From da83e6b210fd4c7b9243b96e7bb28638d048d456 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Mon, 5 Apr 2021 18:04:12 +0200 Subject: [PATCH] getMainZone() moved to Layout --- radio/src/gui/colorlcd/layout.cpp | 32 ++++++++++++++++++++ radio/src/gui/colorlcd/layout.h | 13 ++++++++ radio/src/gui/colorlcd/layouts/layout1x1.cpp | 27 ----------------- radio/src/thirdparty/libopenui | 2 +- 4 files changed, 46 insertions(+), 28 deletions(-) diff --git a/radio/src/gui/colorlcd/layout.cpp b/radio/src/gui/colorlcd/layout.cpp index 1480db327..a375689c5 100644 --- a/radio/src/gui/colorlcd/layout.cpp +++ b/radio/src/gui/colorlcd/layout.cpp @@ -245,3 +245,35 @@ void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode) ); } } + +rect_t Layout::getMainZone(rect_t zone) const +{ + bool hasTopbar = getOptionValue(OPTION_TOPBAR)->boolValue; + bool hasFM = getOptionValue(OPTION_FM)->boolValue; + bool hasSliders = getOptionValue(OPTION_SLIDERS)->boolValue; + bool hasTrims = getOptionValue(OPTION_TRIMS)->boolValue; + + if (hasTopbar) { + zone.y += MENU_HEADER_HEIGHT; + zone.h -= MENU_HEADER_HEIGHT; + } + + if (hasFM || hasTrims) { + zone.h -= TRIM_SQUARE_SIZE; + } + + if (hasSliders) { +#if NUM_SLIDERS + NUM_POTS > 2 + zone.h -= TRIM_SQUARE_SIZE; +#endif + zone.w -= 2 * TRIM_SQUARE_SIZE; + zone.x += TRIM_SQUARE_SIZE; + } + + if (hasTrims) { + zone.w -= 2 * TRIM_SQUARE_SIZE; + zone.x += TRIM_SQUARE_SIZE; + } + + return zone; +} diff --git a/radio/src/gui/colorlcd/layout.h b/radio/src/gui/colorlcd/layout.h index 1be0b623a..402468d48 100644 --- a/radio/src/gui/colorlcd/layout.h +++ b/radio/src/gui/colorlcd/layout.h @@ -37,6 +37,16 @@ class Layout: public WidgetsContainer friend class LayoutFactory; public: + + // Common 'ZoneOptionValue's among all layouts + enum { + OPTION_TOPBAR = 0, + OPTION_FM, + OPTION_SLIDERS, + OPTION_TRIMS, + OPTION_MIRRORED + }; + Layout(const LayoutFactory * factory, PersistentData * persistentData): WidgetsContainer({0, 0, LCD_W, LCD_H}, persistentData), factory(factory) @@ -55,6 +65,9 @@ class Layout: public WidgetsContainer TopBar * topBar = nullptr; uint8_t decorationSettings = 0; std::list decorations; + + // get the Zone rect without decoration + rect_t getMainZone(rect_t zone) const; }; void registerLayout(const LayoutFactory * factory); diff --git a/radio/src/gui/colorlcd/layouts/layout1x1.cpp b/radio/src/gui/colorlcd/layouts/layout1x1.cpp index efa3372d8..74ebf1c82 100644 --- a/radio/src/gui/colorlcd/layouts/layout1x1.cpp +++ b/radio/src/gui/colorlcd/layouts/layout1x1.cpp @@ -74,33 +74,6 @@ class Layout1x1: public Layout return 1; } - rect_t getMainZone(rect_t zone) const - { - if (HAS_TOPBAR()) { - zone.y += MENU_HEADER_HEIGHT; - zone.h -= MENU_HEADER_HEIGHT; - } - - if (HAS_FM() || HAS_TRIMS()) { - zone.h -= TRIM_SQUARE_SIZE; - } - - if (HAS_SLIDERS()) { -#if NUM_SLIDERS + NUM_POTS > 2 - zone.h -= TRIM_SQUARE_SIZE; -#endif - zone.w -= 2 * TRIM_SQUARE_SIZE; - zone.x += TRIM_SQUARE_SIZE; - } - - if (HAS_TRIMS()) { - zone.w -= 2 * TRIM_SQUARE_SIZE; - zone.x += TRIM_SQUARE_SIZE; - } - - return zone; - } - rect_t getZone(unsigned int index) const override { rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border}); diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index a106ff4ff..2d57320ce 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit a106ff4ff7b0437fbd9b43c24546df93049f3e57 +Subproject commit 2d57320ce37e1e749357baa278300db776132d41