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

#include <MessageBox.h>

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

Public Types

using CloseCallback = void(*)()

Public Member Functions

void init (const char *message, MessageIcon icon=MessageIcon::NONE, uint32_t timeoutMs=0)
 Initializes message box state.
void setOnClose (CloseCallback callback)
void render (bool partial) override
 Renders the modal message box.
InputResult onKey (char key) override
 Handles key input for manual dismissal.
void onTick (uint32_t nowMs) override
 Updates timeout-based auto-dismiss behavior.
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)

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

MessageBox - System feedback overlay

Displays a centered message box for user feedback. Can have optional icon and auto-dismiss timeout.

Keys: Y/N = Close (if interactive)

Definition at line 28 of file MessageBox.h.

Member Typedef Documentation

◆ CloseCallback

Close callback (called when message is dismissed)

Definition at line 33 of file MessageBox.h.

Member Function Documentation

◆ getFooterHint()

const char * cdc::ui::MessageBox::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 54 of file MessageBox.h.

◆ getName()

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

Get view name for debugging

Implements cdc::ui::IView.

Definition at line 53 of file MessageBox.h.

◆ init()

void cdc::ui::MessageBox::init ( const char * message,
MessageIcon icon = MessageIcon::NONE,
uint32_t timeoutMs = 0 )

Initializes message box state.

Initialize message box

Parameters
messageText to display
iconIcon type (NONE, SUCCESS, ERROR, INFO, WARNING)
timeoutMsAuto-dismiss timeout (0 = no auto-dismiss)
messageMessage text to display.
iconIcon type for the message.
timeoutMsAuto-close timeout in milliseconds.
Returns
void

Definition at line 37 of file MessageBox.cpp.

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

◆ onKey()

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

Handles key input for manual dismissal.

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

Implements cdc::ui::IView.

Definition at line 75 of file MessageBox.cpp.

References cdc::ui::CONSUMED, cdc::ui::hideMessage(), cdc::ui::IGNORED, cdc::ui::KEY_NO, cdc::ui::KEY_YES, LOG_D, and cdc::ui::TAG.

◆ onTick()

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

Updates timeout-based auto-dismiss behavior.

Parameters
nowMsCurrent monotonic time in milliseconds.
Returns
void

Reimplemented from cdc::ui::IView.

Definition at line 54 of file MessageBox.cpp.

References cdc::ui::hideMessage(), LOG_D, and cdc::ui::TAG.

◆ render()

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

◆ setOnClose()

void cdc::ui::MessageBox::setOnClose ( CloseCallback callback)
inline

Set close callback

Definition at line 47 of file MessageBox.h.


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