5#include <freertos/FreeRTOS.h>
6#include <freertos/semphr.h>
32 void push(
IView* view,
void* context =
nullptr);
83 uint8_t
depth()
const {
return depth_; }
88 bool isEmpty()
const {
return depth_ == 0; }
118 void render(
bool synchronous =
false);
159 IView*
getModal()
const {
return modalDepth_ > 0 ? modals_[modalDepth_ - 1] :
nullptr; }
217 ViewStack() =
default;
219 static constexpr uint8_t MAX_MODAL_DEPTH = 4;
223 IView* modals_[MAX_MODAL_DEPTH] = {};
224 uint8_t modalDepth_ = 0;
225 IView* pendingPush_ =
nullptr;
226 void* pendingContext_ =
nullptr;
227 bool needsFullRefresh_ =
true;
228 const void* exclusiveOwner_ =
nullptr;
229 SemaphoreHandle_t mutex_ =
nullptr;
234 void push_unlocked(IView* view,
void* context);
236 void hideModal_unlocked();
237 void removeModal_unlocked(IView* modal);
241 uint32_t inactivityTimeoutMs_ = 0;
242 uint32_t lastActivityMs_ = 0;
void popToDepth(uint8_t targetDepth)
Pops views until the stack depth is at most targetDepth.
void setInactivityTimeout(InactivityCallback callback, uint32_t timeoutMs)
void dispatchLongPress(char key)
void replace(IView *view, void *context=nullptr)
void dispatchKey(char key)
void dispatchTick(uint32_t nowMs)
static ViewStack & instance()
Returns singleton view-stack instance.
void removeModal(IView *modal)
Remove a specific modal from any position in the modal stack.
const void * exclusiveOwner() const
Returns current exclusive owner, or nullptr if none.
void showModal(IView *modal)
bool releaseExclusive(const void *owner)
Releases exclusive ownership.
static constexpr uint8_t MAX_DEPTH
void(*)() InactivityCallback
bool acquireExclusive(const void *owner)
Acquires exclusive ownership of the view stack.
void checkInactivity(uint32_t nowMs)
void popToAnchor(IView *anchor)
Pops views until the specified anchor view is the current view.
void push(IView *view, void *context=nullptr)
IView * at(uint8_t depth) const
void resetInactivityTimer()
Centralized key-code constants for cdc_views.