From c2d8042182a2815ac678d1b9f26608c5ac260244 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Thu, 2 Dec 2021 11:16:07 +0100 Subject: [PATCH] Added example buttons --- main/displays/popups/alertdisplay.cpp | 36 +++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/main/displays/popups/alertdisplay.cpp b/main/displays/popups/alertdisplay.cpp index ac8799c..f1c4c4f 100644 --- a/main/displays/popups/alertdisplay.cpp +++ b/main/displays/popups/alertdisplay.cpp @@ -33,17 +33,20 @@ void AlertDisplay::initOverlay() constexpr auto topMargin = 50; constexpr auto bottomMargin = topMargin; + const auto width = espgui::tft.width() - leftMargin - rightMargin; + const auto height = espgui::tft.height() - topMargin - bottomMargin; + const auto right = espgui::tft.width() - rightMargin; + const auto bottom = espgui::tft.height() - bottomMargin; + //espgui::tft.drawRect(leftMargin, topMargin, espgui::tft.width() - leftMargin - rightMargin, espgui::tft.height() - topMargin - bottomMargin, TFT_WHITE); //espgui::tft.fillRect(leftMargin + 1, topMargin + 1, espgui::tft.width() - leftMargin - rightMargin - 2, espgui::tft.height() - topMargin - bottomMargin - 2, TFT_BLACK); - espgui::tft.drawSunkenRect(leftMargin, topMargin, - espgui::tft.width() - leftMargin - rightMargin, - espgui::tft.height() - topMargin - bottomMargin, + espgui::tft.drawSunkenRect(leftMargin, topMargin, width, height, espgui::tft.color565(240, 240, 240), espgui::tft.color565(100, 100, 100), - espgui::tft.color565(40, 40, 40)); + espgui::tft.color565(30, 30, 30)); - espgui::tft.setTextColor(TFT_WHITE, espgui::tft.color565(40, 40, 40)); + espgui::tft.setTextColor(TFT_WHITE, espgui::tft.color565(30, 30, 30)); int x = leftMargin + 5; int y = topMargin + 5; @@ -60,7 +63,30 @@ void AlertDisplay::initOverlay() const auto addedWidth = espgui::tft.drawChar(espgui::tft.decodeUTF8(c), x, y, 4); x += addedWidth; } + + if (y >= espgui::tft.height() - bottomMargin) + break; } + + espgui::tft.setTextColor(TFT_BLACK, espgui::tft.color565(170, 170, 170)); + + espgui::tft.drawSunkenRect(leftMargin + 15, bottom - 40, + (width - 15 - 10 - 15) / 2, + 30, + espgui::tft.color565(240, 240, 240), + espgui::tft.color565(100, 100, 100), + espgui::tft.color565(170, 170, 170)); + + espgui::tft.drawString("Yes", leftMargin + 16, bottom - 39); + + espgui::tft.drawSunkenRect(leftMargin + 15 + ((width - 15 - 30 - 15) / 2) + 15, bottom - 40, + (width - 15 - 10 - 15) / 2, + 30, + espgui::tft.color565(240, 240, 240), + espgui::tft.color565(100, 100, 100), + espgui::tft.color565(170, 170, 170)); + + espgui::tft.drawString("No", leftMargin + 15 + ((width - 15 - 30 - 15) / 2) + 15 + 1, bottom - 39); } void AlertDisplay::closeOverlay()