From 3cd44092c44651650a760752a3d374f610ca4f77 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 16 Feb 2022 20:22:25 +0800 Subject: ... --- .../conditions/CompoundConditionEditor.cpp | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/theme_builder/components/conditions/CompoundConditionEditor.cpp') 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 child; + std::unique_ptr editor; switch (index) { case 0: - child = std::make_unique(); + editor = std::make_unique(); break; case 1: - child = std::make_unique(); + editor = std::make_unique(); break; case 2: - child = std::make_unique(); + editor = std::make_unique(); break; case 3: - child = std::make_unique(); + editor = std::make_unique(); break; case 4: - child = std::make_unique(); + editor = std::make_unique(); break; default: break; } - if (child) { - auto c = std::make_unique(std::move(child)); - children_.push_back(std::move(c)); + if (editor) { + auto child = + std::make_unique(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); } -- cgit v1.2.3