Cosmetics
This commit is contained in:
+1
-1
@@ -69,7 +69,7 @@ void Table::Body::paint(BitmapBuffer * dc)
|
|||||||
for (unsigned i = 0; i < line->cells.size(); i++) {
|
for (unsigned i = 0; i < line->cells.size(); i++) {
|
||||||
auto cell = line->cells[i];
|
auto cell = line->cells[i];
|
||||||
if (cell) {
|
if (cell) {
|
||||||
cell->paint(dc, x, y, line->flags | (highlight ? MENU_HIGHLIGHT_COLOR : DEFAULT_COLOR));
|
cell->paint(dc, x, y, line->flags + (highlight ? MENU_HIGHLIGHT_COLOR - COLOR_MASK(line->flags) : DEFAULT_COLOR));
|
||||||
}
|
}
|
||||||
x += static_cast<Table *>(parent)->columnsWidth[i];
|
x += static_cast<Table *>(parent)->columnsWidth[i];
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-12
@@ -28,7 +28,8 @@
|
|||||||
class Table: public FormField
|
class Table: public FormField
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class Cell {
|
class Cell
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Cell() = default;
|
virtual ~Cell() = default;
|
||||||
|
|
||||||
@@ -37,7 +38,8 @@ class Table: public FormField
|
|||||||
virtual bool needsInvalidate() = 0;
|
virtual bool needsInvalidate() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StringCell : public Cell {
|
class StringCell : public Cell
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
StringCell() = default;
|
StringCell() = default;
|
||||||
|
|
||||||
@@ -60,7 +62,8 @@ class Table: public FormField
|
|||||||
std::string value;
|
std::string value;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DynamicStringCell : public Cell {
|
class DynamicStringCell : public Cell
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit DynamicStringCell(std::function<std::string()> getText):
|
explicit DynamicStringCell(std::function<std::string()> getText):
|
||||||
getText(std::move(getText))
|
getText(std::move(getText))
|
||||||
@@ -82,9 +85,10 @@ class Table: public FormField
|
|||||||
std::function<std::string()> getText;
|
std::function<std::string()> getText;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomCell : public Cell {
|
class CustomCell : public Cell
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit CustomCell(std::function<void(BitmapBuffer * dc, coord_t x, coord_t y, LcdFlags flags)> paintFunction):
|
explicit CustomCell(std::function<void(BitmapBuffer * /*dc*/, coord_t /*x*/, coord_t /*y*/, LcdFlags /*flags*/)> paintFunction):
|
||||||
paintFunction(std::move(paintFunction))
|
paintFunction(std::move(paintFunction))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -103,7 +107,8 @@ class Table: public FormField
|
|||||||
std::function<void(BitmapBuffer * dc, coord_t x, coord_t y, LcdFlags flags)> paintFunction;
|
std::function<void(BitmapBuffer * dc, coord_t x, coord_t y, LcdFlags flags)> paintFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Line {
|
class Line
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit Line(uint8_t columnsCount):
|
explicit Line(uint8_t columnsCount):
|
||||||
cells(columnsCount, nullptr)
|
cells(columnsCount, nullptr)
|
||||||
@@ -122,7 +127,8 @@ class Table: public FormField
|
|||||||
LcdFlags flags = TABLE_BODY_FONT;
|
LcdFlags flags = TABLE_BODY_FONT;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Header: public Window, public Line {
|
class Header: public Window, public Line
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Header(Table * parent, const rect_t & rect, uint8_t columnsCount):
|
Header(Table * parent, const rect_t & rect, uint8_t columnsCount):
|
||||||
Window(parent, rect, OPAQUE),
|
Window(parent, rect, OPAQUE),
|
||||||
@@ -165,7 +171,7 @@ class Table: public FormField
|
|||||||
void addLine(Line * line)
|
void addLine(Line * line)
|
||||||
{
|
{
|
||||||
lines.push_back(line);
|
lines.push_back(line);
|
||||||
setInnerHeight(lines.size() * TABLE_LINE_HEIGHT - 2);
|
setInnerHeight((int)lines.size() * TABLE_LINE_HEIGHT - 2);
|
||||||
if (hasFocus() && selection < 0) {
|
if (hasFocus() && selection < 0) {
|
||||||
select(0, true);
|
select(0, true);
|
||||||
}
|
}
|
||||||
@@ -248,7 +254,7 @@ class Table: public FormField
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void deleteLater(bool detach = true, bool trash = true) override
|
void deleteLater(bool detach = true, bool trash = true) override // NOLINT(google-default-arguments)
|
||||||
{
|
{
|
||||||
if (_deleted)
|
if (_deleted)
|
||||||
return;
|
return;
|
||||||
@@ -261,7 +267,7 @@ class Table: public FormField
|
|||||||
|
|
||||||
void setColumnsWidth(const coord_t values[])
|
void setColumnsWidth(const coord_t values[])
|
||||||
{
|
{
|
||||||
int8_t restColumn = -1;
|
int restColumn = -1;
|
||||||
coord_t restWidth = width();
|
coord_t restWidth = width();
|
||||||
for (uint8_t i = 0; i < columnsCount; i++) {
|
for (uint8_t i = 0; i < columnsCount; i++) {
|
||||||
auto columnWidth = values[i];
|
auto columnWidth = values[i];
|
||||||
@@ -289,7 +295,7 @@ class Table: public FormField
|
|||||||
body.invalidate();
|
body.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFocus(uint8_t flag = SET_FOCUS_DEFAULT, Window * from = nullptr) override
|
void setFocus(uint8_t flag = SET_FOCUS_DEFAULT, Window * from = nullptr) override // NOLINT(google-default-arguments)
|
||||||
{
|
{
|
||||||
if (body.lines.empty()) {
|
if (body.lines.empty()) {
|
||||||
if (flag == SET_FOCUS_BACKWARD) {
|
if (flag == SET_FOCUS_BACKWARD) {
|
||||||
@@ -306,7 +312,7 @@ class Table: public FormField
|
|||||||
else {
|
else {
|
||||||
body.setFocus(flag, from);
|
body.setFocus(flag, from);
|
||||||
if (body.selection < 0) {
|
if (body.selection < 0) {
|
||||||
select(flag == SET_FOCUS_BACKWARD ? body.lines.size() - 1 : 0);
|
select(flag == SET_FOCUS_BACKWARD ? (int)body.lines.size() - 1 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user