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
Menus/UI/UI.h
- Committer:
- el17ajf
- Date:
- 2019-04-27
- Revision:
- 37:8da316cf4549
- Parent:
- 32:7b5a864b9234
- Child:
- 41:91b0c73b9e02
File content as of revision 37:8da316cf4549:
#ifndef UI_H
#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:
static const int PADDING_X = 3;
static const int PADDING_Y = 4;
static const int LINE_PADDING = 3;
int next_y_pos;
int nextY();
int button_currently_selected;
int button_currently_drawing;
bool button_pressed_frame;
int frame;
};
};
#endif
