Skip to content

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

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.

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::AppBase

CRTP 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.

FieldTypeDescription
applv_obj_t *This app’s root LVGL object.
app_clv_obj_t *Parent container.
parent_appDerived *Parent app (for sub-apps)

Members

MemberDescription
AppBase
AppBase
getName
AddFlag
HasFlag
start
resumePlatform only The framework calls it after start().
setSelfRefSet by the app factory so a deferred self-close can hold the app alive until the callback runs.
destroyAppAsyncClose this app from inside itself.
destroyApp
setOnShow
setOnBackOptional in-app handler for the power button’s short click.
setOnDestroy
setPadLogicNameDeclarative pad logic: name auto-activated on start() and restored on destroyApp().
getAppContainer
getIcon
isVisible
isStarted
handleBackContextual “back” gesture (the power button’s short click) offered to the app before the framework closes it.

Methods

AppBase(lv_obj_t *app_c, const char *name, const char *icon, CreateFn create, DestroyFn destroy=lv_Default_onDestroy)
AppBase(Derived *parent, const char *name, const char *icon, CreateFn create, DestroyFn destroy=lv_Default_onDestroy)
const char * getName() const override
virtual void AddFlag(AppFlags flag) override
virtual bool HasFlag(AppFlags flag) override
virtual void start(lv_obj_t *parent=lv_screen_active()) override

Platform only The framework calls it after start().

virtual void resume() override
virtual void setSelfRef(std::weak_ptr< ILvglApp > self) override

Set 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.

virtual void destroyAppAsync() override

Close 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.

virtual void destroyApp() override
void setOnShow(ShowFn show)
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.

void setOnDestroy(DestroyFn dest)
virtual void setPadLogicName(const char *name) override

Declarative pad logic: name auto-activated on start() and restored on destroyApp().

Default no-op so non-AppBase implementers are unaffected.

virtual lv_obj_t * getAppContainer() override
virtual const char * getIcon() override
bool isVisible()
virtual bool isStarted() override
virtual bool handleBack() override

Contextual “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.