Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17ajf by
Diff: Menus/UI/UI.h
- Revision:
- 37:8da316cf4549
- Parent:
- 32:7b5a864b9234
- Child:
- 41:91b0c73b9e02
--- a/Menus/UI/UI.h Wed Apr 24 08:06:29 2019 +0000
+++ b/Menus/UI/UI.h Sat Apr 27 11:49:00 2019 +0000
@@ -2,23 +2,93 @@
#define UI_H
namespace Menus {
+ /**
+ * UI class
+ * @brief Provides a user-friendly abstraction layer above the graphics
+ * namespace, allowing the programmer to add labels, buttons and other
+ * UI elements to the 'canvas', without worrying about positioning or
+ * input management.
+ * @see Graphics::UI
+ */
class UI {
public:
+ /**
+ * @brief Creates a new UI object ready to be used
+ */
UI();
+
+ /**
+ * @brief Destructor
+ */
~UI();
+ /**
+ * @brief Should be called before a new Menu is loaded, to reset state
+ * such as the cursor position.
+ */
void reset();
+
+ /**
+ * @brief Should be called every frame, prepares the 'canvas' for a new
+ * set of 'draw' calls.
+ */
void clear();
+ /**
+ * @brief Draws a 'title' style label to the screen, essentially the
+ * same as drawLabel.
+ * @param text The text of the title, must be <= 8 characters
+ * @see drawLabel
+ */
void drawTitle(const char * text);
+
+ /**
+ * @brief Draws a label to the canvas and advance the 'canvas pointer'.
+ * @param text The text of the label, must be <= 8 characters
+ */
void drawLabel(const char * text);
+
+ /**
+ * @brief
+ * @param text The text of the flashing label, must be <= 8 characters
+ * @see drawLabel
+ */
void drawFlashingLabel(const char * text);
+
+ /**
+ * @brief
+ * @param text The text of the button, must be <= 8 characters
+ * @returns true if the button is pressed this frame, else false.
+ */
bool drawAndCheckButton(const char * text);
+
+ /**
+ * @brief Draws the big inverted 'TETRIS' logo and advances the canvas
+ * pointer.
+ */
void drawLogo();
+ /**
+ * @brief Called to move the 'cursor' (highlighted button) down to
+ * the next one vertically beneath.
+ */
void selectNextButton();
+
+ /**
+ * @brief Called to move the 'cursor' (highlighted button) up to
+ * the next one vertically above.
+ */
void selectPreviousButton();
+
+ /**
+ * @brief "Presses" the current button, so it's draw function
+ * will return true.
+ */
void pressButton();
+
+ /**
+ * @brief Simply adds vertical whitespace to the canvas.
+ */
void newLine();
private:
