Simplified toolbar creation (#83)
This commit is contained in:
parent
a4593c6248
commit
881c8517bf
@ -2,7 +2,7 @@
|
|||||||
#include "Ui/Toolbar.h"
|
#include "Ui/Toolbar.h"
|
||||||
|
|
||||||
static void app_show(tt::App app, lv_obj_t* parent) {
|
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_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||||
|
|
||||||
lv_obj_t* label = lv_label_create(parent);
|
lv_obj_t* label = lv_label_create(parent);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "Ui/Toolbar.h"
|
#include "Ui/Toolbar.h"
|
||||||
|
|
||||||
static void app_show(tt::App app, lv_obj_t* parent) {
|
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_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||||
|
|
||||||
lv_obj_t* label = lv_label_create(parent);
|
lv_obj_t* label = lv_label_create(parent);
|
||||||
|
|||||||
@ -44,7 +44,7 @@ Creating a touch-capable UI is [easy](https://docs.lvgl.io/9.0/get-started/quick
|
|||||||
```C++
|
```C++
|
||||||
static void app_show(App app, lv_obj_t* parent) {
|
static void app_show(App app, lv_obj_t* parent) {
|
||||||
// Default toolbar with app name and close button
|
// 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);
|
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||||
|
|
||||||
// Label widget
|
// Label widget
|
||||||
|
|||||||
@ -70,7 +70,7 @@ static void on_orientation_set(lv_event_t* event) {
|
|||||||
static void app_show(App app, lv_obj_t* parent) {
|
static void app_show(App app, lv_obj_t* parent) {
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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_t* wrapper = lv_obj_create(parent);
|
||||||
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
|
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
|
||||||
|
|||||||
@ -123,7 +123,7 @@ static void app_show(App app, lv_obj_t* parent) {
|
|||||||
auto* gpio = static_cast<Gpio*>(tt_app_get_data(app));
|
auto* gpio = static_cast<Gpio*>(tt_app_get_data(app));
|
||||||
|
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||||
|
|
||||||
// Main content wrapper, enables scrolling content without scrolling the toolbar
|
// Main content wrapper, enables scrolling content without scrolling the toolbar
|
||||||
|
|||||||
@ -10,7 +10,7 @@ namespace tt::app::image_viewer {
|
|||||||
|
|
||||||
static void on_show(App app, lv_obj_t* parent) {
|
static void on_show(App app, lv_obj_t* parent) {
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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_t* wrapper = lv_obj_create(parent);
|
||||||
lv_obj_set_width(wrapper, LV_PCT(100));
|
lv_obj_set_width(wrapper, LV_PCT(100));
|
||||||
|
|||||||
@ -56,7 +56,7 @@ static void on_power_enabled_change(lv_event_t* event) {
|
|||||||
static void app_show(App app, lv_obj_t* parent) {
|
static void app_show(App app, lv_obj_t* parent) {
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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_t* wrapper = lv_obj_create(parent);
|
||||||
lv_obj_set_width(wrapper, LV_PCT(100));
|
lv_obj_set_width(wrapper, LV_PCT(100));
|
||||||
|
|||||||
@ -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) {
|
void create_ui(App app, ScreenshotUi* ui, lv_obj_t* parent) {
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||||
|
|
||||||
lv_obj_t* wrapper = lv_obj_create(parent);
|
lv_obj_t* wrapper = lv_obj_create(parent);
|
||||||
|
|||||||
@ -26,7 +26,7 @@ static void create_app_widget(const AppManifest* manifest, void* parent) {
|
|||||||
static void on_show(App app, lv_obj_t* parent) {
|
static void on_show(App app, lv_obj_t* parent) {
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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_t* list = lv_list_create(parent);
|
||||||
lv_obj_set_width(list, LV_PCT(100));
|
lv_obj_set_width(list, LV_PCT(100));
|
||||||
|
|||||||
@ -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) {
|
static void on_show(App app, lv_obj_t* parent) {
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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
|
// This wrapper automatically has its children added vertically underneath eachother
|
||||||
lv_obj_t* wrapper = lv_obj_create(parent);
|
lv_obj_t* wrapper = lv_obj_create(parent);
|
||||||
|
|||||||
@ -11,7 +11,7 @@ namespace tt::app::text_viewer {
|
|||||||
|
|
||||||
static void on_show(App app, lv_obj_t* parent) {
|
static void on_show(App app, lv_obj_t* parent) {
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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_t* wrapper = lv_obj_create(parent);
|
||||||
lv_obj_set_width(wrapper, LV_PCT(100));
|
lv_obj_set_width(wrapper, LV_PCT(100));
|
||||||
|
|||||||
@ -118,7 +118,7 @@ void view_create(App app, void* wifi, lv_obj_t* parent) {
|
|||||||
WifiConnectView* view = &wifi_connect->view;
|
WifiConnectView* view = &wifi_connect->view;
|
||||||
|
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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_t* wrapper = lv_obj_create(parent);
|
||||||
lv_obj_set_width(wrapper, LV_PCT(100));
|
lv_obj_set_width(wrapper, LV_PCT(100));
|
||||||
|
|||||||
@ -133,7 +133,7 @@ void view_create(App app, WifiManageView* view, WifiManageBindings* bindings, lv
|
|||||||
view->root = parent;
|
view->root = parent;
|
||||||
|
|
||||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
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_t* wrapper = lv_obj_create(parent);
|
||||||
lv_obj_set_width(wrapper, LV_PCT(100));
|
lv_obj_set_width(wrapper, LV_PCT(100));
|
||||||
|
|||||||
@ -85,7 +85,7 @@ lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title) {
|
|||||||
return obj;
|
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);
|
const AppManifest& manifest = tt_app_get_manifest(app);
|
||||||
lv_obj_t* toolbar = toolbar_create(parent, manifest.name);
|
lv_obj_t* toolbar = toolbar_create(parent, manifest.name);
|
||||||
toolbar_set_nav_action(toolbar, LV_SYMBOL_CLOSE, &stop_app, nullptr);
|
toolbar_set_nav_action(toolbar, LV_SYMBOL_CLOSE, &stop_app, nullptr);
|
||||||
|
|||||||
@ -19,7 +19,7 @@ typedef struct {
|
|||||||
} ToolbarAction;
|
} ToolbarAction;
|
||||||
|
|
||||||
lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title);
|
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_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);
|
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);
|
uint8_t toolbar_add_action(lv_obj_t* obj, const char* icon, const char* text, lv_event_cb_t callback, void* user_data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user