This commit is contained in:
Bertrand Songis
2020-10-08 17:59:40 +02:00
parent cc76efd38b
commit 16ebf50f40
3 changed files with 40 additions and 4 deletions
+35 -3
View File
@@ -48,7 +48,6 @@ class Table: public FormField {
void paint(BitmapBuffer * dc, coord_t x, coord_t y, LcdFlags flags) override
{
dc->drawText(x, y - 2 + (TABLE_LINE_HEIGHT - getFontHeight(TABLE_HEADER_FONT)) / 2 + 3, value.c_str(), flags);
}
@@ -83,6 +82,27 @@ class Table: public FormField {
std::function<std::string()> getText;
};
class CustomCell : public Cell {
public:
explicit CustomCell(std::function<void(BitmapBuffer * dc, coord_t x, coord_t y, LcdFlags flags)> paintFunction):
paintFunction(std::move(paintFunction))
{
}
void paint(BitmapBuffer * dc, coord_t x, coord_t y, LcdFlags flags) override
{
paintFunction(dc, x, y, flags);
}
bool needsInvalidate() override
{
return true;
}
protected:
std::function<void(BitmapBuffer * dc, coord_t x, coord_t y, LcdFlags flags)> paintFunction;
};
class Line {
public:
explicit Line(uint8_t columnsCount):
@@ -236,10 +256,22 @@ class Table: public FormField {
body.detach();
}
void setColumnsWidth(const coord_t width[])
void setColumnsWidth(const coord_t values[])
{
int8_t restColumn = -1;
coord_t restWidth = width();
for (uint8_t i = 0; i < columnsCount; i++) {
columnsWidth[i] = width[i];
auto columnWidth = values[i];
columnsWidth[i] = columnWidth;
if (columnWidth == 0) {
restColumn = i;
}
else {
restWidth -= columnWidth;
}
}
if (restColumn) {
columnsWidth[restColumn] = restWidth;
}
}
+4
View File
@@ -188,6 +188,10 @@ void TextEdit::onEvent(event_t event)
#if defined(HARDWARE_TOUCH)
bool TextEdit::onTouchEnd(coord_t x, coord_t y)
{
if (!isEnabled()) {
return true;
}
if (!hasFocus()) {
setFocus(SET_FOCUS_DEFAULT);
}
+1 -1
View File
@@ -103,7 +103,7 @@ class Window {
bool isChild(Window * window) const
{
return window == this || (getParent() && getParent()->isChild(window));
return window == this || (parent && parent->isChild(window));
}
Window * getFullScreenWindow()