From 83375befc1115bcb827245acdca98308975cc372 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 19 Jun 2021 17:05:55 +0200 Subject: [PATCH 1/5] Fix displaying ModelBmp on small surfaces Resolves #269 --- radio/src/gui/colorlcd/layouts/layout2x4.cpp | 21 +++++++++++++++++++- radio/src/gui/colorlcd/widgets/modelbmp.cpp | 7 ++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/colorlcd/layouts/layout2x4.cpp b/radio/src/gui/colorlcd/layouts/layout2x4.cpp index b88c97095..18fa09a5e 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x4.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x4.cpp @@ -56,7 +56,7 @@ class Layout2x4: public Layout getOptionValue(OPTION_PANEL1_BACKGROUND)->boolValue = true; getOptionValue(OPTION_PANEL1_COLOR)->unsignedValue = RGB(77,112,203); getOptionValue(OPTION_PANEL2_BACKGROUND)->boolValue = true; - getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue = RGB(77,112,203); + getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue = RGB(7,1,2); } unsigned int getZonesCount() const override @@ -79,6 +79,25 @@ class Layout2x4: public Layout return zone; } + + void paint(BitmapBuffer * dc) override; }; +void Layout2x4::paint(BitmapBuffer* dc) +{ + rect_t fullScreen = Layout::getMainZone(); + fullScreen.w /=2; + if (getOptionValue(OPTION_PANEL1_BACKGROUND)->boolValue) { + lcdSetColor(getOptionValue(OPTION_PANEL1_COLOR)->unsignedValue); + dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, fullScreen.h, CUSTOM_COLOR); + } + + if (getOptionValue(OPTION_PANEL2_BACKGROUND)->boolValue) { + fullScreen.x += fullScreen.w; + lcdSetColor(getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue); + dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, fullScreen.h, CUSTOM_COLOR); + } + Layout::paint(dc); +} + BaseLayoutFactory layout2x4("Layout2x4", "2 x 4", LBM_LAYOUT_2x4, OPTIONS_LAYOUT_2x4); diff --git a/radio/src/gui/colorlcd/widgets/modelbmp.cpp b/radio/src/gui/colorlcd/widgets/modelbmp.cpp index daf5977f7..3eee954d0 100644 --- a/radio/src/gui/colorlcd/widgets/modelbmp.cpp +++ b/radio/src/gui/colorlcd/widgets/modelbmp.cpp @@ -97,7 +97,12 @@ class ModelBitmapWidget: public Widget TRACE("could not load bitmap '%s'", filename.c_str()); return; } - buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38); + + if (rect.h >= 96 && rect.w >= 120) { + buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38); + } else { + buffer->drawScaledBitmap(bitmap.get(), 0, 0, width(), height()); + } } } }; From 02c4e74a3f896fed4d24bdda3b13940caa58dc51 Mon Sep 17 00:00:00 2001 From: eshifri Date: Sat, 19 Jun 2021 11:16:40 -0700 Subject: [PATCH 2/5] Fix for #256: change background for 2x4 widgets. --- radio/src/gui/colorlcd/layouts/layout2x4.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/layouts/layout2x4.cpp b/radio/src/gui/colorlcd/layouts/layout2x4.cpp index 18fa09a5e..106b60d18 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x4.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x4.cpp @@ -56,7 +56,7 @@ class Layout2x4: public Layout getOptionValue(OPTION_PANEL1_BACKGROUND)->boolValue = true; getOptionValue(OPTION_PANEL1_COLOR)->unsignedValue = RGB(77,112,203); getOptionValue(OPTION_PANEL2_BACKGROUND)->boolValue = true; - getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue = RGB(7,1,2); + getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue = RGB(77,112,203); } unsigned int getZonesCount() const override From 2644fc6c9e8484eb63a339480fff821744dcd337 Mon Sep 17 00:00:00 2001 From: eshifri Date: Sat, 19 Jun 2021 11:24:18 -0700 Subject: [PATCH 3/5] Fixed formatting --- radio/src/gui/colorlcd/layouts/layout2x4.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/colorlcd/layouts/layout2x4.cpp b/radio/src/gui/colorlcd/layouts/layout2x4.cpp index 106b60d18..17c2bc0e7 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x4.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x4.cpp @@ -86,16 +86,18 @@ class Layout2x4: public Layout void Layout2x4::paint(BitmapBuffer* dc) { rect_t fullScreen = Layout::getMainZone(); - fullScreen.w /=2; + fullScreen.w /= 2; if (getOptionValue(OPTION_PANEL1_BACKGROUND)->boolValue) { lcdSetColor(getOptionValue(OPTION_PANEL1_COLOR)->unsignedValue); - dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, fullScreen.h, CUSTOM_COLOR); + dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, + fullScreen.h, CUSTOM_COLOR); } if (getOptionValue(OPTION_PANEL2_BACKGROUND)->boolValue) { fullScreen.x += fullScreen.w; lcdSetColor(getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue); - dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, fullScreen.h, CUSTOM_COLOR); + dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, + fullScreen.h, CUSTOM_COLOR); } Layout::paint(dc); } From 487d3713149bd15f3fc75e6d1c17b48fcbcf665b Mon Sep 17 00:00:00 2001 From: eshifri Date: Sat, 19 Jun 2021 22:53:23 -0700 Subject: [PATCH 4/5] Base class paint should be called prior. --- radio/src/gui/colorlcd/layouts/layout2x4.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/layouts/layout2x4.cpp b/radio/src/gui/colorlcd/layouts/layout2x4.cpp index 17c2bc0e7..7214c8535 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x4.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x4.cpp @@ -85,6 +85,7 @@ class Layout2x4: public Layout void Layout2x4::paint(BitmapBuffer* dc) { + Layout::paint(dc); rect_t fullScreen = Layout::getMainZone(); fullScreen.w /= 2; if (getOptionValue(OPTION_PANEL1_BACKGROUND)->boolValue) { @@ -99,7 +100,6 @@ void Layout2x4::paint(BitmapBuffer* dc) dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, fullScreen.h, CUSTOM_COLOR); } - Layout::paint(dc); } BaseLayoutFactory layout2x4("Layout2x4", "2 x 4", LBM_LAYOUT_2x4, OPTIONS_LAYOUT_2x4); From 15a5b6e4cb21236d38e958961c82f15fe3e5e37f Mon Sep 17 00:00:00 2001 From: eshifri Date: Sun, 20 Jun 2021 07:46:35 -0700 Subject: [PATCH 5/5] Removed SetLcd --- radio/src/gui/colorlcd/layouts/layout2x4.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/radio/src/gui/colorlcd/layouts/layout2x4.cpp b/radio/src/gui/colorlcd/layouts/layout2x4.cpp index 7214c8535..66bc3c186 100644 --- a/radio/src/gui/colorlcd/layouts/layout2x4.cpp +++ b/radio/src/gui/colorlcd/layouts/layout2x4.cpp @@ -89,16 +89,14 @@ void Layout2x4::paint(BitmapBuffer* dc) rect_t fullScreen = Layout::getMainZone(); fullScreen.w /= 2; if (getOptionValue(OPTION_PANEL1_BACKGROUND)->boolValue) { - lcdSetColor(getOptionValue(OPTION_PANEL1_COLOR)->unsignedValue); dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, - fullScreen.h, CUSTOM_COLOR); + fullScreen.h, COLOR2FLAGS(getOptionValue(OPTION_PANEL1_COLOR)->unsignedValue)); } if (getOptionValue(OPTION_PANEL2_BACKGROUND)->boolValue) { fullScreen.x += fullScreen.w; - lcdSetColor(getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue); dc->drawSolidFilledRect(fullScreen.x, fullScreen.y, fullScreen.w, - fullScreen.h, CUSTOM_COLOR); + fullScreen.h, COLOR2FLAGS(getOptionValue(OPTION_PANEL2_COLOR)->unsignedValue)); } }