MenuScreen
-
class MenuScreen
- #include <MenuScreen.h>
Represents single screen with number of menu items. Contains logic of navigating between items. Stores current cursor and view.
Public Functions
-
MenuScreen(MenuItem **items)
Constructor
-
void setParent(MenuScreen *parent)
Set new parent screen.
Protected Functions
-
void setCursor(MenuRenderer *renderer, uint8_t position)
Move cursor to specified position.
-
void draw(MenuRenderer *renderer)
Draw the screen on screen.
- Parameters:
renderer – The renderer to use for drawing.
-
void syncIndicators(uint8_t index, MenuRenderer *renderer)
Sync indicators with the renderer.
-
bool process(LcdMenu *menu, const unsigned char command)
Process the command.
- Returns:
true
if the command was processed,false
otherwise.
-
void up(MenuRenderer *renderer)
Move cursor up.
-
void down(MenuRenderer *renderer)
Move cursor down.
-
void reset(MenuRenderer *renderer)
Reset the screen to initial state.
Private Members
- friend LcdMenu
-
MenuScreen *parent = NULL
Previous screen. When
BACK
command received this screen will be shown.
-
MenuItem **items = NULL
The menu items to be displayed on screen. These items will be drawn on renderer.
-
uint8_t cursor = 0
Cursor position.
X X X X X X X ┌───────────────┐ │ X X X │ │ X X X X │ │ > X X X X X X │ <── cursor │ X X X X X │ └───────────────┘ X X X X X X X X X X
When
up
ordown
then this position will be moved over the items accordingly. Always in range [view
,view
+renderer.getMaxRows()
- 1].
-
uint8_t view = 0
First visible item’s position in the menu array.
X X X X X X X ┌───────────────┐ │ X X X │ <── view │ X X X X │ │ > X X X X X X │ │ X X X X X │ └───────────────┘ X X X X X X X X X X
Is moved when
cursor
crosses the borders of visible area. When number of items <renderer.getMaxRows()
this index should be 0. The size of the view is always the same and equals torenderer.getMaxRows()
.
-
MenuScreen(MenuItem **items)