From a16fe0a89e6b70e8555bad95472c4e638fca45f0 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 18 May 2020 12:39:46 +0200 Subject: [PATCH] Possibility to have a different font style for all table lines --- radio/src/thirdparty/libopenui/src/table.cpp | 2 +- radio/src/thirdparty/libopenui/src/table.h | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/table.cpp b/radio/src/thirdparty/libopenui/src/table.cpp index 10eaa991e..af683af4e 100644 --- a/radio/src/thirdparty/libopenui/src/table.cpp +++ b/radio/src/thirdparty/libopenui/src/table.cpp @@ -41,7 +41,7 @@ void Table::Body::paint(BitmapBuffer * dc) dc->drawSolidFilledRect(0, y, width(), TABLE_LINE_HEIGHT - 2, index == selection ? MENU_HIGHLIGHT_BGCOLOR : TABLE_BGCOLOR); x = 10; for (unsigned i = 0; i < line.values.size(); i++) { - dc->drawText(x, y + (TABLE_LINE_HEIGHT - getFontHeight(TABLE_BODY_FONT)) / 2 + 3, line.values[i].c_str(), TABLE_BODY_FONT | (index == selection ? MENU_HIGHLIGHT_COLOR : DEFAULT_COLOR)); + dc->drawText(x, y + (TABLE_LINE_HEIGHT - getFontHeight(TABLE_BODY_FONT)) / 2 + 3, line.values[i].c_str(), line.flags | (index == selection ? MENU_HIGHLIGHT_COLOR : DEFAULT_COLOR)); x += columnsWidth[i]; } y += TABLE_LINE_HEIGHT; diff --git a/radio/src/thirdparty/libopenui/src/table.h b/radio/src/thirdparty/libopenui/src/table.h index 19d4a7140..ff7a3b56a 100644 --- a/radio/src/thirdparty/libopenui/src/table.h +++ b/radio/src/thirdparty/libopenui/src/table.h @@ -35,6 +35,7 @@ class Table: public Window { std::vector values; std::function onPress; std::function onSelect; + LcdFlags flags = TABLE_BODY_FONT; }; class Header: public Window { @@ -88,6 +89,11 @@ class Table: public Window { setInnerHeight(lines.size() * TABLE_LINE_HEIGHT - 2); } + void setLineFlags(uint8_t index, LcdFlags flags) + { + lines[index].flags = flags; + } + void clear() { lines.clear(); @@ -175,6 +181,11 @@ class Table: public Window { body.select(index, scroll); } + void setLineFlags(uint8_t index, LcdFlags flags) + { + body.setLineFlags(index, flags); + } + void setHeader(const char * const values[]) { header.setHeight(TABLE_HEADER_HEIGHT); @@ -204,7 +215,7 @@ class Table: public Window { clearSelection(); } - int size() + uint8_t size() { return body.lines.size(); }