From f9f4155499d008a772e05ee73c82ae6b540125ba Mon Sep 17 00:00:00 2001 From: 3djc Date: Tue, 6 Apr 2021 14:13:05 +0200 Subject: [PATCH] Fix layout mirror --- radio/src/gui/colorlcd/layouts/layout2+1.cpp | 9 +++------ radio/src/gui/colorlcd/layouts/layout2x1.cpp | 7 ++----- radio/src/gui/colorlcd/layouts/layout2x2.cpp | 5 +---- radio/src/gui/colorlcd/layouts/layout2x4.cpp | 6 ++---- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/radio/src/gui/colorlcd/layouts/layout2+1.cpp b/radio/src/gui/colorlcd/layouts/layout2+1.cpp index 449cc4d82..85a4a341c 100644 --- a/radio/src/gui/colorlcd/layouts/layout2+1.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2+1.cpp @@ -60,19 +60,16 @@ class Layout2P1: public Layout rect_t getZone(unsigned int index) const override { - if (isMirrored()) - index = 2 - 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}; + return {isMirrored() ? zone.x : zone.x + zone.w / 2, zone.y,zone.w / 2, zone.h}; } else if (index == 1) { - return {zone.x + zone.w / 2, zone.y,zone.w / 2, zone.h / 2}; + return {isMirrored() ? zone.x + zone.w / 2 : zone.x, zone.y,zone.w / 2, zone.h / 2}; } else { - return {zone.x + zone.w / 2, zone.y + zone.h / 2,zone.w / 2, zone.h / 2}; + return {isMirrored() ? zone.x + zone.w / 2 : zone.x, zone.y + zone.h / 2,zone.w / 2, zone.h / 2}; } return zone; diff --git a/radio/src/gui/colorlcd/layouts/layout2x1.cpp b/radio/src/gui/colorlcd/layouts/layout2x1.cpp index 71509cdf6..82887dbec 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x1.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x1.cpp @@ -60,16 +60,13 @@ class Layout2x1: public Layout rect_t getZone(unsigned int index) const override { - if (isMirrored()) - 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}; + return {isMirrored() ? zone.x + zone.w / 2 : zone.x, zone.y, zone.w / 2, zone.h}; } else { - return {zone.x + zone.w / 2, zone.y, zone.w / 2, zone.h}; + return {isMirrored() ? zone.x : 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 aba64d808..cbf2a1385 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x2.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x2.cpp @@ -60,9 +60,6 @@ class Layout2x2: public Layout rect_t getZone(unsigned int index) const override { - if (isMirrored()) - index = 3 - index; - rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border}); zone.w /= 2; @@ -71,7 +68,7 @@ class Layout2x2: public Layout if (index == 1 || index == 3) zone.y += zone.h; - if (index > 1) + if ((!isMirrored() && index > 1)) || (isMirrored() && index < 2) 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 fbf6a7a81..8cf6ceda5 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x4.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x4.cpp @@ -63,16 +63,14 @@ class Layout2x4: public Layout rect_t getZone(unsigned int index) const override { - if (isMirrored()) - 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) + if ((!isMirrored() && index > 3) || (isMirrored() && index < 4)) { zone.x += zone.w; + } zone.y += (index % 4) * zone.h;