Latest libopenui updates
This commit is contained in:
+4
-4
@@ -363,15 +363,15 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
|||||||
|
|
||||||
coord_t drawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags flags=0);
|
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++;
|
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);
|
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);
|
||||||
|
|||||||
+11
@@ -39,6 +39,16 @@ class CheckBox : public FormField {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const char * getLabel() const
|
||||||
|
{
|
||||||
|
return label.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLabel(std::string newLabel)
|
||||||
|
{
|
||||||
|
label = std::move(newLabel);
|
||||||
|
}
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
@@ -55,6 +65,7 @@ class CheckBox : public FormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
std::string label;
|
||||||
std::function<uint8_t()> _getValue;
|
std::function<uint8_t()> _getValue;
|
||||||
std::function<void(uint8_t)> _setValue;
|
std::function<void(uint8_t)> _setValue;
|
||||||
};
|
};
|
||||||
|
|||||||
+11
-11
@@ -27,7 +27,7 @@
|
|||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
STRUCT_TOUCH touchState;
|
TouchState touchState;
|
||||||
Keyboard * Keyboard::activeKeyboard = nullptr;
|
Keyboard * Keyboard::activeKeyboard = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -42,20 +42,20 @@ void MainWindow::emptyTrash()
|
|||||||
void MainWindow::checkEvents(bool trash)
|
void MainWindow::checkEvents(bool trash)
|
||||||
{
|
{
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
if (touchState.Event == TE_DOWN) {
|
if (touchState.event == TE_DOWN) {
|
||||||
onTouchStart(touchState.X + scrollPositionX, touchState.Y + scrollPositionY);
|
onTouchStart(touchState.x + scrollPositionX, touchState.y + scrollPositionY);
|
||||||
// touchState.Event = TE_NONE;
|
// touchState.Event = TE_NONE;
|
||||||
}
|
}
|
||||||
else if (touchState.Event == TE_UP) {
|
else if (touchState.event == TE_UP) {
|
||||||
touchState.Event = TE_NONE;
|
touchState.event = TE_NONE;
|
||||||
onTouchEnd(touchState.startX + scrollPositionX, touchState.startY + scrollPositionY);
|
onTouchEnd(touchState.startX + scrollPositionX, touchState.startY + scrollPositionY);
|
||||||
}
|
}
|
||||||
else if (touchState.Event == TE_SLIDE) {
|
else if (touchState.event == TE_SLIDE) {
|
||||||
coord_t x = touchState.X - touchState.lastX;
|
coord_t x = touchState.x - touchState.lastX;
|
||||||
coord_t y = touchState.Y - touchState.lastY;
|
coord_t y = touchState.y - touchState.lastY;
|
||||||
onTouchSlide(touchState.X, touchState.Y, touchState.startX, touchState.startY, x, y);
|
onTouchSlide(touchState.x, touchState.y, touchState.startX, touchState.startY, x, y);
|
||||||
touchState.lastX = touchState.X;
|
touchState.lastX = touchState.x;
|
||||||
touchState.lastY = touchState.Y;
|
touchState.lastY = touchState.y;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -171,7 +171,9 @@ bool TextEdit::onTouchEnd(coord_t x, coord_t y)
|
|||||||
setFocus();
|
setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SOFTWARE_KEYBOARD)
|
||||||
TextKeyboard::show(this);
|
TextKeyboard::show(this);
|
||||||
|
#endif
|
||||||
|
|
||||||
coord_t rest = x;
|
coord_t rest = x;
|
||||||
for (cursorPos = 0; cursorPos < length; cursorPos++) {
|
for (cursorPos = 0; cursorPos < length; cursorPos++) {
|
||||||
@@ -187,12 +189,13 @@ bool TextEdit::onTouchEnd(coord_t x, coord_t y)
|
|||||||
invalidate();
|
invalidate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SOFTWARE_KEYBOARD)
|
||||||
void TextEdit::onFocusLost()
|
void TextEdit::onFocusLost()
|
||||||
{
|
{
|
||||||
#if defined(HARDWARE_TOUCH)
|
|
||||||
TextKeyboard::hide();
|
TextKeyboard::hide();
|
||||||
#endif
|
|
||||||
// TODO storageDirty(...);
|
// TODO storageDirty(...);
|
||||||
FormField::onFocusLost();
|
FormField::onFocusLost();
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -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 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
|
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 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;
|
virtual void drawChoice(BitmapBuffer * dc, ChoiceBase * choice, const char * str) const = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user