diff --git a/companion/src/companion.qrc b/companion/src/companion.qrc
index 33b315545..65757d6e0 100644
--- a/companion/src/companion.qrc
+++ b/companion/src/companion.qrc
@@ -1275,18 +1275,18 @@
themes/yerico/48/sdsync.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout1+2.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout1+3.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout1x1.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout1x2.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout1x3.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout1x4.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout2+1.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout2+3.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout2x1.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout2x2.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout2x3.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout2x4.png
- ../../radio/src/gui/colorlcd/layouts/mask_layout4+2.png
+ images/layouts/mask_layout1+2.png
+ images/layouts/mask_layout1+3.png
+ images/layouts/mask_layout1x1.png
+ images/layouts/mask_layout1x2.png
+ images/layouts/mask_layout1x3.png
+ images/layouts/mask_layout1x4.png
+ images/layouts/mask_layout2+1.png
+ images/layouts/mask_layout2+3.png
+ images/layouts/mask_layout2x1.png
+ images/layouts/mask_layout2x2.png
+ images/layouts/mask_layout2x3.png
+ images/layouts/mask_layout2x4.png
+ images/layouts/mask_layout4+2.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout1+2.png b/companion/src/images/layouts/mask_layout1+2.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout1+2.png
rename to companion/src/images/layouts/mask_layout1+2.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout1+3.png b/companion/src/images/layouts/mask_layout1+3.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout1+3.png
rename to companion/src/images/layouts/mask_layout1+3.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout1x1.png b/companion/src/images/layouts/mask_layout1x1.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout1x1.png
rename to companion/src/images/layouts/mask_layout1x1.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout1x2.png b/companion/src/images/layouts/mask_layout1x2.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout1x2.png
rename to companion/src/images/layouts/mask_layout1x2.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout1x3.png b/companion/src/images/layouts/mask_layout1x3.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout1x3.png
rename to companion/src/images/layouts/mask_layout1x3.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout1x4.png b/companion/src/images/layouts/mask_layout1x4.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout1x4.png
rename to companion/src/images/layouts/mask_layout1x4.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout2+1.png b/companion/src/images/layouts/mask_layout2+1.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout2+1.png
rename to companion/src/images/layouts/mask_layout2+1.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout2+3.png b/companion/src/images/layouts/mask_layout2+3.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout2+3.png
rename to companion/src/images/layouts/mask_layout2+3.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout2x1.png b/companion/src/images/layouts/mask_layout2x1.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout2x1.png
rename to companion/src/images/layouts/mask_layout2x1.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout2x2.png b/companion/src/images/layouts/mask_layout2x2.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout2x2.png
rename to companion/src/images/layouts/mask_layout2x2.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout2x3.png b/companion/src/images/layouts/mask_layout2x3.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout2x3.png
rename to companion/src/images/layouts/mask_layout2x3.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout2x4.png b/companion/src/images/layouts/mask_layout2x4.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout2x4.png
rename to companion/src/images/layouts/mask_layout2x4.png
diff --git a/radio/src/gui/colorlcd/layouts/mask_layout4+2.png b/companion/src/images/layouts/mask_layout4+2.png
similarity index 100%
rename from radio/src/gui/colorlcd/layouts/mask_layout4+2.png
rename to companion/src/images/layouts/mask_layout4+2.png
diff --git a/radio/src/bitmaps/480x272/CMakeLists.txt b/radio/src/bitmaps/480x272/CMakeLists.txt
index 8a5a64052..a9cc0fcd1 100644
--- a/radio/src/bitmaps/480x272/CMakeLists.txt
+++ b/radio/src/bitmaps/480x272/CMakeLists.txt
@@ -20,7 +20,6 @@ add_bitmaps_target(${BITMAP_TARGET_PREFIX}_splash "${RADIO_SRC_DIR}/bitmaps/480x
add_bitmaps_target(${BITMAP_TARGET_PREFIX}_button_bitmaps "${RADIO_SRC_DIR}/bitmaps/480x272/button/alpha_*.png" "4/4/4/4" "${BITMAP_LZ4_ARGS}")
add_bitmaps_target(${BITMAP_TARGET_PREFIX}_masks "${RADIO_SRC_DIR}/bitmaps/480x272/mask_*.png" 8bits "${MASK_LZ4_ARGS}")
add_bitmaps_target(${BITMAP_TARGET_PREFIX}_slider_masks "${RADIO_SRC_DIR}/bitmaps/480x272/slider/*.png" 8bits "${MASK_LZ4_ARGS}")
-add_bitmaps_target(${BITMAP_TARGET_PREFIX}_layouts_masks "${RADIO_SRC_DIR}/gui/colorlcd/layouts/*.png" 8bits "${MASK_LZ4_ARGS}")
add_bitmaps_target(${BITMAP_TARGET_PREFIX}_volume_masks ${RADIO_SRC_DIR}/bitmaps/480x272/volume/*.png 8bits "${MASK_LZ4_ARGS}")
add_bitmaps_target(${BITMAP_TARGET_PREFIX}_themes_masks "${RADIO_SRC_DIR}/bitmaps/480x272/default_theme/mask_*.png" 8bits "${MASK_LZ4_ARGS}")
add_bitmaps_target(${BITMAP_TARGET_PREFIX}_themes_alpha "${RADIO_SRC_DIR}/bitmaps/480x272/default_theme/alpha_*.png" "4/4/4/4" "${BITMAP_LZ4_ARGS}")
@@ -35,7 +34,6 @@ add_dependencies(${BITMAP_TARGET_PREFIX}_bitmaps
${BITMAP_TARGET_PREFIX}_button_bitmaps
${BITMAP_TARGET_PREFIX}_masks
${BITMAP_TARGET_PREFIX}_slider_masks
- ${BITMAP_TARGET_PREFIX}_layouts_masks
${BITMAP_TARGET_PREFIX}_themes_masks
${BITMAP_TARGET_PREFIX}_themes_alpha
${BITMAP_TARGET_PREFIX}_volume_masks
diff --git a/radio/src/gui/colorlcd/layouts/layout1+2.cpp b/radio/src/gui/colorlcd/layouts/layout1+2.cpp
index 35aac5f5a..1241b7410 100644
--- a/radio/src/gui/colorlcd/layouts/layout1+2.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout1+2.cpp
@@ -21,42 +21,13 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_1P2[] = {
-#include "mask_layout1+2.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_1P2);
-
-const ZoneOption OPTIONS_LAYOUT_1P2[] = {LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END};
-
-class Layout1P2 : public Layout
-{
- public:
- Layout1P2(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 3; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- if (index == 0) {
- return {zone.x, zone.y, zone.w, zone.h / 2};
- } else if (index == 1) {
- return {zone.x, zone.y + zone.h / 2, zone.w, zone.h / 4};
- } else {
- return {zone.x, zone.y + zone.h * 3 / 4, zone.w, zone.h / 4};
- }
-
- return zone;
- }
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_FULL, LAYOUT_MAP_HALF,
+ LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_FULL, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_3QTR, LAYOUT_MAP_FULL, LAYOUT_MAP_1QTR,
};
-BaseLayoutFactory Layout1P2("Layout1P2", "1 + 2", LBM_LAYOUT_1P2,
- OPTIONS_LAYOUT_1P2);
+BaseLayoutFactory Layout1P2("Layout1P2", "1 + 2",
+ defaultZoneOptions,
+ 3, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout1+3.cpp b/radio/src/gui/colorlcd/layouts/layout1+3.cpp
index bd761ec1d..9e17996a0 100644
--- a/radio/src/gui/colorlcd/layouts/layout1+3.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout1+3.cpp
@@ -21,51 +21,14 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_1P3[] = {
-#include "mask_layout1+3.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_1P3);
-
-const ZoneOption OPTIONS_LAYOUT_1P3[] = {
- LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_FULL,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_2THIRD, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
};
-class Layout1P3 : public Layout
-{
- public:
- Layout1P3(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 4; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- zone.w /= 2;
-
- if (index == 0) {
- if (isMirrored()) {
- zone.x += zone.w;
- }
- } else {
- index--;
- zone.h /= 3;
- zone.y += zone.h * (int)index;
- if (!isMirrored()) {
- zone.x += zone.w;
- }
- }
-
- return zone;
- }
-};
-
-BaseLayoutFactory Layout1P3("Layout1P3", "1 + 3", LBM_LAYOUT_1P3,
- OPTIONS_LAYOUT_1P3);
+BaseLayoutFactory Layout1P3("Layout1P3", "1 + 3",
+ defaultZoneOptions,
+ 4, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout1x1.cpp b/radio/src/gui/colorlcd/layouts/layout1x1.cpp
index 0e74ba800..4413fb45e 100644
--- a/radio/src/gui/colorlcd/layouts/layout1x1.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout1x1.cpp
@@ -21,29 +21,11 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_1x1[] = {
-#include "mask_layout1x1.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_1x1);
-
-const ZoneOption OPTIONS_LAYOUT_1x1[] = {LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END};
-
-class Layout1x1 : public Layout
-{
- public:
- Layout1x1(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 1; }
-
- rect_t getZone(unsigned int index) const override { return getMainZone(); }
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_FULL, LAYOUT_MAP_FULL,
};
-BaseLayoutFactory layout1x1("Layout1x1", STR_WIDGET_FULLSCREEN,
- LBM_LAYOUT_1x1, OPTIONS_LAYOUT_1x1);
+BaseLayoutFactory layout1x1("Layout1x1", STR_WIDGET_FULLSCREEN,
+ defaultZoneOptions,
+ 1, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout1x2.cpp b/radio/src/gui/colorlcd/layouts/layout1x2.cpp
index f3278d203..783587471 100644
--- a/radio/src/gui/colorlcd/layouts/layout1x2.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout1x2.cpp
@@ -21,37 +21,12 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_1x2[] = {
-#include "mask_layout1x2.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_1x2);
-
-const ZoneOption OPTIONS_LAYOUT_1x2[] = {LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END};
-
-class Layout1x2 : public Layout
-{
- public:
- Layout1x2(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 2; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- zone.h /= 2;
- zone.y += zone.h * index;
-
- return zone;
- }
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_FULL, LAYOUT_MAP_HALF,
+ LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_FULL, LAYOUT_MAP_HALF,
};
-BaseLayoutFactory Layout1x2("Layout1x2", "1 x 2", LBM_LAYOUT_1x2,
- OPTIONS_LAYOUT_1x2);
+BaseLayoutFactory Layout1x2("Layout1x2", "1 x 2",
+ defaultZoneOptions,
+ 2, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout1x3.cpp b/radio/src/gui/colorlcd/layouts/layout1x3.cpp
index 0b0edef25..817199aa2 100644
--- a/radio/src/gui/colorlcd/layouts/layout1x3.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout1x3.cpp
@@ -21,37 +21,13 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_1x3[] = {
-#include "mask_layout1x3.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_1x3);
-
-const ZoneOption OPTIONS_LAYOUT_1x3[] = {LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END};
-
-class Layout1x3 : public Layout
-{
- public:
- Layout1x3(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 3; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- zone.h /= 3;
- zone.y += zone.h * index;
-
- return zone;
- }
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_FULL, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_0, LAYOUT_MAP_1THIRD, LAYOUT_MAP_FULL, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_0, LAYOUT_MAP_2THIRD, LAYOUT_MAP_FULL, LAYOUT_MAP_1THIRD,
};
-BaseLayoutFactory Layout1x3("Layout1x3", "1 x 3", LBM_LAYOUT_1x3,
- OPTIONS_LAYOUT_1x3);
+BaseLayoutFactory Layout1x3("Layout1x3", "1 x 3",
+ defaultZoneOptions,
+ 3, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout1x4.cpp b/radio/src/gui/colorlcd/layouts/layout1x4.cpp
index 40e3a72ad..35048d122 100644
--- a/radio/src/gui/colorlcd/layouts/layout1x4.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout1x4.cpp
@@ -21,41 +21,14 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_1x4[] = {
-#include "mask_layout1x4.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_1x4);
-
-const ZoneOption OPTIONS_LAYOUT_1x4[] = {
- LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_FULL, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_1QTR, LAYOUT_MAP_FULL, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_FULL, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_3QTR, LAYOUT_MAP_FULL, LAYOUT_MAP_1QTR,
};
-class Layout1x4 : public Layout
-{
- public:
- Layout1x4(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 4; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- if (index > 3) {
- index = 3;
- }
- return {zone.x, zone.y + zone.h / 4 * (int)index, zone.w, zone.h / 4};
-
- return zone;
- }
-};
-
-BaseLayoutFactory Layout1x4("Layout1x4", "1 x 4", LBM_LAYOUT_1x4,
- OPTIONS_LAYOUT_1x4);
+BaseLayoutFactory Layout1x4("Layout1x4", "1 x 4",
+ defaultZoneOptions,
+ 4, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout2+1.cpp b/radio/src/gui/colorlcd/layouts/layout2+1.cpp
index 4dc363507..aa3ae01c6 100644
--- a/radio/src/gui/colorlcd/layouts/layout2+1.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout2+1.cpp
@@ -21,48 +21,15 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_2P1[] = {
-#include "mask_layout2+1.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_2P1);
-
-const ZoneOption OPTIONS_LAYOUT_2P1[] = {
- LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END
+static uint8_t zmap[] = {
+ LAYOUT_MAP_HALF, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_FULL, // ordered to match previous implementation
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
+ LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
};
-class Layout2P1 : public Layout
-{
- public:
- Layout2P1(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
+BaseLayoutFactory layout2P1("Layout2P1", "2 + 1",
+ defaultZoneOptions,
+ 3, zmap);
- unsigned int getZonesCount() const override { return 3; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- if (index == 0) {
- return {isMirrored() ? zone.x : zone.x + zone.w / 2, zone.y, zone.w / 2,
- zone.h};
- } else if (index == 1) {
- return {isMirrored() ? zone.x + zone.w / 2 : zone.x, zone.y, zone.w / 2,
- zone.h / 2};
- } else {
- return {isMirrored() ? zone.x + zone.w / 2 : zone.x, zone.y + zone.h / 2,
- zone.w / 2, zone.h / 2};
- }
-
- return zone;
- }
-};
-
-BaseLayoutFactory layout2P1("Layout2P1", "2 + 1", LBM_LAYOUT_2P1,
- OPTIONS_LAYOUT_2P1);
const LayoutFactory* defaultLayout = &layout2P1;
diff --git a/radio/src/gui/colorlcd/layouts/layout2+3.cpp b/radio/src/gui/colorlcd/layouts/layout2+3.cpp
index df7c93dde..0ac65af64 100644
--- a/radio/src/gui/colorlcd/layouts/layout2+3.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout2+3.cpp
@@ -21,53 +21,15 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_2P3[] = {
-#include "mask_layout2+3.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_2P3);
-
-const ZoneOption OPTIONS_LAYOUT_2P3[] = {
- LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
+ LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_2THIRD, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
};
-class Layout2P3 : public Layout
-{
- public:
- Layout2P3(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 5; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- zone.w /= 2;
-
- if (index == 0 || index == 1) {
- zone.h /= 2;
- if (index == 1) zone.y += zone.h;
- if (isMirrored()) {
- zone.x += zone.w;
- }
- } else {
- index -= 2;
- zone.h /= 3;
- zone.y += zone.h * (int)index;
- if (!isMirrored()) {
- zone.x += zone.w;
- }
- }
-
- return zone;
- }
-};
-
-BaseLayoutFactory Layout2P3("Layout2P3", "2 + 3", LBM_LAYOUT_2P3,
- OPTIONS_LAYOUT_2P3);
+BaseLayoutFactory Layout2P3("Layout2P3", "2 + 3",
+ defaultZoneOptions,
+ 5, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout2x1.cpp b/radio/src/gui/colorlcd/layouts/layout2x1.cpp
index 61635ce0e..47b17bdb9 100644
--- a/radio/src/gui/colorlcd/layouts/layout2x1.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout2x1.cpp
@@ -21,44 +21,12 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_2x1[] = {
-#include "mask_layout2x1.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_2x1);
-
-const ZoneOption OPTIONS_LAYOUT_2x1[] = {
- LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_FULL,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_FULL,
};
-class Layout2x1 : public Layout
-{
- public:
- Layout2x1(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 2; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- if (index == 0) {
- return {isMirrored() ? zone.x + zone.w / 2 : zone.x, zone.y, zone.w / 2,
- zone.h};
- } else {
- return {isMirrored() ? zone.x : zone.x + zone.w / 2, zone.y, zone.w / 2,
- zone.h};
- }
-
- return zone;
- }
-};
-
-BaseLayoutFactory Layout2x1("Layout2x1", "2 x 1", LBM_LAYOUT_2x1,
- OPTIONS_LAYOUT_2x1);
+BaseLayoutFactory Layout2x1("Layout2x1", "2 x 1",
+ defaultZoneOptions,
+ 2, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout2x2.cpp b/radio/src/gui/colorlcd/layouts/layout2x2.cpp
index e1abb57e2..42b5a0cbe 100644
--- a/radio/src/gui/colorlcd/layouts/layout2x2.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout2x2.cpp
@@ -21,44 +21,14 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_2x2[] = {
-#include "mask_layout2x2.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_2x2);
-
-const ZoneOption OPTIONS_LAYOUT_2x2[] = {
- LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
+ LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
};
-class Layout2x2 : public Layout
-{
- public:
- Layout2x2(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 4; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- zone.w /= 2;
- zone.h /= 2;
-
- if (index == 1 || index == 3) zone.y += zone.h;
-
- if ((!isMirrored() && index > 1) || (isMirrored() && index < 2))
- zone.x += zone.w;
-
- return zone;
- }
-};
-
-BaseLayoutFactory layout2x2("Layout2x2", "2 x 2", LBM_LAYOUT_2x2,
- OPTIONS_LAYOUT_2x2);
+BaseLayoutFactory layout2x2("Layout2x2", "2 x 2",
+ defaultZoneOptions,
+ 4, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout2x3.cpp b/radio/src/gui/colorlcd/layouts/layout2x3.cpp
index f7352eab0..0dd9ab7d9 100644
--- a/radio/src/gui/colorlcd/layouts/layout2x3.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout2x3.cpp
@@ -21,45 +21,16 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_2x3[] = {
-#include "mask_layout2x3.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_2x3);
-
-const ZoneOption OPTIONS_LAYOUT_2x3[] = {LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END};
-
-class Layout2x3 : public Layout
-{
- public:
- Layout2x3(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 6; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- zone.w /= 2;
- zone.h /= 3;
-
- if (index == 1 || index == 3)
- zone.y += zone.h;
- else if (index == 2 || index == 4)
- zone.y += zone.h * 2;
-
- if ((!isMirrored() && index > 2) || (isMirrored() && index < 3))
- zone.x += zone.w;
-
- return zone;
- }
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_0, LAYOUT_MAP_1THIRD, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_0, LAYOUT_MAP_2THIRD, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_2THIRD, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_1THIRD, // ordered to match previous implementation
};
-BaseLayoutFactory layout2x3("Layout2x3", "2 x 3", LBM_LAYOUT_2x3,
- OPTIONS_LAYOUT_2x3);
+BaseLayoutFactory layout2x3("Layout2x3", "2 x 3",
+ defaultZoneOptions,
+ 6, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout2x4.cpp b/radio/src/gui/colorlcd/layouts/layout2x4.cpp
index 7b993eca1..363813234 100644
--- a/radio/src/gui/colorlcd/layouts/layout2x4.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout2x4.cpp
@@ -21,12 +21,6 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-
-const uint8_t _LBM_LAYOUT_2x4[] = {
-#include "mask_layout2x4.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_2x4);
const ZoneOption OPTIONS_LAYOUT_2x4[] = {
LAYOUT_COMMON_OPTIONS,
@@ -48,8 +42,8 @@ class Layout2x4 : public Layout
};
Layout2x4(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
+ Layout::PersistentData* persistentData, uint8_t zoneCount, uint8_t* zoneMap) :
+ Layout(parent, factory, persistentData, zoneCount, zoneMap)
{
}
@@ -62,24 +56,6 @@ class Layout2x4 : public Layout
getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue = RGB(77, 112, 203);
}
- unsigned int getZonesCount() const override { return 8; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
-
- zone.w /= 2;
- zone.h /= 4;
-
- if ((!isMirrored() && index > 3) || (isMirrored() && index < 4)) {
- zone.x += zone.w;
- }
-
- zone.y += (index % 4) * zone.h;
-
- return zone;
- }
-
void paint(BitmapBuffer* dc) override;
};
@@ -102,5 +78,17 @@ void Layout2x4::paint(BitmapBuffer* dc)
}
}
-BaseLayoutFactory layout2x4("Layout2x4", "2 x 4", LBM_LAYOUT_2x4,
- OPTIONS_LAYOUT_2x4);
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_1QTR, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_3QTR, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_3QTR, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+};
+
+BaseLayoutFactory layout2x4("Layout2x4", "2 x 4",
+ OPTIONS_LAYOUT_2x4,
+ 8, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout4+2.cpp b/radio/src/gui/colorlcd/layouts/layout4+2.cpp
index 168c86f5c..2fe34471d 100644
--- a/radio/src/gui/colorlcd/layouts/layout4+2.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout4+2.cpp
@@ -21,47 +21,16 @@
#include "layout.h"
#include "layout_factory_impl.h"
-#include "lz4_bitmaps.h"
-const uint8_t _LBM_LAYOUT_4P2[] = {
-#include "mask_layout4+2.lbm"
-};
-STATIC_LZ4_BITMAP(LBM_LAYOUT_4P2);
-
-const ZoneOption OPTIONS_LAYOUT_4P2[] = {LAYOUT_COMMON_OPTIONS,
- LAYOUT_OPTIONS_END};
-
-class Layout4P2 : public Layout
-{
- public:
- Layout4P2(Window* parent, const LayoutFactory* factory,
- Layout::PersistentData* persistentData) :
- Layout(parent, factory, persistentData)
- {
- }
-
- unsigned int getZonesCount() const override { return 6; }
-
- rect_t getZone(unsigned int index) const override
- {
- rect_t zone = getMainZone();
- zone.w /= 2;
-
- if (index < 4) {
- zone.h /= 4;
- zone.y += (index % 4) * zone.h;
- } else {
- zone.h /= 2;
- zone.y += (index % 2) * zone.h;
- }
-
- if ((!isMirrored() && index > 3) || (isMirrored() && index < 4)) {
- zone.x += zone.w;
- }
-
- return zone;
- }
+static uint8_t zmap[] = {
+ LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_1QTR, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_0, LAYOUT_MAP_3QTR, LAYOUT_MAP_HALF, LAYOUT_MAP_1QTR,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_0, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
+ LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF, LAYOUT_MAP_HALF,
};
-BaseLayoutFactory layout4P2("Layout4P2", "4 + 2", LBM_LAYOUT_4P2,
- OPTIONS_LAYOUT_4P2);
+BaseLayoutFactory layout4P2("Layout4P2", "4 + 2",
+ defaultZoneOptions,
+ 6, zmap);
diff --git a/radio/src/gui/colorlcd/layouts/layout_factory_impl.cpp b/radio/src/gui/colorlcd/layouts/layout_factory_impl.cpp
index 90c9c46f4..d5a70266a 100644
--- a/radio/src/gui/colorlcd/layouts/layout_factory_impl.cpp
+++ b/radio/src/gui/colorlcd/layouts/layout_factory_impl.cpp
@@ -24,10 +24,12 @@
#include "layouts/sliders.h"
#include "view_main.h"
-Layout::Layout(Window* parent, const LayoutFactory * factory, PersistentData * persistentData):
+Layout::Layout(Window* parent, const LayoutFactory * factory, PersistentData * persistentData, uint8_t zoneCount, uint8_t* zoneMap):
LayoutBase(parent, {0, 0, LCD_W, LCD_H}, persistentData),
factory(factory),
- decoration(new ViewMainDecoration(this))
+ decoration(new ViewMainDecoration(this)),
+ zoneCount(zoneCount),
+ zoneMap(zoneMap)
{
adjustLayout();
}
@@ -129,3 +131,23 @@ rect_t Layout::getMainZone() const
return ViewMain::instance()->getMainZone(zone, hasTopbar());
}
+rect_t Layout::getZone(unsigned int index) const
+{
+ rect_t z = getMainZone();
+
+ unsigned int i = index * 4;
+
+ coord_t xo = z.w * zoneMap[i] / LAYOUT_MAP_DIV;
+ coord_t yo = z.h * zoneMap[i+1] / LAYOUT_MAP_DIV;
+ coord_t w = z.w * zoneMap[i+2] / LAYOUT_MAP_DIV;
+ coord_t h = z.h * zoneMap[i+3] / LAYOUT_MAP_DIV;
+
+ if (isMirrored())
+ xo = z.w - xo - w;
+
+ return { z.x + xo, z.y + yo, w, h };
+}
+
+const ZoneOption defaultZoneOptions[] = {LAYOUT_COMMON_OPTIONS,
+ LAYOUT_OPTIONS_END};
+
diff --git a/radio/src/gui/colorlcd/layouts/layout_factory_impl.h b/radio/src/gui/colorlcd/layouts/layout_factory_impl.h
index 82ad59e59..2488d0a61 100644
--- a/radio/src/gui/colorlcd/layouts/layout_factory_impl.h
+++ b/radio/src/gui/colorlcd/layouts/layout_factory_impl.h
@@ -44,13 +44,25 @@
typedef WidgetsContainerImpl LayoutBase;
+extern const ZoneOption defaultZoneOptions[];
+
+#define LAYOUT_MAP_DIV 60
+#define LAYOUT_MAP_0 0
+#define LAYOUT_MAP_1QTR 15
+#define LAYOUT_MAP_1THIRD 20
+#define LAYOUT_MAP_HALF 30
+#define LAYOUT_MAP_2THIRD 40
+#define LAYOUT_MAP_3QTR 45
+#define LAYOUT_MAP_FULL 60
+
class Layout: public LayoutBase
{
friend class LayoutFactory;
public:
- Layout(Window* parent, const LayoutFactory * factory, PersistentData * persistentData);
+ Layout(Window* parent, const LayoutFactory * factory, PersistentData * persistentData,
+ uint8_t zoneCount, uint8_t* zoneMap);
#if defined(DEBUG_WINDOWS)
std::string getName() const override
@@ -104,6 +116,8 @@ class Layout: public LayoutBase
protected:
const LayoutFactory * factory = nullptr;
std::unique_ptr decoration;
+ uint8_t zoneCount;
+ uint8_t* zoneMap = nullptr;
enum DecorationSettings {
DECORATION_NONE = 0x00,
@@ -123,17 +137,69 @@ class Layout: public LayoutBase
// Get the available space for widgets
rect_t getMainZone() const;
+
+ unsigned int getZonesCount() const override { return zoneCount; }
+ rect_t getZone(unsigned int index) const override;
};
+#if LCD_W > LCD_H
+#define BM_W 51
+#define BM_H 25
+#else
+#define BM_W 22
+#define BM_H 34
+#endif
+
template
class BaseLayoutFactory: public LayoutFactory
{
public:
- BaseLayoutFactory(const char * id, const char * name, const uint8_t * bitmap, const ZoneOption * options):
+ BaseLayoutFactory(const char * id, const char * name,
+ const ZoneOption * options, uint8_t zoneCount, uint8_t* zoneMap):
LayoutFactory(id, name),
- bitmap(bitmap),
- options(options)
+ options(options),
+ zoneCount(zoneCount),
+ zoneMap(zoneMap)
{
+ this->bitmap = (uint8_t*)malloc(align32(BM_W * BM_H + 2 * sizeof(uint16_t) + 4));
+
+ uint16_t* hdr = (uint16_t*)this->bitmap;
+ hdr[0] = BM_W;
+ hdr[1] = BM_H;
+
+ uint8_t* bm = (uint8_t*)(this->bitmap + 2 * sizeof(uint16_t));
+ memset(bm, 0, BM_W * BM_H);
+
+ memset(bm, 0xFF, BM_W);
+ memset(bm+((BM_H-1)*BM_W), 0xFF, BM_W);
+
+ for (int y = 1; y < BM_H - 1; y += 1) {
+ bm[y*BM_W] = 0xFF;
+ bm[y*BM_W+BM_W-1] = 0xFF;
+ }
+
+ for (int i = 0; i < zoneCount * 4; i += 4) {
+ uint8_t xo = BM_W * zoneMap[i] / LAYOUT_MAP_DIV;
+ uint8_t yo = BM_H * zoneMap[i+1] / LAYOUT_MAP_DIV;
+ uint8_t w = BM_W * zoneMap[i+2] / LAYOUT_MAP_DIV;
+ uint8_t h = (BM_H * zoneMap[i+3] + LAYOUT_MAP_DIV/2) / LAYOUT_MAP_DIV;
+
+ if (yo > 0)
+ memset(bm+(yo*BM_W+xo), 0xFF, w);
+ if (xo > 0) {
+ for (int y = 0; y < h; y += 1) {
+ bm[(yo+y)*BM_W+xo] = 0xFF;
+ }
+ }
+ }
+ }
+
+ ~BaseLayoutFactory()
+ {
+ if (bitmap) {
+ free((void*)bitmap);
+ bitmap = nullptr;
+ }
}
const uint8_t* getBitmap() const override { return bitmap; }
@@ -151,7 +217,7 @@ class BaseLayoutFactory: public LayoutFactory
Layout * create(Window* parent, Layout::PersistentData * persistentData) const override
{
initPersistentData(persistentData, true);
- Layout * layout = new T(parent, this, persistentData);
+ Layout * layout = new T(parent, this, persistentData, zoneCount, zoneMap);
if (layout) {
layout->create();
}
@@ -161,7 +227,7 @@ class BaseLayoutFactory: public LayoutFactory
Layout * load(Window* parent, Layout::PersistentData * persistentData) const override
{
initPersistentData(persistentData, false);
- Layout * layout = new T(parent, this, persistentData);
+ Layout * layout = new T(parent, this, persistentData, zoneCount, zoneMap);
if (layout) {
layout->load();
}
@@ -191,6 +257,8 @@ class BaseLayoutFactory: public LayoutFactory
}
protected:
- const uint8_t * bitmap;
+ const uint8_t * bitmap = nullptr;
const ZoneOption * options;
+ uint8_t zoneCount;
+ uint8_t* zoneMap;
};