From a72f1491de5d7892aee7e29d07ebbfd4b9333728 Mon Sep 17 00:00:00 2001 From: 3djc Date: Tue, 6 Apr 2021 10:47:46 +0200 Subject: [PATCH] more layouts --- radio/src/gui/colorlcd/layouts/layout2x1.cpp | 19 +++--- radio/src/gui/colorlcd/layouts/layout2x2.cpp | 30 +++++---- radio/src/gui/colorlcd/layouts/layout2x4.cpp | 69 ++++++-------------- 3 files changed, 48 insertions(+), 70 deletions(-) diff --git a/radio/src/gui/colorlcd/layouts/layout2x1.cpp b/radio/src/gui/colorlcd/layouts/layout2x1.cpp index 2e9f1f875..1e1e078ad 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x1.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x1.cpp @@ -28,6 +28,8 @@ #define HAS_TRIMS() (persistentData->options[3].value.boolValue == true) #define IS_MIRRORED() (persistentData->options[4].value.boolValue == true) +constexpr coord_t border = 10; + const uint8_t LBM_LAYOUT_2x1[] = { #include "mask_layout2x1.lbm" }; @@ -64,17 +66,18 @@ class Layout2x1: public Layout rect_t getZone(unsigned int index) const override { - rect_t zone; - zone.w = (LCD_W-3*10) / 2; - zone.x = (index & 1) ? 20 + zone.w : 10; - if (persistentData->options[0].value.boolValue) { - zone.h = (LCD_H-MENU_HEADER_HEIGHT-2*10); - zone.y = MENU_HEADER_HEIGHT + 10; + if (IS_MIRRORED()) + index = 1 - index; + + rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border}); + + if (index == 0) { + return {zone.x, zone.y, zone.w / 2, zone.h}; } else { - zone.h = (LCD_H-2*10); - zone.y = 10; + return {zone.x + zone.w / 2, zone.y, zone.w / 2, zone.h}; } + return zone; } }; diff --git a/radio/src/gui/colorlcd/layouts/layout2x2.cpp b/radio/src/gui/colorlcd/layouts/layout2x2.cpp index 59c346c8e..5ee745a43 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x2.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x2.cpp @@ -28,6 +28,8 @@ #define HAS_TRIMS() (persistentData->options[3].value.boolValue == true) #define IS_MIRRORED() (persistentData->options[4].value.boolValue == true) +constexpr coord_t border = 10; + const uint8_t LBM_LAYOUT_2x2[] = { #include "mask_layout2x2.lbm" }; @@ -64,20 +66,20 @@ class Layout2x2: public Layout rect_t getZone(unsigned int index) const override { - rect_t zone; - zone.w = (LCD_W-3*10) / 2; - zone.x = (index & 1) ? 20 + zone.w : 10; - if (persistentData->options[0].value.boolValue) { - zone.h = (LCD_H-MENU_HEADER_HEIGHT-3*10) / 2; - zone.y = MENU_HEADER_HEIGHT + 10; - } - else { - zone.h = (LCD_H-3*10) / 2; - zone.y = 10; - } - if (index >= 2) { - zone.y += 10 + zone.h; - } + if (IS_MIRRORED()) + index = 3 - index; + + rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border}); + + zone.w /= 2; + zone.h /= 2; + + if (index == 1 || index == 3) + zone.y += zone.h; + + if (index > 1) + zone.x += zone.w; + return zone; } }; diff --git a/radio/src/gui/colorlcd/layouts/layout2x4.cpp b/radio/src/gui/colorlcd/layouts/layout2x4.cpp index 5a5d183ed..4e04bb9ca 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x4.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x4.cpp @@ -20,6 +20,14 @@ #include "opentx.h" +#define HAS_TOPBAR() (persistentData->options[0].value.boolValue == true) +#define HAS_FM() (persistentData->options[1].value.boolValue == true) +#define HAS_SLIDERS() (persistentData->options[2].value.boolValue == true) +#define HAS_TRIMS() (persistentData->options[3].value.boolValue == true) +#define IS_MIRRORED() (persistentData->options[4].value.boolValue == true) + +constexpr coord_t border = 10; + const uint8_t LBM_LAYOUT_2x4[] = { #include "mask_layout2x4.lbm" }; @@ -61,56 +69,21 @@ class Layout2x4: public Layout rect_t getZone(unsigned int index) const override { - rect_t zone; - zone.x = (index >= 4) ? 260 : 60; - zone.y = 56 + (index % 4) * 42; - zone.w = 160; - zone.h = 32; + if (IS_MIRRORED()) + index = 7 - index; + + rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border}); + + zone.w /= 2; + zone.h /= 4; + + if (index > 3) + zone.x += zone.w; + + zone.y += (index % 4) * zone.h; + return zone; } - -// virtual void refresh(); }; -//void Layout2x4::refresh() -//{ -// theme->drawBackground(); -// -// if (persistentData->options[0].value.boolValue) { -// drawTopBar(); -// } -// -// if (persistentData->options[1].value.boolValue) { -// // Flight mode -// lcdDrawSizedText(LCD_W / 2 - getTextWidth(g_model.flightModeData[mixerCurrentFlightMode].name, -// sizeof(g_model.flightModeData[mixerCurrentFlightMode].name), -// ZCHAR | FONT(XS)) / 2, -// 232, -// g_model.flightModeData[mixerCurrentFlightMode].name, -// sizeof(g_model.flightModeData[mixerCurrentFlightMode].name), ZCHAR | FONT(XS)); -// } -// -// if (persistentData->options[2].value.boolValue) { -// // Pots and rear sliders positions -// drawMainPots(); -// } -// -// if (persistentData->options[3].value.boolValue) { -// // Trims -// drawTrims(mixerCurrentFlightMode); -// } -// -// if (persistentData->options[4].value.boolValue) { -// lcdSetColor(persistentData->options[5].value.unsignedValue); -// lcdDrawSolidFilledRect(50, 50, 180, 170, CUSTOM_COLOR); -// } -// -// if (persistentData->options[6].value.boolValue) { -// lcdSetColor(persistentData->options[7].value.unsignedValue); -// lcdDrawSolidFilledRect(250, 50, 180, 170, CUSTOM_COLOR); -// } -// -// Layout::refresh(); -//} - BaseLayoutFactory layout2x4("Layout2x4", "2 x 4", LBM_LAYOUT_2x4, OPTIONS_LAYOUT_2x4);