AppBase
#include "crosspad-gui/app/AppBase.hpp"Generated from crosspad-gui/app/AppBase.hpp in crosspad-gui. Edit the header’s doxygen comments to change this page.
Recipes that use it: Hello screen, Tempo and transport, UI kit
Functions
Section titled “Functions”defaultAppFactory
Section titled “defaultAppFactory”template <typename AppType>std::shared_ptr< ILvglApp > defaultAppFactory(lv_obj_t *container, const char *name, const char *icon, lv_obj_t *(*create)(lv_obj_t *, AppType *), void(*destroy)(lv_obj_t *))Default app factory — eliminates per-platform boilerplate.
Usage: config.app_factory = crosspad_gui::defaultAppFactory<App>;
Returns a std::shared_ptr so that AppType (which derives from std::enable_shared_from_this) can call shared_from_this() at runtime (required by destroyAppAsync()). Constructing via raw new would leave the internal weak_ptr unset and break shared_from_this().
Declared in crosspad-gui/app/AppBase.hpp:326.
crosspad_gui::AppBase
Section titled “crosspad_gui::AppBase”Put cleanup in the destroy function or setOnDestroy; the IApp hooks it inherits (onAppInit, onAppDeinit, onAppUpdate, onAppActivated) are not part of the app lifecycle.
template <typename Derived>class crosspad_gui::AppBaseCRTP base class for LVGL applications.
Provides the full LVGL lifecycle (start / pause / resume / destroyApp), flag management, and getter/setter boilerplate that would otherwise be duplicated across every platform’s App class.
Platform subclass example:
class App : public crosspad_gui::AppBase<App> {public: using AppBase::AppBase; // inherit constructors Sequencer& sequencer(); // platform-specific accessor};// Use crosspad::getPadManager() etc. directly from PlatformServices.Used in Hello screen, Tempo and transport, UI kit.
| Field | Type | Description |
|---|---|---|
app | lv_obj_t * | This app’s root LVGL object. |
app_c | lv_obj_t * | Parent container. |
parent_app | Derived * | Parent app (for sub-apps) |
Members
| Member | Description |
|---|---|
AppBase | |
AppBase | |
getName | |
AddFlag | |
HasFlag | |
start | |
resume | Platform only The framework calls it after start(). |
setSelfRef | Set by the app factory so a deferred self-close can hold the app alive until the callback runs. |
destroyAppAsync | Close this app from inside itself. |
destroyApp | |
setOnShow | |
setOnBack | Optional in-app handler for the power button’s short click. |
setOnDestroy | |
setPadLogicName | Declarative pad logic: name auto-activated on start() and restored on destroyApp(). |
getAppContainer | |
getIcon | |
isVisible | |
isStarted | |
handleBack | Contextual “back” gesture (the power button’s short click) offered to the app before the framework closes it. |
Methods
AppBase
Section titled “AppBase”AppBase(lv_obj_t *app_c, const char *name, const char *icon, CreateFn create, DestroyFn destroy=lv_Default_onDestroy)AppBase
Section titled “AppBase”AppBase(Derived *parent, const char *name, const char *icon, CreateFn create, DestroyFn destroy=lv_Default_onDestroy)getName
Section titled “getName”const char * getName() const overrideAddFlag
Section titled “AddFlag”virtual void AddFlag(AppFlags flag) overrideHasFlag
Section titled “HasFlag”virtual bool HasFlag(AppFlags flag) overridevirtual void start(lv_obj_t *parent=lv_screen_active()) overrideresume
Section titled “resume”Platform only The framework calls it after start().
virtual void resume() overridesetSelfRef
Section titled “setSelfRef”virtual void setSelfRef(std::weak_ptr< ILvglApp > self) overrideSet by the app factory so a deferred self-close can hold the app alive until the callback runs.
Default no-op for hand-built implementations.
destroyAppAsync
Section titled “destroyAppAsync”virtual void destroyAppAsync() overrideClose this app from inside itself.
Deferring matters: a Back button calls this from an LVGL event callback of a widget that destroyApp() is about to delete, and LVGL must not delete the object whose event it is dispatching.
Used in Hello screen.
destroyApp
Section titled “destroyApp”virtual void destroyApp() overridesetOnShow
Section titled “setOnShow”void setOnShow(ShowFn show)setOnBack
Section titled “setOnBack”void setOnBack(BackFn back)Optional in-app handler for the power button’s short click.
Without one the gesture closes the app (destroyAppAsync).
Used in Hello screen.
setOnDestroy
Section titled “setOnDestroy”void setOnDestroy(DestroyFn dest)setPadLogicName
Section titled “setPadLogicName”virtual void setPadLogicName(const char *name) overrideDeclarative pad logic: name auto-activated on start() and restored on destroyApp().
Default no-op so non-AppBase implementers are unaffected.
getAppContainer
Section titled “getAppContainer”virtual lv_obj_t * getAppContainer() overridegetIcon
Section titled “getIcon”virtual const char * getIcon() overrideisVisible
Section titled “isVisible”bool isVisible()isStarted
Section titled “isStarted”virtual bool isStarted() overridehandleBack
Section titled “handleBack”virtual bool handleBack() overrideContextual “back” gesture (the power button’s short click) offered to the app before the framework closes it.
Return true if the app consumed it — e.g. it stepped out of its own sub-view. Default false: the framework then returns to the launcher.
Declared in crosspad-gui/app/AppBase.hpp:38.