diff --git a/radio/src/gui/colorlcd/layouts/layout2x4.cpp b/radio/src/gui/colorlcd/layouts/layout2x4.cpp index 183af767c..56752739a 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x4.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x4.cpp @@ -64,7 +64,7 @@ class Layout2x4 : public Layout void setPanels() { - rect_t zone = Layout::getMainZone(); + rect_t zone = Layout::getWidgetsZone(); if (mainZone.x != zone.x || mainZone.y != zone.y || mainZone.w != zone.w || mainZone.h != zone.h) { mainZone = zone; diff --git a/radio/src/gui/colorlcd/layouts/layout6x1.cpp b/radio/src/gui/colorlcd/layouts/layout6x1.cpp index 59e2479a0..91101ccae 100644 --- a/radio/src/gui/colorlcd/layouts/layout6x1.cpp +++ b/radio/src/gui/colorlcd/layouts/layout6x1.cpp @@ -57,7 +57,7 @@ class Layout6x1 : public Layout void setPanel() { - rect_t zone = Layout::getMainZone(); + rect_t zone = Layout::getWidgetsZone(); if (mainZone.x != zone.x || mainZone.y != zone.y || mainZone.w != zone.w || mainZone.h != zone.h) { mainZone = zone; diff --git a/radio/src/gui/colorlcd/mainview/layout.cpp b/radio/src/gui/colorlcd/mainview/layout.cpp index 8641ea4c3..83e9ff9cc 100644 --- a/radio/src/gui/colorlcd/mainview/layout.cpp +++ b/radio/src/gui/colorlcd/mainview/layout.cpp @@ -335,26 +335,25 @@ void Layout::show(bool visible) } } -rect_t Layout::getMainZone() const +bool Layout::hasFullScreenWidget() const { - rect_t zone = decoration->getMainZone(); - if (hasSliders() || hasTrims() || hasFlightMode()) { - // some decoration activated - zone.x += PAD_LARGE; - zone.y += PAD_LARGE; - zone.w -= 2 * PAD_LARGE; - zone.h -= 2 * PAD_LARGE; - } - if (hasTopbar()) { - zone.y += EdgeTxStyles::MENU_HEADER_HEIGHT; - zone.h -= EdgeTxStyles::MENU_HEADER_HEIGHT; - } - return zone; + for (int i = 0; i < zoneCount; i += 1) + if (widgets[i] && widgets[i]->isFullscreen()) + return true; + return false; +} + +rect_t Layout::getWidgetsZone() const +{ + if (hasFullScreenWidget()) + return {0, 0, LCD_W, LCD_H}; + + return decoration->getWidgetsZone(hasTopbar()); } rect_t Layout::getZone(unsigned int index) const { - rect_t z = getMainZone(); + rect_t z = getWidgetsZone(); unsigned int i = index * 4; @@ -371,13 +370,11 @@ rect_t Layout::getZone(unsigned int index) const void Layout::checkEvents() { Window::checkEvents(); - rect_t z = getMainZone(); + rect_t z = getWidgetsZone(); if (z.x != lastMainZone.x || z.y != lastMainZone.y || z.w != lastMainZone.w || z.h != lastMainZone.h) { lastMainZone = z; - for (int i = 0; i < zoneCount; i++) - if (widgets[i] && widgets[i]->isFullscreen()) - return; - updateZones(); + if (!hasFullScreenWidget()) + updateZones(); } } diff --git a/radio/src/gui/colorlcd/mainview/layout.h b/radio/src/gui/colorlcd/mainview/layout.h index f14b85ecf..7c4b9a247 100644 --- a/radio/src/gui/colorlcd/mainview/layout.h +++ b/radio/src/gui/colorlcd/mainview/layout.h @@ -121,6 +121,8 @@ class Layout: public WidgetsContainer void removeWidget(unsigned int index) override; + bool hasFullScreenWidget() const; + protected: const LayoutFactory* factory = nullptr; ViewMainDecoration* decoration = nullptr; @@ -134,7 +136,7 @@ class Layout: public WidgetsContainer uint32_t lastRefresh = 0; // Get the available space for widgets - rect_t getMainZone() const; + rect_t getWidgetsZone() const; unsigned int getZonesCount() const override { return zoneCount; } rect_t getZone(unsigned int index) const override; diff --git a/radio/src/gui/colorlcd/mainview/view_main_decoration.cpp b/radio/src/gui/colorlcd/mainview/view_main_decoration.cpp index 3bbcee6f6..54be5dfa4 100644 --- a/radio/src/gui/colorlcd/mainview/view_main_decoration.cpp +++ b/radio/src/gui/colorlcd/mainview/view_main_decoration.cpp @@ -108,17 +108,22 @@ static bool canTrimShow(int idx) return false; } -rect_t ViewMainDecoration::getMainZone() const +rect_t ViewMainDecoration::getWidgetsZone(bool showTopBar) const { - coord_t x = 0, w = width(), h = height(); + coord_t x = 0, y = 0, w = width(), h = height(); coord_t bh = 0; + if (showTopBar) { + y = EdgeTxStyles::MENU_HEADER_HEIGHT; + bh = EdgeTxStyles::MENU_HEADER_HEIGHT; + } + if (showSliders) { if (hasVerticalSliders) { x += MainViewSlider::SLIDER_BAR_SIZE; w -= 2 * MainViewSlider::SLIDER_BAR_SIZE; } - bh = MainViewSlider::SLIDER_BAR_SIZE; + bh += MainViewSlider::SLIDER_BAR_SIZE; } if (showTrims) { @@ -139,9 +144,16 @@ rect_t ViewMainDecoration::getMainZone() const bh -= MainViewSlider::SLIDER_BAR_SIZE; } + if (showSliders || showTrims || showFM) { + x += PAD_LARGE; + y += PAD_LARGE; + w -= PAD_LARGE * 2; + bh += PAD_LARGE * 2; + } + h -= bh; - return rect_t{x, 0, w, h}; + return rect_t{x, y, w, h}; } void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Window* bc, Window* br) diff --git a/radio/src/gui/colorlcd/mainview/view_main_decoration.h b/radio/src/gui/colorlcd/mainview/view_main_decoration.h index 4421f4269..03f0e9ffb 100644 --- a/radio/src/gui/colorlcd/mainview/view_main_decoration.h +++ b/radio/src/gui/colorlcd/mainview/view_main_decoration.h @@ -37,7 +37,7 @@ class ViewMainDecoration : public Window // Get the available space in the middle of the screen // (without decoration) - rect_t getMainZone() const; + rect_t getWidgetsZone(bool showTopBar) const; protected: enum { diff --git a/radio/src/gui/colorlcd/mainview/widget.cpp b/radio/src/gui/colorlcd/mainview/widget.cpp index bccb98295..a3c257cc8 100644 --- a/radio/src/gui/colorlcd/mainview/widget.cpp +++ b/radio/src/gui/colorlcd/mainview/widget.cpp @@ -212,8 +212,8 @@ void Widget::setFullscreen(bool enable) fullscreen = enable; // Show or hide ViewMain widgets and decorations - Messaging::send(Messaging::DECORATION_UPDATE); ViewMain::instance()->show(!enable); + Messaging::send(Messaging::DECORATION_UPDATE); // Leave Fullscreen Mode if (!enable) { diff --git a/radio/src/gui/colorlcd/widgets/gauge.cpp b/radio/src/gui/colorlcd/widgets/gauge.cpp index b0b1b11b2..1737cd54e 100644 --- a/radio/src/gui/colorlcd/widgets/gauge.cpp +++ b/radio/src/gui/colorlcd/widgets/gauge.cpp @@ -82,7 +82,7 @@ class GaugeWidget : public Widget void update() override { - if (!loaded) return; + if (!loaded || _deleted) return; auto widgetData = getPersistentData(); @@ -107,7 +107,7 @@ class GaugeWidget : public Widget void foreground() override { - if (!loaded) return; + if (!loaded || _deleted) return; auto newValue = getGuageValue(); if (lastValue != newValue) { diff --git a/radio/src/gui/colorlcd/widgets/modelbmp.cpp b/radio/src/gui/colorlcd/widgets/modelbmp.cpp index e5d81a992..d85918d2c 100644 --- a/radio/src/gui/colorlcd/widgets/modelbmp.cpp +++ b/radio/src/gui/colorlcd/widgets/modelbmp.cpp @@ -55,7 +55,7 @@ class ModelBitmapWidget : public Widget void foreground() override { - if (!loaded) return; + if (!loaded || _deleted) return; if (getHash() != deps_hash) { update(); @@ -68,7 +68,7 @@ class ModelBitmapWidget : public Widget void update() override { - if (!loaded) return; + if (!loaded || _deleted) return; auto widgetData = getPersistentData(); diff --git a/radio/src/gui/colorlcd/widgets/outputs.cpp b/radio/src/gui/colorlcd/widgets/outputs.cpp index 6b8998fdf..98627c080 100644 --- a/radio/src/gui/colorlcd/widgets/outputs.cpp +++ b/radio/src/gui/colorlcd/widgets/outputs.cpp @@ -99,7 +99,7 @@ class ChannelValue : public Window void refresh() { - if (!loaded) return; + if (!loaded || _deleted) return; int16_t value = channelOutputs[channel]; diff --git a/radio/src/gui/colorlcd/widgets/radio_info.cpp b/radio/src/gui/colorlcd/widgets/radio_info.cpp index 0ac951177..30a094911 100644 --- a/radio/src/gui/colorlcd/widgets/radio_info.cpp +++ b/radio/src/gui/colorlcd/widgets/radio_info.cpp @@ -104,6 +104,8 @@ class RadioInfoWidget : public Widget void update() override { + if (_deleted) return; + auto widgetData = getPersistentData(); // get colors from options @@ -114,6 +116,8 @@ class RadioInfoWidget : public Widget void foreground() override { + if (_deleted) return; + usbIcon->show(usbPlugged()); if (getSelectedUsbMode() == USB_UNSELECTED_MODE) usbIcon->setColor(COLOR_THEME_PRIMARY3_INDEX); @@ -243,11 +247,15 @@ class DateTimeWidget : public Widget void foreground() override { + if (_deleted) return; + Widget::checkEvents(); } void update() override { + if (_deleted) return; + auto widgetData = getPersistentData(); // get color from options @@ -295,6 +303,8 @@ class InternalGPSWidget : public Widget void foreground() override { + if (_deleted) return; + bool hasGPS = serialGetModePort(UART_MODE_GPS) >= 0; numSats->show(hasGPS && (gpsData.numSat > 0)); diff --git a/radio/src/gui/colorlcd/widgets/text.cpp b/radio/src/gui/colorlcd/widgets/text.cpp index 894dd0573..4d486f59f 100644 --- a/radio/src/gui/colorlcd/widgets/text.cpp +++ b/radio/src/gui/colorlcd/widgets/text.cpp @@ -60,7 +60,7 @@ class TextWidget : public Widget void update() override { - if (!loaded) return; + if (!loaded || _deleted) return; auto widgetData = getPersistentData(); diff --git a/radio/src/gui/colorlcd/widgets/timer.cpp b/radio/src/gui/colorlcd/widgets/timer.cpp index f3a95cc4f..55c1bb512 100644 --- a/radio/src/gui/colorlcd/widgets/timer.cpp +++ b/radio/src/gui/colorlcd/widgets/timer.cpp @@ -107,7 +107,7 @@ class TimerWidget : public Widget void foreground() override { - if (!loaded) return; + if (!loaded || _deleted) return; auto widgetData = getPersistentData(); @@ -236,7 +236,7 @@ class TimerWidget : public Widget void update() override { - if (!loaded) return; + if (!loaded || _deleted) return; auto widgetData = getPersistentData(); diff --git a/radio/src/gui/colorlcd/widgets/value.cpp b/radio/src/gui/colorlcd/widgets/value.cpp index 7a6e2e535..c2abec9aa 100644 --- a/radio/src/gui/colorlcd/widgets/value.cpp +++ b/radio/src/gui/colorlcd/widgets/value.cpp @@ -76,7 +76,7 @@ class ValueWidget : public Widget void foreground() override { - if (!loaded) return; + if (!loaded || _deleted) return; bool changed = false; @@ -186,7 +186,7 @@ class ValueWidget : public Widget void update() override { - if (!loaded) return; + if (!loaded || _deleted) return; auto widgetData = getPersistentData();