From bfd277f9f621931a1c6ea05ea2cd6d04455cfe67 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 18 Mar 2020 22:40:20 +0800 Subject: ... --- include/cru/ui/controls/container.hpp | 3 +++ src/ui/controls/container.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/cru/ui/controls/container.hpp b/include/cru/ui/controls/container.hpp index d6aa5635..7d4c0d23 100644 --- a/include/cru/ui/controls/container.hpp +++ b/include/cru/ui/controls/container.hpp @@ -19,6 +19,9 @@ class Container : public ContentControl { render::RenderObject* GetRenderObject() const override; + protected: + void OnChildChanged(Control* old_child, Control* new_child) override; + private: std::unique_ptr render_object_; }; diff --git a/src/ui/controls/container.cpp b/src/ui/controls/container.cpp index 2075d4ba..4695ad4c 100644 --- a/src/ui/controls/container.cpp +++ b/src/ui/controls/container.cpp @@ -9,5 +9,10 @@ Container::Container() { render_object_->SetBorderEnabled(false); } -Container::~Container() {} +Container::~Container() = default; + +void Container::OnChildChanged(Control* old_child, Control* new_child) { + render_object_->RemoveChild(0); + render_object_->AddChild(new_child->GetRenderObject(), 0); +} } // namespace cru::ui::controls -- cgit v1.2.3