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

#include <IView.h>

Inheritance diagram for cdc::ui::ViewBase:
cdc::ui::IView cdc::mod_2fa::OathCodeView cdc::plugin_manager::PluginListView cdc::ui::BlePairingPromptView cdc::ui::BlePairingView cdc::ui::CanvasView cdc::ui::ColorPickerView cdc::ui::ConfirmView cdc::ui::ContextMenuView cdc::ui::DateInputView cdc::ui::InfoView cdc::ui::ListView cdc::ui::LockScreenView cdc::ui::MessageBox cdc::ui::PinChangeView cdc::ui::PinEntryView cdc::ui::QRCodeView cdc::ui::SliderView cdc::ui::T9InputView cdc::ui::TimeInputView cdc::ui::ToastView

Public Member Functions

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 void render (bool partial)=0
virtual bool prefersLightRefresh () const
virtual InputResult onKey (char key)=0
virtual InputResult onLongPress (char key)
virtual void onTick (uint32_t nowMs)
virtual const char * getName () const =0

Protected Member Functions

void setTitle (const char *title)
const char * getTitle () const

Protected Attributes

bool dirty_ = true
const char * title_ = nullptr
const char * customFooter_ = nullptr
void(* onHide_ )(void *) = nullptr
void(* onShow_ )(void *) = nullptr
void * lifecycleUserData_ = nullptr

Detailed Description

ViewBase - Default implementation of IView

Provides common functionality for views:

  • Dirty flag management
  • Title storage
  • Default lifecycle handlers

Definition at line 157 of file IView.h.

Constructor & Destructor Documentation

◆ ~ViewBase()

virtual cdc::ui::ViewBase::~ViewBase ( )
virtualdefault

Member Function Documentation

◆ clearDirty()

void cdc::ui::ViewBase::clearDirty ( )
inlineoverridevirtual

Clear the dirty flag. Called automatically by ViewStack after a successful render() pass. Subclasses that animate or update every tick must call markDirty() themselves in onTick().

Implements cdc::ui::IView.

Definition at line 187 of file IView.h.

References dirty_.

Referenced by cdc::mod_2fa::OathCodeView::render(), cdc::ui::BlePairingPromptView::render(), and cdc::ui::BlePairingView::render().

◆ getFooterHint()

const char * cdc::ui::ViewBase::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 195 of file IView.h.

References customFooter_.

◆ getTitle()

const char * cdc::ui::ViewBase::getTitle ( ) const
inlineprotected

Definition at line 199 of file IView.h.

References title_.

◆ markDirty()

◆ needsRender()

bool cdc::ui::ViewBase::needsRender ( ) const
inlineoverridevirtual

Check if view needs re-rendering

Implements cdc::ui::IView.

Definition at line 185 of file IView.h.

References dirty_.

◆ onEnter()

void cdc::ui::ViewBase::onEnter ( void * context)
inlineoverridevirtual

Called when view becomes active (pushed or becomes top)

Parameters
contextOptional context data from parent

Implements cdc::ui::IView.

Definition at line 162 of file IView.h.

References dirty_.

Referenced by cdc::ui::CanvasView::onEnter().

◆ onExit()

void cdc::ui::ViewBase::onExit ( )
inlineoverridevirtual

Called when view is being removed from stack

Implements cdc::ui::IView.

Definition at line 167 of file IView.h.

Referenced by cdc::ui::CanvasView::onExit().

◆ onPause()

void cdc::ui::ViewBase::onPause ( )
inlineoverridevirtual

Called when the view is covered by another view or modal (still on the stack but no longer active). Counterpart to onResume(). Default no-op.

Reimplemented from cdc::ui::IView.

Definition at line 174 of file IView.h.

References lifecycleUserData_, and onHide_.

◆ onResume()

void cdc::ui::ViewBase::onResume ( )
inlineoverridevirtual

Called when view becomes visible again (child popped)

Implements cdc::ui::IView.

Definition at line 169 of file IView.h.

References dirty_, lifecycleUserData_, and onShow_.

Referenced by cdc::ui::CanvasView::onResume().

◆ setFooterHint()

void cdc::ui::ViewBase::setFooterHint ( const char * hint)
inlineoverridevirtual

Override the footer hint at runtime. Default is a no-op; views that support custom footers (ListView, T9InputView, ...) override this to persist the hint. The string is NOT copied by the view - caller (typically PluginUiState) must keep it alive while the view is shown.

Parameters
hintFooter text, or nullptr to clear the override.

Reimplemented from cdc::ui::IView.

Definition at line 191 of file IView.h.

References customFooter_, and dirty_.

◆ setLifecycleHooks()

