CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::ui::ContextMenuView Class Reference

#include <ContextMenuView.h>

Inheritance diagram for cdc::ui::ContextMenuView:
cdc::ui::ViewBase cdc::ui::IView

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

Detailed Description

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.

Member Function Documentation

◆ getFooterHint()

const char * cdc::ui::ContextMenuView::getFooterHint ( ) const
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.

◆ getName()

const char * cdc::ui::ContextMenuView::getName ( ) const
inlineoverridevirtual

Get view name for debugging

Implements cdc::ui::IView.

Definition at line 50 of file ContextMenuView.h.

◆ getSelection()

uint8_t cdc::ui::ContextMenuView::getSelection ( ) const
inline

Get current selection

Definition at line 44 of file ContextMenuView.h.

◆ init()

void cdc::ui::ContextMenuView::init ( const char * title,
const ContextMenuItem * items,
uint8_t count )

Initializes context menu content and selection state.

Initialize context menu

Parameters
titleMenu title
itemsArray of menu items
countNumber of items
titleMenu title text.
itemsMenu item array.
countNumber of menu items.
Returns
void

Definition at line 40 of file ContextMenuView.cpp.

References cdc::ui::ViewBase::dirty_, LOG_D, MAX_ITEMS, and cdc::ui::TAG.

◆ onKey()

InputResult cdc::ui::ContextMenuView::onKey ( char key)
overridevirtual

Handles key input for context menu navigation and actions.

Parameters
keyPressed key code.
Returns
Input handling result for the view stack.

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.

◆ onTick()

void cdc::ui::ContextMenuView::onTick ( uint32_t nowMs)
overridevirtual

Auto-dismisses the menu after a period of inactivity.

Parameters
nowMsCurrent uptime in milliseconds.
Returns
void

Reimplemented from cdc::ui::IView.

Definition at line 144 of file ContextMenuView.cpp.

References cdc::ui::hideContextMenu(), and kMenuTimeoutMs.

◆ render()

void cdc::ui::ContextMenuView::render ( bool partial)
overridevirtual

Member Data Documentation

◆ MAX_ITEMS

uint8_t cdc::ui::ContextMenuView::MAX_ITEMS = 8
staticconstexpr

◆ VISIBLE_ITEMS

uint8_t cdc::ui::ContextMenuView::VISIBLE_ITEMS = 4
staticconstexpr

Definition at line 31 of file ContextMenuView.h.

Referenced by render().


The documentation for this class was generated from the following files: