diff options
author | crupest <crupest@outlook.com> | 2022-02-16 20:22:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-16 20:22:25 +0800 |
commit | 3cd44092c44651650a760752a3d374f610ca4f77 (patch) | |
tree | d3481e8d93d8d47674d0df46eb765ccf9100bca8 /src/theme_builder/components/conditions/CompoundConditionEditor.cpp | |
parent | 6459edc7c8af9e5c9bafe4f1635194334f42f415 (diff) | |
download | cru-3cd44092c44651650a760752a3d374f610ca4f77.tar.gz cru-3cd44092c44651650a760752a3d374f610ca4f77.tar.bz2 cru-3cd44092c44651650a760752a3d374f610ca4f77.zip |
...
Diffstat (limited to 'src/theme_builder/components/conditions/CompoundConditionEditor.cpp')
-rw-r--r-- | src/theme_builder/components/conditions/CompoundConditionEditor.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/theme_builder/components/conditions/CompoundConditionEditor.cpp b/src/theme_builder/components/conditions/CompoundConditionEditor.cpp index 511fffdd..76198dc0 100644 --- a/src/theme_builder/components/conditions/CompoundConditionEditor.cpp +++ b/src/theme_builder/components/conditions/CompoundConditionEditor.cpp @@ -38,29 +38,36 @@ CompoundConditionEditor::CompoundConditionEditor() { u"Checked Condtion", }); add_child_button_.MenuItemSelectedEvent()->AddHandler([this](Index index) { - std::unique_ptr<ConditionEditor> child; + std::unique_ptr<ConditionEditor> editor; switch (index) { case 0: - child = std::make_unique<AndConditionEditor>(); + editor = std::make_unique<AndConditionEditor>(); break; case 1: - child = std::make_unique<OrConditionEditor>(); + editor = std::make_unique<OrConditionEditor>(); break; case 2: - child = std::make_unique<ClickStateConditionEditor>(); + editor = std::make_unique<ClickStateConditionEditor>(); break; case 3: - child = std::make_unique<FocusConditionEditor>(); + editor = std::make_unique<FocusConditionEditor>(); break; case 4: - child = std::make_unique<CheckedConditionEditor>(); + editor = std::make_unique<CheckedConditionEditor>(); break; default: break; } - if (child) { - auto c = std::make_unique<CompoundConditionEditorChild>(std::move(child)); - children_.push_back(std::move(c)); + if (editor) { + auto child = + std::make_unique<CompoundConditionEditorChild>(std::move(editor)); + child->RemoveEvent()->AddSpyOnlyHandler([this, c = child.get()] { + auto index = this->children_container_.IndexOf(c->GetRootControl()); + this->children_.erase(this->children_.begin() + index); + this->children_container_.RemoveChildAt(index); + change_event_.Raise(nullptr); + }); + children_.push_back(std::move(child)); children_container_.AddChild(children_.back()->GetRootControl()); change_event_.Raise(nullptr); } |