void cdc::ui::ViewBase::setLifecycleHooks ( void(* onHide )(void *),
void(* onShow )(void *),
void * userData )
inlineoverridevirtual

Register opaque hooks fired when this view is hidden (onPause) and shown again (onResume). Default is a no-op; ViewBase persists and fires them. Lets callers (e.g. PluginUiState) react to a view being covered/revealed without enumerating concrete view types. Pass nullptr to clear a hook.

Parameters
onHideCalled from onPause(), or nullptr.
onShowCalled from onResume(), or nullptr.
userDataOpaque pointer passed back to both hooks.

Reimplemented from cdc::ui::IView.

Definition at line 178 of file IView.h.

References lifecycleUserData_, onHide_, and onShow_.

◆ setTitle()

void cdc::ui::ViewBase::setTitle ( const char * title)
inlineprotected

Definition at line 198 of file IView.h.

References title_.

Member Data Documentation

◆ customFooter_

◆ dirty_

bool cdc::ui::ViewBase::dirty_ = true
protected

Definition at line 201 of file IView.h.

Referenced by cdc::ui::T9InputView::appendRaw(), cdc::ui::T9InputView::backspace(), clearDirty(), cdc::ui::T9InputView::commitCharacter(), cdc::ui::T9InputView::forceDigit(), cdc::ui::CanvasView::init(), cdc::ui::ColorPickerView::init(), cdc::ui::ConfirmView::init(), cdc::ui::ContextMenuView::init(), cdc::ui::DateInputView::init(), cdc::ui::InfoView::init(), cdc::ui::ListView::init(), cdc::ui::LockScreenView::init(), cdc::ui::MessageBox::init(), cdc::ui::PinChangeView::init(), cdc::ui::PinEntryView::init(), cdc::ui::QRCodeView::init(), cdc::ui::SliderView::init(), cdc::ui::T9InputView::init(), cdc::ui::TimeInputView::init(), cdc::ui::ToastView::init(), markDirty(), needsRender(), cdc::mod_2fa::OathCodeView::onEnter(), cdc::ui::BlePairingPromptView::onEnter(), cdc::ui::BlePairingView::onEnter(), cdc::ui::LockScreenView::onEnter(), cdc::ui::PinEntryView::onEnter(), onEnter(), cdc::ui::PinChangeView::onKey(), cdc::ui::InfoView::onLongPress(), cdc::mod_2fa::OathCodeView::onResume(), cdc::ui::LockScreenView::onResume(), onResume(), cdc::ui::PinChangeView::onTick(), cdc::ui::PinEntryView::onTick(), cdc::ui::BlePairingPromptView::prepare(), cdc::ui::T9InputView::processKey(), cdc::ui::CanvasView::render(), cdc::ui::ColorPickerView::render(), cdc::ui::ConfirmView::render(), cdc::ui::ContextMenuView::render(), cdc::ui::DateInputView::render(), cdc::ui::InfoView::render(), cdc::ui::ListView::render(), cdc::ui::LockScreenView::render(), cdc::ui::MessageBox::render(), cdc::ui::PasswordT9View::render(), cdc::ui::PinChangeView::render(), cdc::ui::PinEntryView::render(), cdc::ui::QRCodeView::render(), cdc::ui::SliderView::render(), cdc::ui::T9InputView::render(), cdc::ui::TimeInputView::render(), cdc::ui::ToastView::render(), cdc::ui::LockScreenView::setBatteryPercent(), cdc::ui::LockScreenView::setClock(), cdc::ui::LockScreenView::setDate(), cdc::ui::LockScreenView::setDisplayName(), setFooterHint(), cdc::ui::LockScreenView::setInfo(), cdc::ui::LockScreenView::setInfo2(), cdc::ui::ListView::setSelection(), cdc::ui::LockScreenView::setStatusIcons(), cdc::ui::SliderView::setValue(), and cdc::ui::LockScreenView::toggleBacklight().

◆ lifecycleUserData_

void* cdc::ui::ViewBase::lifecycleUserData_ = nullptr
protected

Definition at line 207 of file IView.h.

Referenced by onPause(), onResume(), and setLifecycleHooks().

◆ onHide_

void(* cdc::ui::ViewBase::onHide_) (void *) = nullptr
protected

Definition at line 205 of file IView.h.

Referenced by onPause(), and setLifecycleHooks().

◆ onShow_

void(* cdc::ui::ViewBase::onShow_) (void *) = nullptr
protected

Definition at line 206 of file IView.h.

Referenced by onResume(), and setLifecycleHooks().

◆ title_

const char* cdc::ui::ViewBase::title_ = nullptr
protected

The documentation for this class was generated from the following file:
  • components/cdc_ui/include/cdc_ui/IView.h