summaryrefslogtreecommitdiff
path: root/ui.hpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-01-01 10:37:17 +1100
committerquou <quou@disroot.org>2025-01-01 10:44:04 +1100
commit076c83525ff33a756bf1aac63fe202f5e02c86b0 (patch)
tree98c8f8a24d4b7cfd49452edf94ffde50079c3335 /ui.hpp
parent7c2ccfdb31d4e8e74830f9d0b91e4ab0d9913065 (diff)
UI tree
Diffstat (limited to 'ui.hpp')
-rw-r--r--ui.hpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/ui.hpp b/ui.hpp
index adb1ba8..abb4f69 100644
--- a/ui.hpp
+++ b/ui.hpp
@@ -177,6 +177,7 @@ struct UI {
void update();
virtual void on_update();
virtual void on_render();
+ virtual void on_add_child(Element* nch);
virtual void on_message(const Message& msg);
void add_child(Element* ch);
@@ -204,14 +205,6 @@ struct UI {
void on_render() override;
};
- struct Button : Element {
- char* text;
- Button(UI* ui, Element* parent, const char* label);
- ~Button();
- Rect layout(const Rect& avail) override;
- void on_render() override;
- };
-
struct Label : Element {
char* text;
Label(UI* ui, Element* parent, const char* label);
@@ -222,6 +215,12 @@ struct UI {
void set_text(const char* s);
};
+ struct Button : Label {
+ Button(UI* ui, Element* parent, const char* label);
+ Rect layout(const Rect& avail) override;
+ void on_render() override;
+ };
+
struct Modal : Element {
Container* contents;
Toolbar* title_bar;
@@ -236,6 +235,20 @@ struct UI {
void on_update() override;
void bring_to_front();
};
+
+ struct Tree : Element {
+ Element* collapsed; /* <- children are moved here when it's collapsed so they stop layout'ing and rendering! */
+ Button* expandbtn;
+ Label* text;
+ Tree(UI* ui, Element* parent, const char* text);
+ Rect layout(const Rect& avail) override;
+ void on_render() override;
+ void on_update() override;
+ void on_add_child(Element* child) override;
+ void expand();
+ void collapse();
+ bool is_leaf() const;
+ };
};
#endif