aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-08 21:13:01 +0800
committercrupest <crupest@outlook.com>2022-02-08 21:13:01 +0800
commitfa1764d7cb77aa683c6049f915a46b981f9161f7 (patch)
treee5b54620d3b84f5391e995ab483647214152ca99 /include/cru/ui
parent74bb9cd27242b9320f99ff4d2b50c3051576cc14 (diff)
downloadcru-fa1764d7cb77aa683c6049f915a46b981f9161f7.tar.gz
cru-fa1764d7cb77aa683c6049f915a46b981f9161f7.tar.bz2
cru-fa1764d7cb77aa683c6049f915a46b981f9161f7.zip
...
Diffstat (limited to 'include/cru/ui')
-rw-r--r--include/cru/ui/controls/Control.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/cru/ui/controls/Control.h b/include/cru/ui/controls/Control.h
index c00e3a65..edbf5919 100644
--- a/include/cru/ui/controls/Control.h
+++ b/include/cru/ui/controls/Control.h
@@ -5,8 +5,6 @@
#include "../render/Base.h"
#include "cru/common/Event.h"
-#include <string_view>
-
namespace cru::ui::controls {
class CRU_UI_API Control : public Object {
friend host::WindowHost;
@@ -31,10 +29,18 @@ class CRU_UI_API Control : public Object {
Control* GetParent() const { return parent_; }
const std::vector<Control*>& GetChildren() const { return children_; }
+ Index IndexOf(Control* child) const;
// Traverse the tree rooted the control including itself.
void TraverseDescendants(const std::function<void(Control*)>& predicate);
+ bool IsAutoDeleteChildren() const { return auto_delete_children_; }
+ void SetAutoDeleteChildren(bool auto_delete_children) {
+ auto_delete_children_ = auto_delete_children;
+ }
+
+ void RemoveFromParent();
+
public:
virtual render::RenderObject* GetRenderObject() const = 0;
@@ -146,6 +152,8 @@ class CRU_UI_API Control : public Object {
host::WindowHost* window_host_ = nullptr;
+ bool auto_delete_children_ = true;
+
private:
bool is_mouse_over_ = false;