From 6b4edc9be8ec556147c195cf2047d92b9439efd7 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Tue, 18 Nov 2025 00:46:27 +0800 Subject: Bring back ControlHost and refactor tree management of control. --- include/cru/ui/controls/TreeView.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include/cru/ui/controls/TreeView.h') diff --git a/include/cru/ui/controls/TreeView.h b/include/cru/ui/controls/TreeView.h index f4938259..62b1c69b 100644 --- a/include/cru/ui/controls/TreeView.h +++ b/include/cru/ui/controls/TreeView.h @@ -48,6 +48,11 @@ class CRU_UI_API TreeViewItem : public Object { }; class CRU_UI_API TreeView : public Control { + friend TreeViewItem; + + private: + using Control::AddChild; + public: constexpr static std::string_view kControlType = "TreeView"; @@ -61,11 +66,11 @@ class CRU_UI_API TreeView : public Control { } render::TreeRenderObject* GetRenderObject() { return &render_object_; } - void ForEachChild(const std::function& predicate) override; - void RemoveChild(Control* control) override; - TreeViewItem* GetRootItem() { return &root_item_; } + protected: + void OnChildRemoved(Control* control, Index index) override; + private: render::TreeRenderObject render_object_; TreeViewItem root_item_; -- cgit v1.2.3