diff --git a/radio/src/thirdparty/libopenui/src/bitmapbuffer.h b/radio/src/thirdparty/libopenui/src/bitmapbuffer.h index 5a6631168..de0a0e69b 100644 --- a/radio/src/thirdparty/libopenui/src/bitmapbuffer.h +++ b/radio/src/thirdparty/libopenui/src/bitmapbuffer.h @@ -363,15 +363,15 @@ class BitmapBuffer: public BitmapBufferBase coord_t drawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags flags=0); - void drawText(coord_t x, coord_t y, const char * s, LcdFlags flags = 0) + coord_t drawText(coord_t x, coord_t y, const char * s, LcdFlags flags = 0) { - drawSizedText(x, y, s, 255, flags); + return drawSizedText(x, y, s, 255, flags); } - void drawTextAtIndex(coord_t x, coord_t y, const char * s, uint8_t idx, LcdFlags flags = 0) + coord_t drawTextAtIndex(coord_t x, coord_t y, const char * s, uint8_t idx, LcdFlags flags = 0) { char length = *s++; - drawSizedText(x, y, s+length*idx, length, flags); + return drawSizedText(x, y, s+length*idx, length, flags); } void drawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags = 0, uint8_t len = 0, const char * prefix = nullptr, const char * suffix = nullptr); diff --git a/radio/src/thirdparty/libopenui/src/checkbox.h b/radio/src/thirdparty/libopenui/src/checkbox.h index d61605881..c0b2193d9 100644 --- a/radio/src/thirdparty/libopenui/src/checkbox.h +++ b/radio/src/thirdparty/libopenui/src/checkbox.h @@ -39,6 +39,16 @@ class CheckBox : public FormField { } #endif + const char * getLabel() const + { + return label.c_str(); + } + + void setLabel(std::string newLabel) + { + label = std::move(newLabel); + } + void paint(BitmapBuffer * dc) override; #if defined(HARDWARE_KEYS) @@ -55,6 +65,7 @@ class CheckBox : public FormField { } protected: + std::string label; std::function _getValue; std::function _setValue; }; diff --git a/radio/src/thirdparty/libopenui/src/mainwindow.cpp b/radio/src/thirdparty/libopenui/src/mainwindow.cpp index 260683d6c..48aec258b 100644 --- a/radio/src/thirdparty/libopenui/src/mainwindow.cpp +++ b/radio/src/thirdparty/libopenui/src/mainwindow.cpp @@ -27,7 +27,7 @@ MainWindow mainWindow; #if defined(HARDWARE_TOUCH) -STRUCT_TOUCH touchState; +TouchState touchState; Keyboard * Keyboard::activeKeyboard = nullptr; #endif @@ -42,20 +42,20 @@ void MainWindow::emptyTrash() void MainWindow::checkEvents(bool trash) { #if defined(HARDWARE_TOUCH) - if (touchState.Event == TE_DOWN) { - onTouchStart(touchState.X + scrollPositionX, touchState.Y + scrollPositionY); + if (touchState.event == TE_DOWN) { + onTouchStart(touchState.x + scrollPositionX, touchState.y + scrollPositionY); // touchState.Event = TE_NONE; } - else if (touchState.Event == TE_UP) { - touchState.Event = TE_NONE; + else if (touchState.event == TE_UP) { + touchState.event = TE_NONE; onTouchEnd(touchState.startX + scrollPositionX, touchState.startY + scrollPositionY); } - else if (touchState.Event == TE_SLIDE) { - coord_t x = touchState.X - touchState.lastX; - coord_t y = touchState.Y - touchState.lastY; - onTouchSlide(touchState.X, touchState.Y, touchState.startX, touchState.startY, x, y); - touchState.lastX = touchState.X; - touchState.lastY = touchState.Y; + else if (touchState.event == TE_SLIDE) { + coord_t x = touchState.x - touchState.lastX; + coord_t y = touchState.y - touchState.lastY; + onTouchSlide(touchState.x, touchState.y, touchState.startX, touchState.startY, x, y); + touchState.lastX = touchState.x; + touchState.lastY = touchState.y; } #endif diff --git a/radio/src/thirdparty/libopenui/src/textedit.cpp b/radio/src/thirdparty/libopenui/src/textedit.cpp index e808dcc55..27006581b 100644 --- a/radio/src/thirdparty/libopenui/src/textedit.cpp +++ b/radio/src/thirdparty/libopenui/src/textedit.cpp @@ -171,7 +171,9 @@ bool TextEdit::onTouchEnd(coord_t x, coord_t y) setFocus(); } +#if defined(SOFTWARE_KEYBOARD) TextKeyboard::show(this); +#endif coord_t rest = x; for (cursorPos = 0; cursorPos < length; cursorPos++) { @@ -187,12 +189,13 @@ bool TextEdit::onTouchEnd(coord_t x, coord_t y) invalidate(); return true; } +#endif +#if defined(SOFTWARE_KEYBOARD) void TextEdit::onFocusLost() { -#if defined(HARDWARE_TOUCH) TextKeyboard::hide(); -#endif + // TODO storageDirty(...); FormField::onFocusLost(); } diff --git a/radio/src/thirdparty/libopenui/src/theme.h b/radio/src/thirdparty/libopenui/src/theme.h index 7b9233d41..18241e250 100644 --- a/radio/src/thirdparty/libopenui/src/theme.h +++ b/radio/src/thirdparty/libopenui/src/theme.h @@ -37,7 +37,10 @@ class Theme { virtual void drawProgressBar(BitmapBuffer * dc, coord_t x, coord_t y, coord_t w, coord_t h, int value) const = 0; virtual void drawCheckBox(BitmapBuffer * dc, CheckBox * checkBox) const { - return drawCheckBox(dc, checkBox->getValue(), 0, 0, checkBox->hasFocus()); + drawCheckBox(dc, checkBox->getValue(), 0, FIELD_PADDING_TOP, checkBox->hasFocus()); + const char * label = checkBox->getLabel(); + if (label) + dc->drawText(22, FIELD_PADDING_TOP, label); } virtual void drawCheckBox(BitmapBuffer * dc, bool checked, coord_t x, coord_t y, bool focus = false) const = 0; virtual void drawChoice(BitmapBuffer * dc, ChoiceBase * choice, const char * str) const = 0;