diff --git a/radio/src/thirdparty/libopenui/src/button.cpp b/radio/src/thirdparty/libopenui/src/button.cpp index cf3e213b7..9ba76a6d7 100644 --- a/radio/src/thirdparty/libopenui/src/button.cpp +++ b/radio/src/thirdparty/libopenui/src/button.cpp @@ -77,22 +77,20 @@ void TextButton::paint(BitmapBuffer * dc) if (checked()) { if (hasFocus()) { dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR); - dc->drawSolidFilledRect(3, 3, rect.w - 6, rect.h - 6, FOCUS_BGCOLOR); - } - else { - dc->drawSolidRect(0, 0, rect.w, rect.h, 1, DISABLE_COLOR); - dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, FOCUS_BGCOLOR); + dc->drawSolidFilledRect(3, 3, rect.w - 6, rect.h - 6, EDIT_MARKER_COLOR); + } else { + dc->drawSolidFilledRect(0, 0, rect.w, rect.h, EDIT_MARKER_COLOR); } textColor = FOCUS_COLOR; } else { if (windowFlags & BUTTON_BACKGROUND) { if (hasFocus()) { - dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR); - dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, DISABLE_COLOR); + dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FOCUS_BGCOLOR); + textColor = FOCUS_COLOR; } else { - dc->drawSolidFilledRect(0, 0, rect.w, rect.h, DISABLE_COLOR); + dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FIELD_FRAME_COLOR); } } else { @@ -105,7 +103,8 @@ void TextButton::paint(BitmapBuffer * dc) } } - dc->drawText(rect.w / 2, 1 + (rect.h - getFontHeight(textFlags)) / 2, text.c_str(), CENTERED | textFlags | textColor); + dc->drawText(rect.w / 2, 1 + (rect.h - getFontHeight(textFlags)) / 2, + text.c_str(), CENTERED | textFlags | textColor); } void IconButton::paint(BitmapBuffer * dc) diff --git a/radio/src/thirdparty/libopenui/src/button.h b/radio/src/thirdparty/libopenui/src/button.h index a60ab6476..722ef3f18 100644 --- a/radio/src/thirdparty/libopenui/src/button.h +++ b/radio/src/thirdparty/libopenui/src/button.h @@ -89,31 +89,34 @@ class Button: public FormField class TextButton: public Button { public: - TextButton(FormGroup * parent, const rect_t & rect, std::string text, std::function pressHandler = nullptr, WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE, LcdFlags textFlags = 0): - Button(parent, rect, std::move(pressHandler), windowFlags, textFlags), - text(std::move(text)) - { - } + TextButton(FormGroup* parent, const rect_t& rect, std::string text, + std::function pressHandler = nullptr, + WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE, + LcdFlags textFlags = 0) : + Button(parent, rect, std::move(pressHandler), windowFlags, textFlags), + text(std::move(text)) + { + } #if defined(DEBUG_WINDOWS) - std::string getName() const override - { - return "TextButton \"" + text + "\""; - } + std::string getName() const override + { + return "TextButton \"" + text + "\""; + } #endif - void setText(std::string value) - { - if (value != text) { - text = std::move(value); - invalidate(); - } - } + void setText(std::string value) + { + if (value != text) { + text = std::move(value); + invalidate(); + } + } - void paint(BitmapBuffer * dc) override; + void paint(BitmapBuffer* dc) override; protected: - std::string text; + std::string text; }; class IconButton: public Button diff --git a/radio/src/thirdparty/libopenui/src/form.cpp b/radio/src/thirdparty/libopenui/src/form.cpp index 2c75aa53b..39198f0aa 100644 --- a/radio/src/thirdparty/libopenui/src/form.cpp +++ b/radio/src/thirdparty/libopenui/src/form.cpp @@ -87,14 +87,18 @@ void FormField::setFocus(uint8_t flag, Window * from) void FormField::paint(BitmapBuffer * dc) { if (editMode) { - dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FOCUS_BGCOLOR); + dc->drawSolidFilledRect(0, 0, rect.w, rect.h, EDIT_MARKER_COLOR); } - else if (!(windowFlags & FORM_NO_BORDER)) { - if (hasFocus()) { - dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR); - } - else if (!(windowFlags & FORM_BORDER_FOCUS_ONLY)) { - dc->drawSolidRect(0, 0, rect.w, rect.h, 1, DISABLE_COLOR); + else { + + if (!(windowFlags & FORM_NO_BORDER)) { + + if (hasFocus()) { + dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FOCUS_BGCOLOR); + } else if (!(windowFlags & FORM_BORDER_FOCUS_ONLY)) { + dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FIELD_BGCOLOR); + dc->drawSolidRect(0, 0, rect.w, rect.h, 1, FIELD_FRAME_COLOR); + } } } } diff --git a/radio/src/thirdparty/libopenui/src/menu.cpp b/radio/src/thirdparty/libopenui/src/menu.cpp index 3258d429c..ee46dbe60 100644 --- a/radio/src/thirdparty/libopenui/src/menu.cpp +++ b/radio/src/thirdparty/libopenui/src/menu.cpp @@ -107,36 +107,43 @@ void MenuBody::paint(BitmapBuffer * dc) dc->clear(MENU_BGCOLOR); for (unsigned i = 0; i < lines.size(); i++) { - auto & line = lines[i]; + auto& line = lines[i]; LcdFlags flags = MENU_COLOR | MENU_FONT; if (selectedIndex == (int)i) { flags = MENU_HIGHLIGHT_COLOR | MENU_FONT; if (MENU_HIGHLIGHT_BGCOLOR != MENU_BGCOLOR) { - dc->drawSolidFilledRect(0, i * MENUS_LINE_HEIGHT, width(), MENUS_LINE_HEIGHT, MENU_HIGHLIGHT_BGCOLOR); + dc->drawSolidFilledRect(0, i * MENUS_LINE_HEIGHT, width(), + MENUS_LINE_HEIGHT, MENU_HIGHLIGHT_BGCOLOR); } } if (line.drawLine) { line.drawLine(dc, 0, i * MENUS_LINE_HEIGHT, flags); - } - else { - const char * text = line.text.data(); - dc->drawText(10, i * MENUS_LINE_HEIGHT + (MENUS_LINE_HEIGHT - getFontHeight(MENU_FONT)) / 2, text[0] == '\0' ? "---" : text, flags); + } else { + const char* text = line.text.data(); + dc->drawText(10, + i * MENUS_LINE_HEIGHT + + (MENUS_LINE_HEIGHT - getFontHeight(MENU_FONT)) / 2, + text[0] == '\0' ? "---" : text, flags); } - Menu * menu = getParentMenu(); + Menu* menu = getParentMenu(); if (menu->multiple && line.isChecked) { - theme->drawCheckBox(dc, line.isChecked(), width() - 35, i * MENUS_LINE_HEIGHT + (MENUS_LINE_HEIGHT - 20) / 2, 0); + theme->drawCheckBox(dc, line.isChecked(), width() - 35, + i * MENUS_LINE_HEIGHT + (MENUS_LINE_HEIGHT - 20) / 2, + 0); } if (i > 0) { - dc->drawSolidHorizontalLine(0, i * MENUS_LINE_HEIGHT - 1, MENUS_WIDTH, MENU_LINE_COLOR); + dc->drawSolidHorizontalLine(0, i * MENUS_LINE_HEIGHT, MENUS_WIDTH, + MENU_LINE_COLOR); } } } -MenuWindowContent::MenuWindowContent(Menu * parent): - ModalWindowContent(parent, {(LCD_W - MENUS_WIDTH) / 2, (LCD_H - MENUS_WIDTH) / 2, MENUS_WIDTH, 0}), - body(this, {0, 0, width(), height()}) +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.setFocus(SET_FOCUS_DEFAULT); } @@ -148,9 +155,14 @@ void MenuWindowContent::paint(BitmapBuffer * dc) // the title if (!title.empty()) { - dc->drawText(MENUS_WIDTH / 2, (POPUP_HEADER_HEIGHT - getFontHeight(MENU_HEADER_FONT)) / 2, title.c_str(), CENTERED | MENU_HEADER_FONT); - dc->drawSolidHorizontalLine(0, POPUP_HEADER_HEIGHT - 1, MENUS_WIDTH, MENU_LINE_COLOR); + dc->drawText(MENUS_WIDTH / 2, + (POPUP_HEADER_HEIGHT - getFontHeight(MENU_HEADER_FONT)) / 2, + title.c_str(), CENTERED | MENU_HEADER_FONT); + 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): @@ -165,10 +177,12 @@ void Menu::updatePosition() if (!toolbar) { // there is no navigation bar at the left, we may center the window on screen auto headerHeight = content->title.empty() ? 0 : POPUP_HEADER_HEIGHT; - auto bodyHeight = limit(MENUS_MIN_HEIGHT, content->body.lines.size() * MENUS_LINE_HEIGHT - 1, MENUS_MAX_HEIGHT); + auto bodyHeight = limit( + 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); - content->body.setTop(headerHeight); + content->setHeight(headerHeight + bodyHeight + 2); + content->body.setTop(headerHeight + 1); content->body.setHeight(bodyHeight); } content->body.setInnerHeight(content->body.lines.size() * MENUS_LINE_HEIGHT - 1); diff --git a/radio/src/thirdparty/libopenui/src/numberedit.cpp b/radio/src/thirdparty/libopenui/src/numberedit.cpp index cdbda1dad..e5ff1a38b 100644 --- a/radio/src/thirdparty/libopenui/src/numberedit.cpp +++ b/radio/src/thirdparty/libopenui/src/numberedit.cpp @@ -38,27 +38,30 @@ void NumberEdit::paint(BitmapBuffer * dc) if (editMode) textColor = FOCUS_COLOR; else if (hasFocus()) - textColor = FOCUS_BGCOLOR; - else if (enabled && (value != 0 || zeroText.empty())) - textColor = DEFAULT_COLOR; + textColor = FOCUS_COLOR; + // else if (enabled && (value != 0 || zeroText.empty())) + // textColor = DEFAULT_COLOR; else - textColor = DISABLE_COLOR; + textColor = DEFAULT_COLOR; if (displayFunction) { displayFunction(dc, textColor, value); - } - else if (value == 0 && !zeroText.empty()) { - dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(), textColor | textFlags); + } else if (value == 0 && !zeroText.empty()) { + dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(), + textColor | textFlags); if (textFlags & RIGHT) - dc->drawText(rect.w - FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(), textColor | textFlags); + dc->drawText(rect.w - FIELD_PADDING_LEFT, FIELD_PADDING_TOP, + zeroText.c_str(), textColor | textFlags); else - dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(), textColor | textFlags); - } - else { + dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(), + textColor | textFlags); + } else { if (textFlags & RIGHT) - dc->drawNumber(rect.w - FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, textColor | textFlags, 0, prefix.c_str(), suffix.c_str()); + dc->drawNumber(rect.w - FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, + textColor | textFlags, 0, prefix.c_str(), suffix.c_str()); else - dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, textColor | textFlags, 0, prefix.c_str(), suffix.c_str()); + dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, + textColor | textFlags, 0, prefix.c_str(), suffix.c_str()); } } diff --git a/radio/src/thirdparty/libopenui/src/static.h b/radio/src/thirdparty/libopenui/src/static.h index 6ead718ec..15f1bcf5b 100644 --- a/radio/src/thirdparty/libopenui/src/static.h +++ b/radio/src/thirdparty/libopenui/src/static.h @@ -30,7 +30,7 @@ class StaticText: public Window text(std::move(text)) { if (windowFlags & BUTTON_BACKGROUND) { - setBackgroundColor(DISABLE_COLOR); + setBackgroundColor(FIELD_FRAME_COLOR); } } diff --git a/radio/src/thirdparty/libopenui/src/textedit.cpp b/radio/src/thirdparty/libopenui/src/textedit.cpp index 864399127..3edcfaafb 100644 --- a/radio/src/thirdparty/libopenui/src/textedit.cpp +++ b/radio/src/thirdparty/libopenui/src/textedit.cpp @@ -47,24 +47,27 @@ void TextEdit::paint(BitmapBuffer * dc) FormField::paint(dc); if (editMode) { - dc->drawSizedText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, length, FOCUS_COLOR); + dc->drawSizedText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, length, + FOCUS_COLOR); coord_t left = (cursorPos == 0 ? 0 : getTextWidth(value, cursorPos)); #if defined(SOFTWARE_KEYBOARD) dc->drawSolidFilledRect(left + 2, 2, 2, height() - 4, FOCUS_COLOR); #else - char s[] = { value[cursorPos], '\0' }; - dc->drawSolidFilledRect(FIELD_PADDING_LEFT + left - 1, FIELD_PADDING_TOP - 1, getTextWidth(s, 1) + 1, height() - 2, FOCUS_COLOR); - dc->drawText(FIELD_PADDING_LEFT + left, FIELD_PADDING_TOP, s, DEFAULT_COLOR); + char s[] = {value[cursorPos], '\0'}; + dc->drawSolidFilledRect(FIELD_PADDING_LEFT + left - 1, + FIELD_PADDING_TOP - 1, getTextWidth(s, 1) + 1, + height() - 2, FOCUS_COLOR); + dc->drawText(FIELD_PADDING_LEFT + left, FIELD_PADDING_TOP, s, + DEFAULT_COLOR); #endif - } - else { + } else { const char * displayedValue = value; - LcdFlags textColor; + LcdFlags textColor = FOCUS_COLOR; if (hasFocus()) { if (strlen(value) == 0) { displayedValue = "---"; } - textColor = FOCUS_BGCOLOR; + textColor = FOCUS_COLOR; } else { if (strlen(value) == 0) {