mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
Added settings app (#27)
- Added Settings app to show all apps of type `AppTypeSettings`. - Removed the `AppTypeSettings` apps from the Desktop app.
This commit is contained in:
parent
d171b9a231
commit
7f133e65c5
@ -11,9 +11,13 @@ typedef struct _lv_obj_t lv_obj_t;
|
|||||||
typedef void* App;
|
typedef void* App;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
/** A desktop app sits at the root of the app stack managed by the Loader service */
|
||||||
AppTypeDesktop,
|
AppTypeDesktop,
|
||||||
|
/** Standard apps, provided by the system. */
|
||||||
AppTypeSystem,
|
AppTypeSystem,
|
||||||
|
/** The apps that are launched/shown by the Settings app. The Settings app itself is of type AppTypeSystem. */
|
||||||
AppTypeSettings,
|
AppTypeSettings,
|
||||||
|
/** User-provided apps. */
|
||||||
AppTypeUser
|
AppTypeUser
|
||||||
} AppType;
|
} AppType;
|
||||||
|
|
||||||
|
|||||||
@ -25,8 +25,6 @@ static void desktop_show(TT_UNUSED App app, TT_UNUSED lv_obj_t* parent) {
|
|||||||
|
|
||||||
lv_list_add_text(list, "System");
|
lv_list_add_text(list, "System");
|
||||||
tt_app_manifest_registry_for_each_of_type(AppTypeSystem, list, create_app_widget);
|
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");
|
lv_list_add_text(list, "User");
|
||||||
tt_app_manifest_registry_for_each_of_type(AppTypeUser, list, create_app_widget);
|
tt_app_manifest_registry_for_each_of_type(AppTypeUser, list, create_app_widget);
|
||||||
}
|
}
|
||||||
|
|||||||
38
tactility/src/apps/settings/settings.c
Normal file
38
tactility/src/apps/settings/settings.c
Normal file
@ -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
|
||||||
|
};
|
||||||
@ -26,11 +26,13 @@ static const ServiceManifest* const system_services[] = {
|
|||||||
|
|
||||||
extern const AppManifest desktop_app;
|
extern const AppManifest desktop_app;
|
||||||
extern const AppManifest display_app;
|
extern const AppManifest display_app;
|
||||||
|
extern const AppManifest settings_app;
|
||||||
extern const AppManifest system_info_app;
|
extern const AppManifest system_info_app;
|
||||||
|
|
||||||
static const AppManifest* const system_apps[] = {
|
static const AppManifest* const system_apps[] = {
|
||||||
&desktop_app,
|
&desktop_app,
|
||||||
&display_app,
|
&display_app,
|
||||||
|
&settings_app,
|
||||||
&system_info_app
|
&system_info_app
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user