From fa1764d7cb77aa683c6049f915a46b981f9161f7 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 8 Feb 2022 21:13:01 +0800 Subject: ... --- include/cru/ui/controls/Control.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'include/cru/ui/controls/Control.h') 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 - 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& GetChildren() const { return children_; } + Index IndexOf(Control* child) const; // Traverse the tree rooted the control including itself. void TraverseDescendants(const std::function& 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; -- cgit v1.2.3