diff --git a/radio/src/thirdparty/libopenui/src/menu.cpp b/radio/src/thirdparty/libopenui/src/menu.cpp index e63dbc027..f4782c67d 100644 --- a/radio/src/thirdparty/libopenui/src/menu.cpp +++ b/radio/src/thirdparty/libopenui/src/menu.cpp @@ -95,6 +95,8 @@ bool MenuBody::onTouchEnd(coord_t /*x*/, coord_t y) void MenuBody::paint(BitmapBuffer * dc) { + dc->clear(MENU_BGCOLOR); + for (unsigned i = 0; i < lines.size(); i++) { auto & line = lines[i]; LcdFlags flags = MENU_COLOR | MENU_FONT; diff --git a/radio/src/thirdparty/libopenui/src/textedit.cpp b/radio/src/thirdparty/libopenui/src/textedit.cpp index 18c65c649..097d534f4 100644 --- a/radio/src/thirdparty/libopenui/src/textedit.cpp +++ b/radio/src/thirdparty/libopenui/src/textedit.cpp @@ -85,12 +85,14 @@ void TextEdit::onEvent(event_t event) value[length - 1] = '\0'; --cursorPos; invalidate(); + changed = true; } } else if (cursorPos < length) { memmove(value + cursorPos + 1, value + cursorPos, length - cursorPos - 1); value[cursorPos++] = c; invalidate(); + changed = true; } } #endif @@ -130,8 +132,10 @@ void TextEdit::onEvent(event_t event) case EVT_KEY_BREAK(KEY_ENTER): if (cursorPos < length - 1) { cursorPos++; - if (value[cursorPos] == '\0') + if (value[cursorPos] == '\0') { value[cursorPos] = ' '; + changed = true; + } invalidate(); } else { @@ -171,7 +175,7 @@ void TextEdit::onEvent(event_t event) // TRACE("value[%d] = %d", cursorPos, v); value[cursorPos] = v; invalidate(); - // TODO storageDirty(...); + changed = true; } } else { @@ -216,6 +220,5 @@ void TextEdit::onFocusLost() changeEnd(); - // TODO storageDirty(...); FormField::onFocusLost(); } diff --git a/radio/src/thirdparty/libopenui/src/textedit.h b/radio/src/thirdparty/libopenui/src/textedit.h index 8676441d9..52a732cc1 100644 --- a/radio/src/thirdparty/libopenui/src/textedit.h +++ b/radio/src/thirdparty/libopenui/src/textedit.h @@ -67,6 +67,7 @@ class TextEdit : public FormField { protected: char * value; + bool changed = false; uint8_t length; uint8_t cursorPos = 0; std::function changeHandler = nullptr; @@ -76,9 +77,12 @@ class TextEdit : public FormField { void changeEnd() { cursorPos = 0; - trim(); - if (changeHandler) - changeHandler(); + if (changed) { + changed = false; + trim(); + if (changeHandler) + changeHandler(); + } } static uint8_t getNextChar(uint8_t c) diff --git a/radio/src/thirdparty/libopenui/src/window.cpp b/radio/src/thirdparty/libopenui/src/window.cpp index 8f4b38425..6842bd32d 100644 --- a/radio/src/thirdparty/libopenui/src/window.cpp +++ b/radio/src/thirdparty/libopenui/src/window.cpp @@ -205,17 +205,18 @@ void Window::scrollTo(const rect_t & rect) } } -bool Window::hasOpaqueRect(const rect_t & rect) const +bool Window::hasOpaqueRect(const rect_t & testRect) const { - if (!this->rect.contains(rect)) + if (!rect.contains(testRect)) return false; if (windowFlags & OPAQUE) { return true; } + rect_t relativeRect = {testRect.x - rect.x, testRect.y - rect.y, testRect.w, testRect.h}; for (auto child: children) { - if (child->hasOpaqueRect(rect)) + if (child->hasOpaqueRect(relativeRect)) return true; } @@ -228,19 +229,20 @@ void Window::fullPaint(BitmapBuffer * dc) coord_t xmin, xmax, ymin, ymax; dc->getClippingRect(xmin, xmax, ymin, ymax); + coord_t x = dc->getOffsetX(); + coord_t y = dc->getOffsetY(); auto firstChild = children.end(); + rect_t relativeRect = {xmin - x, ymin - y, xmax - xmin, ymax - ymin}; while (firstChild != children.begin()) { auto child = *(--firstChild); - if (child->hasOpaqueRect({xmin, ymin, xmax - xmin, ymax - ymin})) { + if (child->hasOpaqueRect(relativeRect)) { paintNeeded = false; break; } } if (windowFlags & PAINT_CHILDREN_FIRST) { - coord_t x = dc->getOffsetX(); - coord_t y = dc->getOffsetY(); paintChildren(dc, firstChild); dc->setOffset(x, y); dc->setClippingRect(xmin, xmax, ymin, ymax); diff --git a/radio/src/thirdparty/libopenui/src/window.h b/radio/src/thirdparty/libopenui/src/window.h index 2f6c0ba1e..2fa1273cb 100644 --- a/radio/src/thirdparty/libopenui/src/window.h +++ b/radio/src/thirdparty/libopenui/src/window.h @@ -416,7 +416,7 @@ class Window { bool forwardTouchEnd(coord_t x, coord_t y); - bool hasOpaqueRect(const rect_t & rect) const; + bool hasOpaqueRect(const rect_t & testRect) const; }; #endif // _WINDOW_H_