From d862cd6a8cea76f56701e0fb6813e31ab4e5df57 Mon Sep 17 00:00:00 2001 From: "kkoenig1@optonline.com" Date: Tue, 28 Sep 2021 10:52:29 -0400 Subject: [PATCH] Enhance FormField paint to allow instantiator to set a background color handler. Used in FlightModes() to set background color. Enhance GridLayout to allow whitespace at top. changed modal to use hard coded BLACK instead of theme color as per JimB40 --- radio/src/thirdparty/libopenui/src/form.cpp | 29 ++++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/form.cpp b/radio/src/thirdparty/libopenui/src/form.cpp index a168f009f..8d88327fc 100644 --- a/radio/src/thirdparty/libopenui/src/form.cpp +++ b/radio/src/thirdparty/libopenui/src/form.cpp @@ -86,21 +86,24 @@ void FormField::setFocus(uint8_t flag, Window * from) void FormField::paint(BitmapBuffer * dc) { - if (editMode) { - dc->drawSolidFilledRect(0, 0, rect.w, rect.h, COLOR_THEME_EDIT); - } - else { - - if (!(windowFlags & FORM_NO_BORDER)) { - - if (hasFocus()) { - dc->drawSolidFilledRect(0, 0, rect.w, rect.h, COLOR_THEME_FOCUS); - } else if (!(windowFlags & FORM_BORDER_FOCUS_ONLY)) { - dc->drawSolidFilledRect(0, 0, rect.w, rect.h, COLOR_THEME_PRIMARY2); - dc->drawSolidRect(0, 0, rect.w, rect.h, 1, COLOR_THEME_SECONDARY2); - } + uint32_t bgColor = 0; + if (backgroundHandler) { + bgColor = backgroundHandler(this); + } else { + if (editMode) { + bgColor = COLOR_THEME_EDIT; + } else if (hasFocus()) { + bgColor = COLOR_THEME_FOCUS; + } else { + bgColor = COLOR_THEME_PRIMARY2; } } + + if (editMode || ! (windowFlags & FORM_NO_BORDER)) { + dc->drawSolidFilledRect(0, 0, rect.w, rect.h, bgColor); + if (!editMode) + dc->drawSolidRect(0, 0, rect.w, rect.h, 1, COLOR_THEME_SECONDARY2); + } } void FormGroup::removeField(FormField * field)