Menu System
Pre-built menu UI components
The menu system provides a complete solution for building settings screens and navigation hierarchies.
Menu Entry Types
- Custom - Action triggered on selection
- Submenu - Navigate to nested menu
- Param - Edit a parameter value Any entry may also carry a
ui_gfx_cb- a painter for the side panel while it is the cursor.
Basic Example
static void play_action(ui_menu_t* menu, ui_menu_node_t* entry) {
my_model_t* m = ui_menu_ctx(menu); // the ctx passed to ui_menu_create, at any depth
...
}
static void root_menu(ui_menu_t* menu) { // the builder: runs at create and every ui_menu_show
my_model_t* m = ui_menu_ctx(menu);
ui_menu_add(menu, UI_ACTION("Play", play_action));
ui_menu_add(menu, UI_PARAM("Volume", MenuNodeParam, &m->volume));
}
// init(): m->menu = ui_menu_create(m, root_menu); a button: ui_menu_show(m->menu);Style a menu once (type, position, width, rows - in any order): a submenu inherits the look of the level it was entered from and may change it, and "back" restores the parent's. The menu is modal while shown; BTN4/BTN5 hold go back / close, and closing hides it before the close callback (ui_menu_set_close_cb) runs - which may destroy it.
A pick list: UI_PICK(name, callback, index) entries, and UI_PICK_IDX(entry) in the callback.