aboutsummaryrefslogtreecommitdiff
path: root/src/ThemeBuilder/components/stylers/CompoundStylerEditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ThemeBuilder/components/stylers/CompoundStylerEditor.cpp')
-rw-r--r--src/ThemeBuilder/components/stylers/CompoundStylerEditor.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/ThemeBuilder/components/stylers/CompoundStylerEditor.cpp b/src/ThemeBuilder/components/stylers/CompoundStylerEditor.cpp
index c8b2a871..fb144e60 100644
--- a/src/ThemeBuilder/components/stylers/CompoundStylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/CompoundStylerEditor.cpp
@@ -6,13 +6,14 @@
#include "MarginStylerEditor.h"
#include "PaddingStylerEditor.h"
#include "PreferredSizeStylerEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
+#include "cru/platform/gui/DeleteLater.h"
#include "cru/ui/ThemeManager.h"
#include "cru/ui/style/Styler.h"
namespace cru::theme_builder::components::stylers {
CompoundStylerEditor::CompoundStylerEditor() {
- SetLabel(u"Compound Styler");
+ SetLabel("Compound Styler");
GetContainer()->AddChild(&children_container_);
children_container_.SetFlexDirection(ui::controls::FlexDirection::Vertical);
children_container_.SetItemCrossAlign(
@@ -21,16 +22,16 @@ CompoundStylerEditor::CompoundStylerEditor() {
GetHeadContainer()->AddChild(add_child_button_.GetRootControl());
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"Compound Styler", u"Border Styler",
- u"Cursor Styler", u"Content Brush Styler",
- u"Font Styler", u"Margin Styler",
- u"Padding Styler", u"Preferred Size Styler"});
+ add_child_button_.SetMenuItems({"Compound Styler", "Border Styler",
+ "Cursor Styler", "Content Brush Styler",
+ "Font Styler", "Margin Styler",
+ "Padding Styler", "Preferred Size Styler"});
add_child_button_.MenuItemSelectedEvent()->AddHandler([this](Index index) {
std::unique_ptr<StylerEditor> editor;
switch (index) {
@@ -64,12 +65,13 @@ CompoundStylerEditor::CompoundStylerEditor() {
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(editor->GetRootControl());
RaiseChangeEvent();
}
@@ -78,8 +80,8 @@ CompoundStylerEditor::CompoundStylerEditor() {
CompoundStylerEditor::~CompoundStylerEditor() {}
-ClonablePtr<ui::style::CompoundStyler> CompoundStylerEditor::GetValue() {
- std::vector<ClonablePtr<ui::style::Styler>> children_styler;
+ClonePtr<ui::style::CompoundStyler> CompoundStylerEditor::GetValue() {
+ std::vector<ClonePtr<ui::style::Styler>> children_styler;
for (auto& child : children_) {
children_styler.push_back(child->GetStyler());
}
@@ -93,12 +95,12 @@ void CompoundStylerEditor::SetValue(ui::style::CompoundStyler* value,
auto editor = CreateStylerEditor(styler.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());
}
}