From a396eff73e68237b3163a691ea9dfd98d73c8940 Mon Sep 17 00:00:00 2001 From: philmoz Date: Mon, 11 Mar 2024 12:56:46 +1100 Subject: [PATCH] feat(color): run widget 'background' function while in setup pages (#4393) --- radio/src/gui/colorlcd/model_outputs.cpp | 2 +- radio/src/gui/colorlcd/page.cpp | 7 +++++++ radio/src/gui/colorlcd/page.h | 1 + radio/src/gui/colorlcd/radio_theme.cpp | 2 +- radio/src/gui/colorlcd/tabsgroup.cpp | 1 + radio/src/gui/colorlcd/trainer_bluetooth.cpp | 1 + radio/src/gui/colorlcd/view_main.cpp | 9 +++++++++ radio/src/gui/colorlcd/view_main.h | 2 ++ radio/src/gui/colorlcd/widgets/widgets_container_impl.h | 9 +++++++++ radio/src/gui/colorlcd/widgets_container.h | 1 + 10 files changed, 33 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/colorlcd/model_outputs.cpp b/radio/src/gui/colorlcd/model_outputs.cpp index e40cd37d1ec..df472e00d69 100644 --- a/radio/src/gui/colorlcd/model_outputs.cpp +++ b/radio/src/gui/colorlcd/model_outputs.cpp @@ -232,7 +232,7 @@ class OutputLineButton : public ListLineButton void checkEvents() override { - Window::checkEvents(); + ListLineButton::checkEvents(); if (!init) return; int newValue = channelOutputs[index]; diff --git a/radio/src/gui/colorlcd/page.cpp b/radio/src/gui/colorlcd/page.cpp index 17589909217..270d54b607e 100644 --- a/radio/src/gui/colorlcd/page.cpp +++ b/radio/src/gui/colorlcd/page.cpp @@ -24,6 +24,7 @@ #include "keyboard_base.h" #include "opentx.h" #include "theme.h" +#include "view_main.h" PageHeader::PageHeader(Page * parent, uint8_t icon): FormWindow(parent, { 0, 0, LCD_W, MENU_HEADER_HEIGHT }, OPAQUE), @@ -94,3 +95,9 @@ void Page::onCancel() } void Page::onClicked() { Keyboard::hide(false); } + +void Page::checkEvents() +{ + ViewMain::instance()->runBackground(); + NavWindow::checkEvents(); +} diff --git a/radio/src/gui/colorlcd/page.h b/radio/src/gui/colorlcd/page.h index d1f301957b5..563e1f5a74c 100644 --- a/radio/src/gui/colorlcd/page.h +++ b/radio/src/gui/colorlcd/page.h @@ -63,6 +63,7 @@ class Page : public NavWindow PageHeader header; FormWindow body; + void checkEvents() override; bool bubbleEvents() override { return false; } }; diff --git a/radio/src/gui/colorlcd/radio_theme.cpp b/radio/src/gui/colorlcd/radio_theme.cpp index 0b94911c07d..04c7f62911f 100644 --- a/radio/src/gui/colorlcd/radio_theme.cpp +++ b/radio/src/gui/colorlcd/radio_theme.cpp @@ -401,7 +401,7 @@ class ThemeEditPage : public Page started = true; _themeName->setText(_theme.getName()); } - Window::checkEvents(); + Page::checkEvents(); } void editColorPage() diff --git a/radio/src/gui/colorlcd/tabsgroup.cpp b/radio/src/gui/colorlcd/tabsgroup.cpp index 6acaa1943b3..6e946efc9e7 100644 --- a/radio/src/gui/colorlcd/tabsgroup.cpp +++ b/radio/src/gui/colorlcd/tabsgroup.cpp @@ -255,6 +255,7 @@ void TabsGroup::checkEvents() if (currentTab) { currentTab->checkEvents(); } + ViewMain::instance()->runBackground(); static uint32_t lastRefresh = 0; uint32_t now = RTOS_GET_MS(); diff --git a/radio/src/gui/colorlcd/trainer_bluetooth.cpp b/radio/src/gui/colorlcd/trainer_bluetooth.cpp index 31dcdd08803..ddf727c85ea 100644 --- a/radio/src/gui/colorlcd/trainer_bluetooth.cpp +++ b/radio/src/gui/colorlcd/trainer_bluetooth.cpp @@ -116,6 +116,7 @@ void BluetoothTrainerWindow::checkEvents() refresh(); lastbtstate = bluetooth.state; devcount = reusableBuffer.moduleSetup.bt.devicesCount; + Window::checkEvents(); } void BluetoothTrainerWindow::refresh() diff --git a/radio/src/gui/colorlcd/view_main.cpp b/radio/src/gui/colorlcd/view_main.cpp index 69b9dee781d..18b7e21cb3f 100644 --- a/radio/src/gui/colorlcd/view_main.cpp +++ b/radio/src/gui/colorlcd/view_main.cpp @@ -379,3 +379,12 @@ void ViewMain::long_pressed(lv_event_t* e) lv_indev_wait_release(lv_indev_get_act()); } } + +void ViewMain::runBackground() +{ + topbar->runBackground(); + for (int i = 0; i < MAX_CUSTOM_SCREENS; i += 1) { + if (customScreens[i]) + customScreens[i]->runBackground(); + } +} diff --git a/radio/src/gui/colorlcd/view_main.h b/radio/src/gui/colorlcd/view_main.h index 42967f70947..9c73378fbd0 100644 --- a/radio/src/gui/colorlcd/view_main.h +++ b/radio/src/gui/colorlcd/view_main.h @@ -78,6 +78,8 @@ class ViewMain : public NavWindow void onClicked() override; void onCancel() override; + void runBackground(); + protected: static ViewMain* _instance; diff --git a/radio/src/gui/colorlcd/widgets/widgets_container_impl.h b/radio/src/gui/colorlcd/widgets/widgets_container_impl.h index 6b9afab1cf8..9925f16f5aa 100644 --- a/radio/src/gui/colorlcd/widgets/widgets_container_impl.h +++ b/radio/src/gui/colorlcd/widgets/widgets_container_impl.h @@ -145,6 +145,15 @@ class WidgetsContainerImpl : public WidgetsContainer void adjustLayout() override {} void updateFromTheme() override {}; + void runBackground() override + { + for (int i = 0; i < N; i++) { + if (widgets[i]) { + widgets[i]->background(); + } + } + } + protected: PersistentData* persistentData; Widget* widgets[N] = {}; diff --git a/radio/src/gui/colorlcd/widgets_container.h b/radio/src/gui/colorlcd/widgets_container.h index d9d7a02771b..cd84afef565 100644 --- a/radio/src/gui/colorlcd/widgets_container.h +++ b/radio/src/gui/colorlcd/widgets_container.h @@ -89,6 +89,7 @@ class WidgetsContainer: public Window virtual void adjustLayout() = 0; virtual void updateZones() = 0; virtual void updateFromTheme() = 0; + virtual void runBackground() = 0; virtual bool isLayout() { return false; } bool isWidgetsContainer() override { return true; }