diff options
author | crupest <crupest@outlook.com> | 2022-02-08 21:45:10 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-08 21:45:10 +0800 |
commit | ae2a748403f3a4879a759820f7a445e41ee5f9df (patch) | |
tree | 20076f0366fcd7b4c60626ac687bb6b06b9399b8 | |
parent | 5d7dcef619bd1f866684b57351dde2efbda6959c (diff) | |
download | cru-ae2a748403f3a4879a759820f7a445e41ee5f9df.tar.gz cru-ae2a748403f3a4879a759820f7a445e41ee5f9df.tar.bz2 cru-ae2a748403f3a4879a759820f7a445e41ee5f9df.zip |
...
-rw-r--r-- | include/cru/ui/components/Component.h | 8 | ||||
-rw-r--r-- | src/theme_builder/components/StyleRuleEditor.cpp | 5 | ||||
-rw-r--r-- | src/theme_builder/components/StyleRuleSetEditor.cpp | 15 |
3 files changed, 19 insertions, 9 deletions
diff --git a/include/cru/ui/components/Component.h b/include/cru/ui/components/Component.h index 0b871dc4..e889ae97 100644 --- a/include/cru/ui/components/Component.h +++ b/include/cru/ui/components/Component.h @@ -2,9 +2,11 @@ #include "../Base.h" namespace cru::ui::components { -// In destructor, component should check all owned controls whether it is -// attached to window, if not, destroy them, otherwise it is host's duty to -// destroy them. +/** + * \remarks In destructor, component should first delete all child components + * and then remove root control from its parent (by calling + * Control::RemoveFromParent). Then delete all its root control. + */ class CRU_UI_API Component : public Object { public: Component() = default; diff --git a/src/theme_builder/components/StyleRuleEditor.cpp b/src/theme_builder/components/StyleRuleEditor.cpp index 8b9df6db..1cbeaeb2 100644 --- a/src/theme_builder/components/StyleRuleEditor.cpp +++ b/src/theme_builder/components/StyleRuleEditor.cpp @@ -5,7 +5,10 @@ StyleRuleEditor::StyleRuleEditor() { main_layout_ = ui::controls::FlexLayout::Create(); } -StyleRuleEditor::~StyleRuleEditor() {} +StyleRuleEditor::~StyleRuleEditor() { + main_layout_->RemoveFromParent(); + delete main_layout_; +} void StyleRuleEditor::BindStyleRule(ui::style::StyleRule *rule) { style_rule_ = rule; diff --git a/src/theme_builder/components/StyleRuleSetEditor.cpp b/src/theme_builder/components/StyleRuleSetEditor.cpp index cfb2ad56..313b53da 100644 --- a/src/theme_builder/components/StyleRuleSetEditor.cpp +++ b/src/theme_builder/components/StyleRuleSetEditor.cpp @@ -1,9 +1,16 @@ #include "StyleRuleSetEditor.h" +#include "cru/ui/controls/FlexLayout.h" namespace cru::theme_builder { -StyleRuleSetEditor::StyleRuleSetEditor() {} +using namespace cru::ui::controls; +StyleRuleSetEditor::StyleRuleSetEditor() { + main_layout_ = FlexLayout::Create(); +} -StyleRuleSetEditor::~StyleRuleSetEditor() {} +StyleRuleSetEditor::~StyleRuleSetEditor() { + main_layout_->RemoveFromParent(); + delete main_layout_; +} void StyleRuleSetEditor::BindStyleRuleSet( std::shared_ptr<ui::style::StyleRuleSet> rule_set) { @@ -11,7 +18,5 @@ void StyleRuleSetEditor::BindStyleRuleSet( UpdateView(); } -void StyleRuleSetEditor::UpdateView() { - -} +void StyleRuleSetEditor::UpdateView() {} } // namespace cru::theme_builder |