From f8042ee2e06fc115fa43991193fe9497c56ea4a9 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 13 Jun 2021 08:33:41 +0200 Subject: [PATCH] [Menu] tuned look of menus with toolbar - use DEFAULT_BGCOLOR for toolbar - draw line around the complete menu --- radio/src/thirdparty/libopenui/src/menu.cpp | 20 +++++++++++++------ radio/src/thirdparty/libopenui/src/menu.h | 2 ++ .../thirdparty/libopenui/src/menutoolbar.cpp | 17 ++++++++++------ .../thirdparty/libopenui/src/menutoolbar.h | 2 +- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/menu.cpp b/radio/src/thirdparty/libopenui/src/menu.cpp index ee46dbe60..9db5f5d0c 100644 --- a/radio/src/thirdparty/libopenui/src/menu.cpp +++ b/radio/src/thirdparty/libopenui/src/menu.cpp @@ -143,7 +143,7 @@ void MenuBody::paint(BitmapBuffer * dc) MenuWindowContent::MenuWindowContent(Menu* parent) : ModalWindowContent(parent, {(LCD_W - MENUS_WIDTH) / 2, (LCD_H - MENUS_WIDTH) / 2, MENUS_WIDTH, 0}), - body(this, {1, 1, width() - 2, height() - 2}) + body(this, {0, 0, width(), height()}) { body.setFocus(SET_FOCUS_DEFAULT); } @@ -161,8 +161,6 @@ void MenuWindowContent::paint(BitmapBuffer * dc) dc->drawSolidHorizontalLine(0, POPUP_HEADER_HEIGHT - 1, MENUS_WIDTH, MENU_LINE_COLOR); } - - dc->drawSolidRect(0, 0, MENUS_WIDTH, height(), 1, MENU_LINE_COLOR); } Menu::Menu(Window * parent, bool multiple): @@ -181,11 +179,11 @@ void Menu::updatePosition() MENUS_MIN_HEIGHT, content->body.lines.size() * MENUS_LINE_HEIGHT - 1, MENUS_MAX_HEIGHT); content->setTop((LCD_H - headerHeight - bodyHeight) / 2 + MENUS_OFFSET_TOP); - content->setHeight(headerHeight + bodyHeight + 2); - content->body.setTop(headerHeight + 1); + content->setHeight(headerHeight + bodyHeight); + content->body.setTop(headerHeight); content->body.setHeight(bodyHeight); } - content->body.setInnerHeight(content->body.lines.size() * MENUS_LINE_HEIGHT - 1); + content->body.setInnerHeight(content->body.lines.size() * MENUS_LINE_HEIGHT); } void Menu::setTitle(std::string text) @@ -226,3 +224,13 @@ void Menu::onEvent(event_t event) } } #endif + +void Menu::paint(BitmapBuffer * dc) +{ + rect_t r(content->getRect()); + if (toolbar) { + r.x = toolbar->left(); + r.w += toolbar->width(); + } + dc->drawSolidRect(r.x - 1, r.y - 1, r.w + 2, r.h + 2, 1, MENU_LINE_COLOR); +} diff --git a/radio/src/thirdparty/libopenui/src/menu.h b/radio/src/thirdparty/libopenui/src/menu.h index 9e41eaa32..8b8e361b2 100644 --- a/radio/src/thirdparty/libopenui/src/menu.h +++ b/radio/src/thirdparty/libopenui/src/menu.h @@ -224,6 +224,8 @@ class Menu: public ModalWindow } } + void paint(BitmapBuffer * dc) override; + protected: MenuWindowContent * content; bool multiple; diff --git a/radio/src/thirdparty/libopenui/src/menutoolbar.cpp b/radio/src/thirdparty/libopenui/src/menutoolbar.cpp index f6cceee29..7a27ae2d0 100644 --- a/radio/src/thirdparty/libopenui/src/menutoolbar.cpp +++ b/radio/src/thirdparty/libopenui/src/menutoolbar.cpp @@ -23,10 +23,15 @@ void MenuToolbarButton::paint(BitmapBuffer * dc) { if (checked()) { - dc->drawSolidFilledRect(MENUS_TOOLBAR_BUTTON_PADDING, MENUS_TOOLBAR_BUTTON_PADDING, MENUS_TOOLBAR_BUTTON_WIDTH - 2 * MENUS_TOOLBAR_BUTTON_PADDING, MENUS_TOOLBAR_BUTTON_WIDTH - 2 * MENUS_TOOLBAR_BUTTON_PADDING, FOCUS_BGCOLOR); - dc->drawSizedText(rect.w / 2, (rect.h - getFontHeight(FONT(STD))) / 2 + 1, &picto, 1, CENTERED | FOCUS_COLOR); + dc->drawSolidFilledRect( + MENUS_TOOLBAR_BUTTON_PADDING, MENUS_TOOLBAR_BUTTON_PADDING, + MENUS_TOOLBAR_BUTTON_WIDTH - 2 * MENUS_TOOLBAR_BUTTON_PADDING, + MENUS_TOOLBAR_BUTTON_WIDTH - 2 * MENUS_TOOLBAR_BUTTON_PADDING, + FOCUS_BGCOLOR); + dc->drawSizedText(rect.w / 2, (rect.h - getFontHeight(FONT(STD))) / 2 + 1, + &picto, 1, CENTERED | FOCUS_COLOR); + } else { + dc->drawSizedText(rect.w / 2, (rect.h - getFontHeight(FONT(STD))) / 2 + 1, + &picto, 1, CENTERED | DEFAULT_COLOR); } - else { - dc->drawSizedText(rect.w / 2, (rect.h - getFontHeight(FONT(STD))) / 2 + 1, &picto, 1, CENTERED | DEFAULT_COLOR); - } -} \ No newline at end of file +} diff --git a/radio/src/thirdparty/libopenui/src/menutoolbar.h b/radio/src/thirdparty/libopenui/src/menutoolbar.h index 44365caed..de493a04f 100644 --- a/radio/src/thirdparty/libopenui/src/menutoolbar.h +++ b/radio/src/thirdparty/libopenui/src/menutoolbar.h @@ -78,7 +78,7 @@ class MenuToolbar: public FormGroup { void paint(BitmapBuffer * dc) override { - dc->clear(DISABLE_COLOR); + dc->clear(DEFAULT_BGCOLOR); } #if defined(HARDWARE_KEYS)