Skip to content

Commit

Permalink
feat(color): run widget 'background' function while in setup pages (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz authored Mar 11, 2024
1 parent b271d9d commit a396eff
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/model_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class OutputLineButton : public ListLineButton

void checkEvents() override
{
Window::checkEvents();
ListLineButton::checkEvents();
if (!init) return;

int newValue = channelOutputs[index];
Expand Down
7 changes: 7 additions & 0 deletions radio/src/gui/colorlcd/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -94,3 +95,9 @@ void Page::onCancel()
}

void Page::onClicked() { Keyboard::hide(false); }

void Page::checkEvents()
{
ViewMain::instance()->runBackground();
NavWindow::checkEvents();
}
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Page : public NavWindow
PageHeader header;
FormWindow body;

void checkEvents() override;
bool bubbleEvents() override { return false; }
};

Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/radio_theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class ThemeEditPage : public Page
started = true;
_themeName->setText(_theme.getName());
}
Window::checkEvents();
Page::checkEvents();
}

void editColorPage()
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/tabsgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/trainer_bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ void BluetoothTrainerWindow::checkEvents()
refresh();
lastbtstate = bluetooth.state;
devcount = reusableBuffer.moduleSetup.bt.devicesCount;
Window::checkEvents();
}

void BluetoothTrainerWindow::refresh()
Expand Down
9 changes: 9 additions & 0 deletions radio/src/gui/colorlcd/view_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
2 changes: 2 additions & 0 deletions radio/src/gui/colorlcd/view_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class ViewMain : public NavWindow
void onClicked() override;
void onCancel() override;

void runBackground();

protected:
static ViewMain* _instance;

Expand Down
9 changes: 9 additions & 0 deletions radio/src/gui/colorlcd/widgets/widgets_container_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {};
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/widgets_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit a396eff

Please sign in to comment.