alert flow text
This commit is contained in:
Submodule components/TFT_eSPI updated: 5731f928f6...aa7279cb29
@ -35,7 +35,7 @@ public:
|
||||
std::string text() const override { return "Open popup"; }
|
||||
void triggered() override
|
||||
{
|
||||
auto newDisplay = std::make_unique<AlertDisplay>(std::move(currentDisplay));
|
||||
auto newDisplay = std::make_unique<AlertDisplay>("Das\nist\nein sehr langer text, der nicht in eine zeile passt", std::move(currentDisplay));
|
||||
newDisplay->initOverlay();
|
||||
currentDisplay = std::move(newDisplay);
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <tftinstance.h>
|
||||
#include <screenmanager.h>
|
||||
|
||||
AlertDisplay::AlertDisplay(std::unique_ptr<Display> &&lastDisplay) :
|
||||
m_lastDisplay{std::move(lastDisplay)}
|
||||
AlertDisplay::AlertDisplay(std::string &&message, std::unique_ptr<Display> &&lastDisplay) :
|
||||
m_message{std::move(message)}, m_lastDisplay{std::move(lastDisplay)}
|
||||
{
|
||||
}
|
||||
|
||||
@ -28,14 +28,39 @@ void AlertDisplay::back()
|
||||
|
||||
void AlertDisplay::initOverlay()
|
||||
{
|
||||
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
constexpr auto leftMargin = 20;
|
||||
constexpr auto rightMargin = leftMargin;
|
||||
constexpr auto topMargin = 50;
|
||||
constexpr auto bottomMargin = topMargin;
|
||||
|
||||
espgui::tft.drawRect(20, 50, espgui::tft.width() - 40, espgui::tft.height() - 100, TFT_WHITE);
|
||||
espgui::tft.fillRect(21, 51, espgui::tft.width() - 42, espgui::tft.height() - 102, TFT_BLACK);
|
||||
//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.drawString("oida", 25, 60);
|
||||
espgui::tft.drawString("oida", 25, 85);
|
||||
espgui::tft.drawString("oida", 25, 110);
|
||||
espgui::tft.drawSunkenRect(leftMargin, topMargin,
|
||||
espgui::tft.width() - leftMargin - rightMargin,
|
||||
espgui::tft.height() - topMargin - bottomMargin,
|
||||
espgui::tft.color565(240, 240, 240),
|
||||
espgui::tft.color565(100, 100, 100),
|
||||
espgui::tft.color565(40, 40, 40));
|
||||
|
||||
espgui::tft.setTextColor(TFT_WHITE, espgui::tft.color565(40, 40, 40));
|
||||
|
||||
int x = leftMargin + 5;
|
||||
int y = topMargin + 5;
|
||||
for (char c : m_message)
|
||||
{
|
||||
if (c == '\n' || x > espgui::tft.width() - rightMargin - 10)
|
||||
{
|
||||
x = leftMargin + 5;
|
||||
y += espgui::tft.fontHeight(4);
|
||||
}
|
||||
|
||||
if (c != '\n')
|
||||
{
|
||||
const auto addedWidth = espgui::tft.drawChar(espgui::tft.decodeUTF8(c), x, y, 4);
|
||||
x += addedWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AlertDisplay::closeOverlay()
|
||||
|
@ -9,7 +9,7 @@
|
||||
class AlertDisplay : public espgui::Display
|
||||
{
|
||||
public:
|
||||
AlertDisplay(std::unique_ptr<Display> &&lastDisplay);
|
||||
AlertDisplay(std::string &&message, std::unique_ptr<Display> &&lastDisplay);
|
||||
|
||||
//void start() override;
|
||||
void initScreen() override;
|
||||
@ -23,5 +23,6 @@ public:
|
||||
void closeOverlay();
|
||||
|
||||
private:
|
||||
std::string m_message;
|
||||
std::unique_ptr<Display> m_lastDisplay;
|
||||
};
|
||||
|
Reference in New Issue
Block a user