aboutsummaryrefslogtreecommitdiff
path: root/src/ThemeBuilder/components/conditions/CompoundConditionEditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ThemeBuilder/components/conditions/CompoundConditionEditor.cpp')
-rw-r--r--src/ThemeBuilder/components/conditions/CompoundConditionEditor.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/ThemeBuilder/components/conditions/CompoundConditionEditor.cpp b/src/ThemeBuilder/components/conditions/CompoundConditionEditor.cpp
index 8be3aa0f..d84f05e2 100644
--- a/src/ThemeBuilder/components/conditions/CompoundConditionEditor.cpp
+++ b/src/ThemeBuilder/components/conditions/CompoundConditionEditor.cpp
@@ -4,9 +4,10 @@
#include "ConditionEditor.h"
#include "FocusConditionEditor.h"
#include "NoConditionEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/platform/Color.h"
#include "cru/ui/Base.h"
+#include "cru/platform/gui/DeleteLater.h"
#include "cru/ui/ThemeManager.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/style/Condition.h"
@@ -14,7 +15,7 @@
namespace cru::theme_builder::components::conditions {
CompoundConditionEditor::CompoundConditionEditor() {
- SetLabel(u"Compound Condition");
+ SetLabel("Compound Condition");
GetContainer()->AddChild(&children_container_);
children_container_.SetMargin({10, 0, 0, 0});
@@ -26,15 +27,15 @@ CompoundConditionEditor::CompoundConditionEditor() {
add_child_button_.GetButton()->GetStyleRuleSet()->SetParent(
ui::ThemeManager::GetInstance()->GetResourceStyleRuleSet(
- u"cru.theme_builder.icon-button.style"));
+ "cru.theme_builder.icon-button.style"));
add_child_button_.GetButton()->SetIconWithSvgPathDataStringResourceKey(
- u"icon.plus", {0, 0, 16, 16});
- add_child_button_.GetButton()->SetPreferredSize({24, 24});
+ "icon.plus", {0, 0, 16, 16});
+ add_child_button_.GetButton()->SetSuggestSize({24, 24});
add_child_button_.GetButton()->SetPadding(ui::Thickness(2));
add_child_button_.GetButton()->SetIconFillColor(ui::colors::green);
- add_child_button_.SetMenuItems({u"And Condition", u"Or Condition",
- u"Click State Condition", u"Focus Condition",
- u"Checked Condition", u"No Condition"});
+ add_child_button_.SetMenuItems({"And Condition", "Or Condition",
+ "Click State Condition", "Focus Condition",
+ "Checked Condition", "No Condition"});
add_child_button_.MenuItemSelectedEvent()->AddHandler([this](Index index) {
std::unique_ptr<ConditionEditor> editor;
switch (index) {
@@ -62,12 +63,13 @@ CompoundConditionEditor::CompoundConditionEditor() {
if (editor) {
ConnectChangeEvent(editor.get());
editor->RemoveEvent()->AddSpyOnlyHandler([this, c = editor.get()] {
- auto index = this->children_container_.IndexOf(c->GetRootControl());
+ auto index =
+ this->children_container_.IndexOfChild(c->GetRootControl());
this->children_.erase(this->children_.begin() + index);
this->children_container_.RemoveChildAt(index);
RaiseChangeEvent();
});
- children_.push_back(std::move(editor));
+ children_.push_back(platform::gui::ToDeleteLaterPtr(std::move(editor)));
children_container_.AddChild(children_.back()->GetRootControl());
RaiseChangeEvent();
}
@@ -76,9 +78,9 @@ CompoundConditionEditor::CompoundConditionEditor() {
CompoundConditionEditor::~CompoundConditionEditor() {}
-std::vector<ClonablePtr<ui::style::Condition>>
+std::vector<ClonePtr<ui::style::Condition>>
CompoundConditionEditor::GetChildren() {
- std::vector<ClonablePtr<ui::style::Condition>> children;
+ std::vector<ClonePtr<ui::style::Condition>> children;
for (auto& child : children_) {
children.push_back(child->GetCondition());
}
@@ -86,20 +88,19 @@ CompoundConditionEditor::GetChildren() {
}
void CompoundConditionEditor::SetChildren(
- std::vector<ClonablePtr<ui::style::Condition>> children,
- bool trigger_change) {
- children_container_.ClearChildren();
+ std::vector<ClonePtr<ui::style::Condition>> children, bool trigger_change) {
+ children_container_.RemoveAllChild();
children_.clear();
for (const auto& condition : children) {
auto editor = CreateConditionEditor(condition.get());
ConnectChangeEvent(editor.get());
editor->RemoveEvent()->AddSpyOnlyHandler([this, c = editor.get()] {
- auto index = this->children_container_.IndexOf(c->GetRootControl());
+ auto index = this->children_container_.IndexOfChild(c->GetRootControl());
this->children_.erase(this->children_.begin() + index);
this->children_container_.RemoveChildAt(index);
RaiseChangeEvent();
});
- children_.push_back(std::move(editor));
+ children_.push_back(platform::gui::ToDeleteLaterPtr(std::move(editor)));
children_container_.AddChild(children_.back()->GetRootControl());
}
if (trigger_change) {