From b983070b4d58574c735c0ef7db05021561ef135f Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 5 Sep 2021 21:10:33 +0200 Subject: [PATCH] Richtext now supports more colors, fixed menudisplay selection box overdraw --- src/changevaluedisplay.cpp | 2 +- src/menudisplay.cpp | 4 ++-- src/menudisplay.h | 6 +++--- src/richtextrenderer.cpp | 18 +++++++++++++----- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/changevaluedisplay.cpp b/src/changevaluedisplay.cpp index d4df3ef..cb4df1c 100644 --- a/src/changevaluedisplay.cpp +++ b/src/changevaluedisplay.cpp @@ -7,7 +7,7 @@ void ChangeValueDisplayInterface::initScreen() m_titleLabel.start(); - tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE); + tft.fillRect(0, 33, tft.width(), 3, TFT_WHITE); tft.drawRect(25, 75, 190, 65, TFT_WHITE); m_valueLabel.start(); diff --git a/src/menudisplay.cpp b/src/menudisplay.cpp index 779775f..e4ea8da 100644 --- a/src/menudisplay.cpp +++ b/src/menudisplay.cpp @@ -18,7 +18,7 @@ void MenuDisplay::initScreen() tft.fillScreen(TFT_BLACK); m_titleLabel.start(); - tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE); + tft.fillRect(0, 33, tft.width(), 3, TFT_WHITE); for (auto &label : m_labels) label.start(); @@ -94,7 +94,7 @@ void MenuDisplay::redraw() tft.drawRect(5, label.y()-1, tft.width() - 10, - lineHeight+2, + lineHeight+1, color); }; diff --git a/src/menudisplay.h b/src/menudisplay.h index 3181c2c..bd6147f 100644 --- a/src/menudisplay.h +++ b/src/menudisplay.h @@ -99,9 +99,9 @@ private: static constexpr size_t rowCount = CONFIG_ESPGUI_MENUDISPLAY_ROWS; static constexpr auto iconWidth = 25; static constexpr auto horizontalSpacing = 10; - static constexpr auto topMargin = 40; - static constexpr auto lineHeight = 25; - static constexpr auto verticalSpacing = 4; + static constexpr auto topMargin = 39; + static constexpr auto lineHeight = 27; + static constexpr auto verticalSpacing = 2; std::array m_labels {{ #if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 1 diff --git a/src/richtextrenderer.cpp b/src/richtextrenderer.cpp index 5224948..9e03002 100644 --- a/src/richtextrenderer.cpp +++ b/src/richtextrenderer.cpp @@ -28,7 +28,7 @@ int16_t renderRichText(std::string_view str, int32_t poX, int32_t poY, uint8_t f if (str.empty()) return 0; - const auto oldColor = tft.textcolor; + const uint16_t oldColor = tft.textcolor; int16_t width{}; @@ -53,13 +53,21 @@ again: case '0': case '1': case '2': + case '3': + case '4': + case '5': + case '6': { - const auto color = [&controlChar](){ + const auto color = [&controlChar,&oldColor](){ switch (controlChar) { - case '0': return TFT_RED; - case '1': return TFT_GREEN; - case '2': return TFT_BLUE; + case '0': return oldColor; + case '1': return TFT_RED; + case '2': return TFT_GREEN; + case '3': return TFT_BLUE; + case '4': return TFT_BLACK; + case '5': return TFT_WHITE; + case '6': return TFT_GREY; } __builtin_unreachable(); }();