feat(color): run widget 'background' function while in setup pages (#4393)

This commit is contained in:
philmoz
2024-03-11 11:56:46 +10:00
committed by GitHub
parent b271d9d5e3
commit a396eff73e
10 changed files with 33 additions and 2 deletions
+1 -1
View File
@@ -232,7 +232,7 @@ class OutputLineButton : public ListLineButton
void checkEvents() override void checkEvents() override
{ {
Window::checkEvents(); ListLineButton::checkEvents();
if (!init) return; if (!init) return;
int newValue = channelOutputs[index]; int newValue = channelOutputs[index];
+7
View File
@@ -24,6 +24,7 @@
#include "keyboard_base.h" #include "keyboard_base.h"
#include "opentx.h" #include "opentx.h"
#include "theme.h" #include "theme.h"
#include "view_main.h"
PageHeader::PageHeader(Page * parent, uint8_t icon): PageHeader::PageHeader(Page * parent, uint8_t icon):
FormWindow(parent, { 0, 0, LCD_W, MENU_HEADER_HEIGHT }, OPAQUE), 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::onClicked() { Keyboard::hide(false); }
void Page::checkEvents()
{
ViewMain::instance()->runBackground();
NavWindow::checkEvents();
}
+1
View File
@@ -63,6 +63,7 @@ class Page : public NavWindow
PageHeader header; PageHeader header;
FormWindow body; FormWindow body;
void checkEvents() override;
bool bubbleEvents() override { return false; } bool bubbleEvents() override { return false; }
}; };
+1 -1
View File
@@ -401,7 +401,7 @@ class ThemeEditPage : public Page
started = true; started = true;
_themeName->setText(_theme.getName()); _themeName->setText(_theme.getName());
} }
Window::checkEvents(); Page::checkEvents();
} }
void editColorPage() void editColorPage()
+1
View File
@@ -255,6 +255,7 @@ void TabsGroup::checkEvents()
if (currentTab) { if (currentTab) {
currentTab->checkEvents(); currentTab->checkEvents();
} }
ViewMain::instance()->runBackground();
static uint32_t lastRefresh = 0; static uint32_t lastRefresh = 0;
uint32_t now = RTOS_GET_MS(); uint32_t now = RTOS_GET_MS();
@@ -116,6 +116,7 @@ void BluetoothTrainerWindow::checkEvents()
refresh(); refresh();
lastbtstate = bluetooth.state; lastbtstate = bluetooth.state;
devcount = reusableBuffer.moduleSetup.bt.devicesCount; devcount = reusableBuffer.moduleSetup.bt.devicesCount;
Window::checkEvents();
} }
void BluetoothTrainerWindow::refresh() void BluetoothTrainerWindow::refresh()
+9
View File
@@ -379,3 +379,12 @@ void ViewMain::long_pressed(lv_event_t* e)
lv_indev_wait_release(lv_indev_get_act()); 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();
}
}
+2
View File
@@ -78,6 +78,8 @@ class ViewMain : public NavWindow
void onClicked() override; void onClicked() override;
void onCancel() override; void onCancel() override;
void runBackground();
protected: protected:
static ViewMain* _instance; static ViewMain* _instance;
@@ -145,6 +145,15 @@ class WidgetsContainerImpl : public WidgetsContainer
void adjustLayout() override {} void adjustLayout() override {}
void updateFromTheme() override {}; void updateFromTheme() override {};
void runBackground() override
{
for (int i = 0; i < N; i++) {
if (widgets[i]) {
widgets[i]->background();
}
}
}
protected: protected:
PersistentData* persistentData; PersistentData* persistentData;
Widget* widgets[N] = {}; Widget* widgets[N] = {};
@@ -89,6 +89,7 @@ class WidgetsContainer: public Window
virtual void adjustLayout() = 0; virtual void adjustLayout() = 0;
virtual void updateZones() = 0; virtual void updateZones() = 0;
virtual void updateFromTheme() = 0; virtual void updateFromTheme() = 0;
virtual void runBackground() = 0;
virtual bool isLayout() { return false; } virtual bool isLayout() { return false; }
bool isWidgetsContainer() override { return true; } bool isWidgetsContainer() override { return true; }