Open
Description
I am trying to to create a menu where the renderer will also display the parent item name on the current item. For example, think of this structure:
Main Menu
- Item 1
-- Item A
-- Item B
- Item 2
- Item 3
So, when browsing the menu, you will get something like this:
Line 1: Main Menu
Line 2: Item1
Or this:
Line 1: Item 1
Line 2: Item A
This is my current (and early) implementation of a renderer:
class Renderer : public MenuComponentRenderer {
public:
void render(Menu const& menu) const {
oled.clearDisplay();
menu.get_current_component()->render(*this);
}
void render_menu_item(MenuItem const& menu_item) const {
oled.setTextSize(1);
oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.println("Menu Item");
oled.setTextSize(2);
oled.setTextColor(WHITE);
oled.setCursor(0,17);
oled.println(menu_item.get_name());
oled.display();
}
void render_back_menu_item(BackMenuItem const& menu_item) const {}
void render_numeric_menu_item(NumericMenuItem const& menu_item) const {}
void render_menu(Menu const& menu) const {
oled.setTextSize(1);
oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.println("Render menu");
oled.setTextSize(2);
oled.setTextColor(WHITE);
oled.setCursor(0,17);
oled.print(menu.get_name());
oled.display();
}
};
Renderer menu_render;
I can see there are methods like get_parent(), but I am not sure of how to implement them. Can you please point me to the right direction? I am quite new to arduino programming...