Tabs#
ui_tabs draws a row of tabs and keeps the index of the active one in a variable of yours. Your code draws the
content of the active tab under it.
enum { TAB_LAUNCHER, TAB_PANELS, TAB_KEYPAD, TAB_COUNT };
static const char *const tab_names[TAB_COUNT] = {"Launcher", "Panels", "Keypad"};
static uint8_t tab;
ui_tabs(&tab, tab_names, TAB_COUNT);
if (tab == TAB_LAUNCHER) launcher();
if (tab == TAB_PANELS) panels();
if (tab == TAB_KEYPAD) keypad();
The row of tabs is one focus stop. [left] and [right] switch tabs and stop at the first and the last one. [down]
moves focus into the content. ui_tabs returns true in the frame the active tab changed, which is the place to reset
or load something for the new tab.
Each tab is as wide as its label plus the style’s padding. The active tab is drawn in ui_style_tab’s UI_ON colors,
or its UI_FOCUS colors while the row has focus. A value of *active out of range is set to 0.
Because the content is plain code under an if, widgets of the other tabs do not exist while their tab is hidden,
and each tab can keep its own state in its own variables, such as its own ui_scroll_t.
The Launcher tab of the showcase’s Layout screen.#
The Keypad tab: a display label and a grid of buttons with ui_height.#