-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathItemSubMenu.h
45 lines (40 loc) · 1.22 KB
/
ItemSubMenu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include "BaseItemZeroWidget.h"
#include "LcdMenu.h"
#include "MenuScreen.h"
/**
* @class ItemSubMenu
* @brief Represents a submenu item in a menu.
*
* This class extends the MenuItem class and provides functionality to navigate
* to a different screen when the item is selected.
*/
class ItemSubMenu : public BaseItemZeroWidget {
private:
MenuScreen*& screen;
public:
/**
* @param text text to display for the item
* @param screen the next screen to show
*/
ItemSubMenu(const char* text, MenuScreen*& screen) : BaseItemZeroWidget(text), screen(screen) {}
protected:
void handleCommit(LcdMenu* menu) override {
LOG(F("ItemSubMenu::changeScreen"), text);
screen->setParent(menu->getScreen());
menu->setScreen(screen);
}
};
/**
* @brief Create a new submenu item.
*
* @param text The text to display for the item.
* @param screen The screen to navigate to when the item is selected.
* @return MenuItem* The created item. Caller takes ownership of the returned pointer.
*
* @example
* auto item = ITEM_SUBMENU("Settings", settingsScreen);
*/
inline MenuItem* ITEM_SUBMENU(const char* text, MenuScreen*& screen) {
return new ItemSubMenu(text, screen);
}