Chesto 0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
AlertDialog.hpp
1#include <string>
2#include <functional>
3#include "TextElement.hpp"
4#include "Container.hpp"
5
6class AlertDialog : public Element {
7public:
8 AlertDialog(const std::string& title, const std::string& message);
9
10 void show();
11
12 // can be set by the user
13 std::string title;
14 std::string message;
15 std::function<void()> onConfirm;
16 std::function<void()> onCancel;
17 bool useAnimation = true;
18
19 void setText(const std::string& newText);
20
21 CST_Color blackColor = CST_Color{0, 0, 0, 0xff}; // default text color
22 TextElement* messageText = new TextElement("(Placeholder text)", 20, &blackColor, NORMAL, 400);
23 Element* overlay = new Element();
24 Container* vStack = new Container(COL_LAYOUT, 50);
25
26 // max sizes of the inner dialogue (not the whole screen-covering element)
27 int dialogWidth = 450;
28 int dialogHeight = 200;
29
30 // overridden lifecycle methods
31 virtual void render(Element* parent) override;
32 virtual bool process(InputEvents* event) override;
33};
virtual bool process(InputEvents *event) override
process any input that is received for this element
virtual void render(Element *parent) override
display the current state of the display
Definition: AlertDialog.cpp:97
AlertDialog(const std::string &title, const std::string &message)
Definition: AlertDialog.cpp:6
Element * parent
the parent element (can sometimes be null if it isn't set)
Definition: Element.hpp:107