diff --git a/tactility/src/app_manifest.h b/tactility/src/app_manifest.h index ea3b7443..ee030b71 100644 --- a/tactility/src/app_manifest.h +++ b/tactility/src/app_manifest.h @@ -11,9 +11,13 @@ typedef struct _lv_obj_t lv_obj_t; typedef void* App; typedef enum { + /** A desktop app sits at the root of the app stack managed by the Loader service */ AppTypeDesktop, + /** Standard apps, provided by the system. */ AppTypeSystem, + /** The apps that are launched/shown by the Settings app. The Settings app itself is of type AppTypeSystem. */ AppTypeSettings, + /** User-provided apps. */ AppTypeUser } AppType; diff --git a/tactility/src/apps/desktop/desktop.c b/tactility/src/apps/desktop/desktop.c index 3b240e87..b9e552eb 100644 --- a/tactility/src/apps/desktop/desktop.c +++ b/tactility/src/apps/desktop/desktop.c @@ -25,8 +25,6 @@ static void desktop_show(TT_UNUSED App app, TT_UNUSED lv_obj_t* parent) { lv_list_add_text(list, "System"); tt_app_manifest_registry_for_each_of_type(AppTypeSystem, list, create_app_widget); - lv_list_add_text(list, "Settings"); - tt_app_manifest_registry_for_each_of_type(AppTypeSettings, list, create_app_widget); lv_list_add_text(list, "User"); tt_app_manifest_registry_for_each_of_type(AppTypeUser, list, create_app_widget); } diff --git a/tactility/src/apps/settings/settings.c b/tactility/src/apps/settings/settings.c new file mode 100644 index 00000000..c74bdd02 --- /dev/null +++ b/tactility/src/apps/settings/settings.c @@ -0,0 +1,38 @@ +#include "app_manifest_registry.h" +#include "check.h" +#include "lvgl.h" +#include "services/loader/loader.h" + +static void on_app_pressed(lv_event_t* e) { + lv_event_code_t code = lv_event_get_code(e); + if (code == LV_EVENT_CLICKED) { + const AppManifest* manifest = lv_event_get_user_data(e); + loader_start_app(manifest->id, false, NULL); + } +} + +static void create_app_widget(const AppManifest* manifest, void* _Nullable parent) { + tt_check(parent); + lv_obj_t* list = (lv_obj_t*)parent; + lv_obj_t* btn = lv_list_add_btn(list, LV_SYMBOL_FILE, manifest->name); + lv_obj_add_event_cb(btn, &on_app_pressed, LV_EVENT_CLICKED, (void*)manifest); +} + +static void on_show(TT_UNUSED App app, TT_UNUSED lv_obj_t* parent) { + lv_obj_t* list = lv_list_create(parent); + lv_obj_set_size(list, LV_PCT(100), LV_PCT(100)); + lv_obj_center(list); + + tt_app_manifest_registry_for_each_of_type(AppTypeSettings, list, create_app_widget); +} + +const AppManifest settings_app = { + .id = "settings", + .name = "Settings", + .icon = NULL, + .type = AppTypeSystem, + .on_start = NULL, + .on_stop = NULL, + .on_show = &on_show, + .on_hide = NULL +}; diff --git a/tactility/src/tactility.c b/tactility/src/tactility.c index ed2cc7ea..34370512 100644 --- a/tactility/src/tactility.c +++ b/tactility/src/tactility.c @@ -26,11 +26,13 @@ static const ServiceManifest* const system_services[] = { extern const AppManifest desktop_app; extern const AppManifest display_app; +extern const AppManifest settings_app; extern const AppManifest system_info_app; static const AppManifest* const system_apps[] = { &desktop_app, &display_app, + &settings_app, &system_info_app };