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
6namespace Chesto {
7
8class AlertDialog : public Element {
9public:
10 AlertDialog(const std::string& title, const std::string& message);
11
12 void show();
13
14 // can be set by the user
15 std::string title;
16 std::string message;
17 std::function<void()> onConfirm;
18 std::function<void()> onCancel;
19 bool useAnimation = true;
20
21 void setText(const std::string& newText);
22
23 CST_Color blackColor = CST_Color{0, 0, 0, 0xff}; // default text color
24
25 // Raw pointers to children (owned by elements vector)
26 TextElement* messageText = nullptr;
27 Element* overlay = nullptr;
28 Container* vStack = nullptr;
29
30 // max sizes of the inner dialogue (not the whole screen-covering element)
31 int dialogWidth = 450;
32 int dialogHeight = 200;
33
34 // overridden lifecycle methods
35 virtual void render(Element* parent) override;
36 virtual bool process(InputEvents* event) override;
37};
38
39} // namespace Chesto
virtual void render(Element *parent) override
display the current state of the display
Definition: AlertDialog.cpp:95
virtual bool process(InputEvents *event) override
process any input that is received for this element
AlertDialog(const std::string &title, const std::string &message)
Definition: AlertDialog.cpp:8
Element * parent
the parent element (reference only, not owned)
Definition: Element.hpp:116