diff options
Diffstat (limited to 'src/theme_builder/components/stylers/CompoundStylerEditor.cpp')
-rw-r--r-- | src/theme_builder/components/stylers/CompoundStylerEditor.cpp | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/src/theme_builder/components/stylers/CompoundStylerEditor.cpp b/src/theme_builder/components/stylers/CompoundStylerEditor.cpp index f96a9a8f..6b8a5033 100644 --- a/src/theme_builder/components/stylers/CompoundStylerEditor.cpp +++ b/src/theme_builder/components/stylers/CompoundStylerEditor.cpp @@ -11,27 +11,6 @@ #include "cru/ui/style/Styler.h" namespace cru::theme_builder::components::stylers { -CompoundStylerEditorChild::CompoundStylerEditorChild( - std::unique_ptr<StylerEditor>&& editor) - : styler_editor_(std::move(editor)) { - container_.SetFlexDirection(ui::controls::FlexDirection::Horizontal); - container_.AddChild(&remove_button_); - - remove_button_.GetStyleRuleSet()->SetParent( - ui::ThemeManager::GetInstance()->GetResourceStyleRuleSet( - u"cru.theme_builder.icon-button.style")); - remove_button_.SetIconWithSvgPathDataStringResourceKey(u"icon.close", - {0, 0, 16, 16}); - remove_button_.SetIconFillColor(ui::colors::red); - - container_.AddChild(styler_editor_->GetRootControl()); - - remove_button_.ClickEvent()->AddSpyOnlyHandler( - [this] { this->remove_event_.Raise(nullptr); }); -} - -CompoundStylerEditorChild::~CompoundStylerEditorChild() {} - CompoundStylerEditor::CompoundStylerEditor() { SetLabel(u"Compound Styler"); GetContainer()->AddChild(&children_container_); @@ -84,16 +63,14 @@ CompoundStylerEditor::CompoundStylerEditor() { } if (editor) { ConnectChangeEvent(editor.get()); - auto child = - std::make_unique<CompoundStylerEditorChild>(std::move(editor)); - child->RemoveEvent()->AddSpyOnlyHandler([this, c = child.get()] { + editor->RemoveEvent()->AddSpyOnlyHandler([this, c = editor.get()] { auto index = this->children_container_.IndexOf(c->GetRootControl()); this->children_.erase(this->children_.begin() + index); this->children_container_.RemoveChildAt(index); RaiseChangeEvent(); }); - children_container_.AddChild(child->GetRootControl()); - children_.push_back(std::move(child)); + children_.push_back(std::move(editor)); + children_container_.AddChild(editor->GetRootControl()); RaiseChangeEvent(); } }); @@ -104,7 +81,7 @@ CompoundStylerEditor::~CompoundStylerEditor() {} ClonablePtr<ui::style::CompoundStyler> CompoundStylerEditor::GetValue() { std::vector<ClonablePtr<ui::style::Styler>> children_styler; for (auto& child : children_) { - children_styler.push_back(child->GetStylerEditor()->GetStyler()); + children_styler.push_back(child->GetStyler()); } return ui::style::CompoundStyler::Create(std::move(children_styler)); } @@ -115,14 +92,13 @@ void CompoundStylerEditor::SetValue(ui::style::CompoundStyler* value, for (const auto& styler : value->GetChildren()) { auto editor = CreateStylerEditor(styler.get()); ConnectChangeEvent(editor.get()); - auto child = std::make_unique<CompoundStylerEditorChild>(std::move(editor)); - child->RemoveEvent()->AddSpyOnlyHandler([this, c = child.get()] { + editor->RemoveEvent()->AddSpyOnlyHandler([this, c = editor.get()] { auto index = this->children_container_.IndexOf(c->GetRootControl()); this->children_.erase(this->children_.begin() + index); this->children_container_.RemoveChildAt(index); RaiseChangeEvent(); }); - children_.push_back(std::move(child)); + children_.push_back(std::move(editor)); children_container_.AddChild(children_.back()->GetRootControl()); } } |