From 881c8517bfc9f4615509e06d3cb85d689052cc13 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Fri, 22 Nov 2024 23:47:18 +0100 Subject: [PATCH] Simplified toolbar creation (#83) --- AppEsp32/Source/HelloWorld/HelloWorld.cpp | 2 +- AppSim/Source/HelloWorld/hello_world.cpp | 2 +- README.md | 2 +- Tactility/Source/Apps/Display/Display.cpp | 2 +- Tactility/Source/Apps/Gpio/Gpio.cpp | 2 +- Tactility/Source/Apps/ImageViewer/ImageViewer.cpp | 2 +- Tactility/Source/Apps/Power/Power.cpp | 2 +- Tactility/Source/Apps/Screenshot/ScreenshotUi.cpp | 2 +- Tactility/Source/Apps/Settings/Settings.cpp | 2 +- Tactility/Source/Apps/SystemInfo/SystemInfo.cpp | 2 +- Tactility/Source/Apps/TextViewer/TextViewer.cpp | 2 +- Tactility/Source/Apps/WifiConnect/WifiConnectView.cpp | 2 +- Tactility/Source/Apps/WifiManager/WifiManageView.cpp | 2 +- Tactility/Source/Ui/Toolbar.cpp | 2 +- Tactility/Source/Ui/Toolbar.h | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/AppEsp32/Source/HelloWorld/HelloWorld.cpp b/AppEsp32/Source/HelloWorld/HelloWorld.cpp index 3231c51d..6c8e4a6b 100644 --- a/AppEsp32/Source/HelloWorld/HelloWorld.cpp +++ b/AppEsp32/Source/HelloWorld/HelloWorld.cpp @@ -2,7 +2,7 @@ #include "Ui/Toolbar.h" static void app_show(tt::App app, lv_obj_t* parent) { - lv_obj_t* toolbar = tt::lvgl::toolbar_create_for_app(parent, app); + lv_obj_t* toolbar = tt::lvgl::toolbar_create(parent, app); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_t* label = lv_label_create(parent); diff --git a/AppSim/Source/HelloWorld/hello_world.cpp b/AppSim/Source/HelloWorld/hello_world.cpp index f623cb13..5a7081e6 100644 --- a/AppSim/Source/HelloWorld/hello_world.cpp +++ b/AppSim/Source/HelloWorld/hello_world.cpp @@ -1,7 +1,7 @@ #include "Ui/Toolbar.h" static void app_show(tt::App app, lv_obj_t* parent) { - lv_obj_t* toolbar = tt::lvgl::toolbar_create_for_app(parent, app); + lv_obj_t* toolbar = tt::lvgl::toolbar_create(parent, app); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_t* label = lv_label_create(parent); diff --git a/README.md b/README.md index adfe77b8..15310495 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Creating a touch-capable UI is [easy](https://docs.lvgl.io/9.0/get-started/quick ```C++ static void app_show(App app, lv_obj_t* parent) { // Default toolbar with app name and close button - lv_obj_t* toolbar = tt::toolbar_create_for_app(parent, app); + lv_obj_t* toolbar = tt::lvgl::toolbar_create(parent, app); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); // Label widget diff --git a/Tactility/Source/Apps/Display/Display.cpp b/Tactility/Source/Apps/Display/Display.cpp index 946e9118..c80e1bf3 100644 --- a/Tactility/Source/Apps/Display/Display.cpp +++ b/Tactility/Source/Apps/Display/Display.cpp @@ -70,7 +70,7 @@ static void on_orientation_set(lv_event_t* event) { static void app_show(App app, lv_obj_t* parent) { lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lvgl::toolbar_create_for_app(parent, app); + lvgl::toolbar_create(parent, app); lv_obj_t* wrapper = lv_obj_create(parent); lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN); diff --git a/Tactility/Source/Apps/Gpio/Gpio.cpp b/Tactility/Source/Apps/Gpio/Gpio.cpp index 2fb0506a..6bf75be6 100644 --- a/Tactility/Source/Apps/Gpio/Gpio.cpp +++ b/Tactility/Source/Apps/Gpio/Gpio.cpp @@ -123,7 +123,7 @@ static void app_show(App app, lv_obj_t* parent) { auto* gpio = static_cast(tt_app_get_data(app)); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lv_obj_t* toolbar = lvgl::toolbar_create_for_app(parent, app); + lv_obj_t* toolbar = lvgl::toolbar_create(parent, app); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); // Main content wrapper, enables scrolling content without scrolling the toolbar diff --git a/Tactility/Source/Apps/ImageViewer/ImageViewer.cpp b/Tactility/Source/Apps/ImageViewer/ImageViewer.cpp index 4ee3d136..65d58e31 100644 --- a/Tactility/Source/Apps/ImageViewer/ImageViewer.cpp +++ b/Tactility/Source/Apps/ImageViewer/ImageViewer.cpp @@ -10,7 +10,7 @@ namespace tt::app::image_viewer { static void on_show(App app, lv_obj_t* parent) { lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lvgl::toolbar_create_for_app(parent, app); + lvgl::toolbar_create(parent, app); lv_obj_t* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); diff --git a/Tactility/Source/Apps/Power/Power.cpp b/Tactility/Source/Apps/Power/Power.cpp index e9f6e0f0..f0764559 100644 --- a/Tactility/Source/Apps/Power/Power.cpp +++ b/Tactility/Source/Apps/Power/Power.cpp @@ -56,7 +56,7 @@ static void on_power_enabled_change(lv_event_t* event) { static void app_show(App app, lv_obj_t* parent) { lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lvgl::toolbar_create_for_app(parent, app); + lvgl::toolbar_create(parent, app); lv_obj_t* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); diff --git a/Tactility/Source/Apps/Screenshot/ScreenshotUi.cpp b/Tactility/Source/Apps/Screenshot/ScreenshotUi.cpp index 16e3fbb0..bd672a07 100644 --- a/Tactility/Source/Apps/Screenshot/ScreenshotUi.cpp +++ b/Tactility/Source/Apps/Screenshot/ScreenshotUi.cpp @@ -155,7 +155,7 @@ static void create_timer_settings_ui(ScreenshotUi* ui, lv_obj_t* parent) { void create_ui(App app, ScreenshotUi* ui, lv_obj_t* parent) { lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lv_obj_t* toolbar = lvgl::toolbar_create_for_app(parent, app); + lv_obj_t* toolbar = lvgl::toolbar_create(parent, app); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_t* wrapper = lv_obj_create(parent); diff --git a/Tactility/Source/Apps/Settings/Settings.cpp b/Tactility/Source/Apps/Settings/Settings.cpp index 7b312724..4e58c64e 100644 --- a/Tactility/Source/Apps/Settings/Settings.cpp +++ b/Tactility/Source/Apps/Settings/Settings.cpp @@ -26,7 +26,7 @@ static void create_app_widget(const AppManifest* manifest, void* parent) { static void on_show(App app, lv_obj_t* parent) { lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lvgl::toolbar_create_for_app(parent, app); + lvgl::toolbar_create(parent, app); lv_obj_t* list = lv_list_create(parent); lv_obj_set_width(list, LV_PCT(100)); diff --git a/Tactility/Source/Apps/SystemInfo/SystemInfo.cpp b/Tactility/Source/Apps/SystemInfo/SystemInfo.cpp index 223357c7..57fcb4c5 100644 --- a/Tactility/Source/Apps/SystemInfo/SystemInfo.cpp +++ b/Tactility/Source/Apps/SystemInfo/SystemInfo.cpp @@ -67,7 +67,7 @@ static void add_memory_bar(lv_obj_t* parent, const char* label, size_t used, siz static void on_show(App app, lv_obj_t* parent) { lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lvgl::toolbar_create_for_app(parent, app); + lvgl::toolbar_create(parent, app); // This wrapper automatically has its children added vertically underneath eachother lv_obj_t* wrapper = lv_obj_create(parent); diff --git a/Tactility/Source/Apps/TextViewer/TextViewer.cpp b/Tactility/Source/Apps/TextViewer/TextViewer.cpp index add4dcc8..15d245be 100644 --- a/Tactility/Source/Apps/TextViewer/TextViewer.cpp +++ b/Tactility/Source/Apps/TextViewer/TextViewer.cpp @@ -11,7 +11,7 @@ namespace tt::app::text_viewer { static void on_show(App app, lv_obj_t* parent) { lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lvgl::toolbar_create_for_app(parent, app); + lvgl::toolbar_create(parent, app); lv_obj_t* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); diff --git a/Tactility/Source/Apps/WifiConnect/WifiConnectView.cpp b/Tactility/Source/Apps/WifiConnect/WifiConnectView.cpp index 2e47c235..0b161ddf 100644 --- a/Tactility/Source/Apps/WifiConnect/WifiConnectView.cpp +++ b/Tactility/Source/Apps/WifiConnect/WifiConnectView.cpp @@ -118,7 +118,7 @@ void view_create(App app, void* wifi, lv_obj_t* parent) { WifiConnectView* view = &wifi_connect->view; lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lvgl::toolbar_create_for_app(parent, app); + lvgl::toolbar_create(parent, app); lv_obj_t* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); diff --git a/Tactility/Source/Apps/WifiManager/WifiManageView.cpp b/Tactility/Source/Apps/WifiManager/WifiManageView.cpp index 35ee6449..930897fe 100644 --- a/Tactility/Source/Apps/WifiManager/WifiManageView.cpp +++ b/Tactility/Source/Apps/WifiManager/WifiManageView.cpp @@ -133,7 +133,7 @@ void view_create(App app, WifiManageView* view, WifiManageBindings* bindings, lv view->root = parent; lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); - lvgl::toolbar_create_for_app(parent, app); + lvgl::toolbar_create(parent, app); lv_obj_t* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); diff --git a/Tactility/Source/Ui/Toolbar.cpp b/Tactility/Source/Ui/Toolbar.cpp index 06d75259..dd2e1c64 100644 --- a/Tactility/Source/Ui/Toolbar.cpp +++ b/Tactility/Source/Ui/Toolbar.cpp @@ -85,7 +85,7 @@ lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title) { return obj; } -lv_obj_t* toolbar_create_for_app(lv_obj_t* parent, App app) { +lv_obj_t* toolbar_create(lv_obj_t* parent, App app) { const AppManifest& manifest = tt_app_get_manifest(app); lv_obj_t* toolbar = toolbar_create(parent, manifest.name); toolbar_set_nav_action(toolbar, LV_SYMBOL_CLOSE, &stop_app, nullptr); diff --git a/Tactility/Source/Ui/Toolbar.h b/Tactility/Source/Ui/Toolbar.h index 86ee0344..c7031fa4 100644 --- a/Tactility/Source/Ui/Toolbar.h +++ b/Tactility/Source/Ui/Toolbar.h @@ -19,7 +19,7 @@ typedef struct { } ToolbarAction; lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title); -lv_obj_t* toolbar_create_for_app(lv_obj_t* parent, tt::App app); +lv_obj_t* toolbar_create(lv_obj_t* parent, tt::App app); void toolbar_set_title(lv_obj_t* obj, const std::string& title); void toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data); uint8_t toolbar_add_action(lv_obj_t* obj, const char* icon, const char* text, lv_event_cb_t callback, void* user_data);