|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <ContextMenuView.h>
Public Member Functions | |
| void | init (const char *title, const ContextMenuItem *items, uint8_t count) |
| Initializes context menu content and selection state. | |
| uint8_t | getSelection () const |
| void | render (bool partial) override |
| Renders the context menu popup. | |
| InputResult | onKey (char key) override |
| Handles key input for context menu navigation and actions. | |
| void | onTick (uint32_t nowMs) override |
| Auto-dismisses the menu after a period of inactivity. | |
| const char * | getName () const override |
| const char * | getFooterHint () const override |
| Public Member Functions inherited from cdc::ui::ViewBase | |
| virtual | ~ViewBase ()=default |
| void | onEnter (void *context) override |
| void | onExit () override |
| void | onResume () override |
| void | onPause () override |
| void | setLifecycleHooks (void(*onHide)(void *), void(*onShow)(void *), void *userData) override |
| bool | needsRender () const override |
| void | markDirty () override |
| void | clearDirty () override |
| void | setFooterHint (const char *hint) override |
| const char * | getFooterHint () const override |
| Public Member Functions inherited from cdc::ui::IView | |
| virtual | ~IView ()=default |
| virtual bool | prefersLightRefresh () const |
| virtual InputResult | onLongPress (char key) |
Static Public Attributes | |
| static constexpr uint8_t | MAX_ITEMS = 8 |
| static constexpr uint8_t | VISIBLE_ITEMS = 4 |
Additional Inherited Members | |
| Protected Member Functions inherited from cdc::ui::ViewBase | |
| void | setTitle (const char *title) |
| const char * | getTitle () const |
| Protected Attributes inherited from cdc::ui::ViewBase | |
| bool | dirty_ = true |
| const char * | title_ = nullptr |
| const char * | customFooter_ = nullptr |
| void(* | onHide_ )(void *) = nullptr |
| void(* | onShow_ )(void *) = nullptr |
| void * | lifecycleUserData_ = nullptr |
ContextMenuView - Quick popup menu overlay
Shows a centered popup menu that can be triggered from anywhere. Displayed as a modal overlay on top of the current view.
Keys: 2 = Up 8 = Down Y = Select N = Cancel (close menu)
Definition at line 28 of file ContextMenuView.h.
|
inlineoverridevirtual |
Get footer hint text (e.g., "[Y] OK [N] Back") Return nullptr for no footer
Reimplemented from cdc::ui::IView.
Definition at line 51 of file ContextMenuView.h.
|
inlineoverridevirtual |
Get view name for debugging
Implements cdc::ui::IView.
Definition at line 50 of file ContextMenuView.h.
|
inline |
Get current selection
Definition at line 44 of file ContextMenuView.h.
| void cdc::ui::ContextMenuView::init | ( | const char * | title, |
| const ContextMenuItem * | items, | ||
| uint8_t | count ) |
Initializes context menu content and selection state.
Initialize context menu
| title | Menu title |
| items | Array of menu items |
| count | Number of items |
| title | Menu title text. |
| items | Menu item array. |
| count | Number of menu items. |
Definition at line 40 of file ContextMenuView.cpp.
References cdc::ui::ViewBase::dirty_, LOG_D, MAX_ITEMS, and cdc::ui::TAG.
|
overridevirtual |
Handles key input for context menu navigation and actions.
| key | Pressed key code. |
Implements cdc::ui::IView.
Definition at line 116 of file ContextMenuView.cpp.
References cdc::ui::CONSUMED, cdc::ui::hideContextMenu(), cdc::ui::IGNORED, cdc::ui::KEY_DOWN, cdc::ui::KEY_NO, cdc::ui::KEY_UP, and cdc::ui::KEY_YES.
|
overridevirtual |
Auto-dismisses the menu after a period of inactivity.
| nowMs | Current uptime in milliseconds. |
Reimplemented from cdc::ui::IView.
Definition at line 144 of file ContextMenuView.cpp.
References cdc::ui::hideContextMenu(), and kMenuTimeoutMs.
|
overridevirtual |
Renders the context menu popup.
| partial | Indicates partial/full redraw mode. |
Implements cdc::ui::IView.
Definition at line 159 of file ContextMenuView.cpp.
References BOX_PADDING, cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::ui::render::drawDialogFrame(), cdc::hal::getDisplayInstance(), ITEM_HEIGHT, cdc::ui::ContextMenuItem::label, MAX_BOX_WIDTH, MIN_BOX_WIDTH, cdc::ui::render::printText(), TITLE_HEIGHT, and VISIBLE_ITEMS.
|
staticconstexpr |
Definition at line 30 of file ContextMenuView.h.
Referenced by init(), cdc::plugin_manager::PluginUiState::pushContextMenu(), and cdc::plugin_manager::w_host_ui_push_context_menu().
|
staticconstexpr |
Definition at line 31 of file ContextMenuView.h.
Referenced by render().