aboutsummaryrefslogtreecommitdiff
path: root/src/ThemeBuilder
diff options
context:
space:
mode:
Diffstat (limited to 'src/ThemeBuilder')
-rw-r--r--src/ThemeBuilder/CMakeLists.txt2
-rw-r--r--src/ThemeBuilder/components/HeadBodyEditor.cpp4
-rw-r--r--src/ThemeBuilder/components/HeadBodyEditor.h9
-rw-r--r--src/ThemeBuilder/components/LabeledMixin.h13
-rw-r--r--src/ThemeBuilder/components/MainWindow.cpp4
-rw-r--r--src/ThemeBuilder/components/StyleRuleEditor.cpp8
-rw-r--r--src/ThemeBuilder/components/StyleRuleSetEditor.cpp29
-rw-r--r--src/ThemeBuilder/components/StyleRuleSetEditor.h6
-rw-r--r--src/ThemeBuilder/components/conditions/CheckedConditionEditor.cpp9
-rw-r--r--src/ThemeBuilder/components/conditions/CheckedConditionEditor.h10
-rw-r--r--src/ThemeBuilder/components/conditions/ClickStateConditionEditor.cpp19
-rw-r--r--src/ThemeBuilder/components/conditions/ClickStateConditionEditor.h11
-rw-r--r--src/ThemeBuilder/components/conditions/CompoundConditionEditor.cpp35
-rw-r--r--src/ThemeBuilder/components/conditions/CompoundConditionEditor.h32
-rw-r--r--src/ThemeBuilder/components/conditions/ConditionEditor.cpp3
-rw-r--r--src/ThemeBuilder/components/conditions/ConditionEditor.h2
-rw-r--r--src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp8
-rw-r--r--src/ThemeBuilder/components/conditions/FocusConditionEditor.h10
-rw-r--r--src/ThemeBuilder/components/conditions/NoConditionEditor.cpp2
-rw-r--r--src/ThemeBuilder/components/conditions/NoConditionEditor.h4
-rw-r--r--src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h10
-rw-r--r--src/ThemeBuilder/components/properties/ColorPropertyEditor.cpp2
-rw-r--r--src/ThemeBuilder/components/properties/ColorPropertyEditor.h10
-rw-r--r--src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp10
-rw-r--r--src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.h2
-rw-r--r--src/ThemeBuilder/components/properties/FontPropertyEditor.cpp8
-rw-r--r--src/ThemeBuilder/components/properties/FontPropertyEditor.h9
-rw-r--r--src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp12
-rw-r--r--src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h12
-rw-r--r--src/ThemeBuilder/components/properties/OptionalPropertyEditor.h12
-rw-r--r--src/ThemeBuilder/components/properties/PointPropertyEditor.cpp9
-rw-r--r--src/ThemeBuilder/components/properties/PointPropertyEditor.h12
-rw-r--r--src/ThemeBuilder/components/properties/SelectPropertyEditor.h16
-rw-r--r--src/ThemeBuilder/components/properties/TextPropertyEditor.cpp7
-rw-r--r--src/ThemeBuilder/components/properties/TextPropertyEditor.h17
-rw-r--r--src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp6
-rw-r--r--src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h10
-rw-r--r--src/ThemeBuilder/components/stylers/BorderStylerEditor.cpp20
-rw-r--r--src/ThemeBuilder/components/stylers/BorderStylerEditor.h8
-rw-r--r--src/ThemeBuilder/components/stylers/CompoundStylerEditor.cpp32
-rw-r--r--src/ThemeBuilder/components/stylers/CompoundStylerEditor.h12
-rw-r--r--src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp3
-rw-r--r--src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.h7
-rw-r--r--src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp8
-rw-r--r--src/ThemeBuilder/components/stylers/CursorStylerEditor.h6
-rw-r--r--src/ThemeBuilder/components/stylers/FontStylerEditor.cpp4
-rw-r--r--src/ThemeBuilder/components/stylers/FontStylerEditor.h7
-rw-r--r--src/ThemeBuilder/components/stylers/MarginStylerEditor.cpp6
-rw-r--r--src/ThemeBuilder/components/stylers/MarginStylerEditor.h8
-rw-r--r--src/ThemeBuilder/components/stylers/PaddingStylerEditor.cpp6
-rw-r--r--src/ThemeBuilder/components/stylers/PaddingStylerEditor.h8
-rw-r--r--src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.cpp12
-rw-r--r--src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.h8
-rw-r--r--src/ThemeBuilder/components/stylers/StylerEditor.cpp3
-rw-r--r--src/ThemeBuilder/components/stylers/StylerEditor.h2
55 files changed, 245 insertions, 299 deletions
diff --git a/src/ThemeBuilder/CMakeLists.txt b/src/ThemeBuilder/CMakeLists.txt
index 5e49cf78..93b24e85 100644
--- a/src/ThemeBuilder/CMakeLists.txt
+++ b/src/ThemeBuilder/CMakeLists.txt
@@ -40,4 +40,6 @@ if(APPLE)
)
endif()
+target_add_resources(CruThemeBuilder cru/ui)
+target_add_resources(CruThemeBuilder cru/theme_builder)
target_link_libraries(CruThemeBuilder PRIVATE CruPlatformBootstrap CruUi)
diff --git a/src/ThemeBuilder/components/HeadBodyEditor.cpp b/src/ThemeBuilder/components/HeadBodyEditor.cpp
index 6d7ace66..3cc71d53 100644
--- a/src/ThemeBuilder/components/HeadBodyEditor.cpp
+++ b/src/ThemeBuilder/components/HeadBodyEditor.cpp
@@ -16,8 +16,8 @@ HeadBodyEditor::HeadBodyEditor() {
remove_button_.GetStyleRuleSet()->SetParent(
ui::ThemeManager::GetInstance()->GetResourceStyleRuleSet(
- u"cru.theme_builder.icon-button.style"));
- remove_button_.SetIconWithSvgPathDataStringResourceKey(u"icon.close",
+ "cru.theme_builder.icon-button.style"));
+ remove_button_.SetIconWithSvgPathDataStringResourceKey("icon.close",
{0, 0, 16, 16});
remove_button_.SetIconFillColor(ui::colors::red);
head_container_.AddChild(&remove_button_);
diff --git a/src/ThemeBuilder/components/HeadBodyEditor.h b/src/ThemeBuilder/components/HeadBodyEditor.h
index 1fcf2f63..1337bd4d 100644
--- a/src/ThemeBuilder/components/HeadBodyEditor.h
+++ b/src/ThemeBuilder/components/HeadBodyEditor.h
@@ -1,14 +1,13 @@
#pragma once
#include "Editor.h"
+#include "LabeledMixin.h"
#include "cru/base/Event.h"
#include "cru/ui/controls/Container.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/controls/IconButton.h"
-#include "cru/ui/controls/TextBlock.h"
-#include "cru/ui/style/Styler.h"
namespace cru::theme_builder::components {
-class HeadBodyEditor : public Editor {
+class HeadBodyEditor : public Editor, public LabeledMixin {
public:
HeadBodyEditor();
~HeadBodyEditor() override;
@@ -19,16 +18,12 @@ class HeadBodyEditor : public Editor {
ui::controls::FlexLayout* GetContainer() { return &container_; }
ui::controls::FlexLayout* GetHeadContainer() { return &head_container_; }
- String GetLabel() const { return label_.GetText(); }
- void SetLabel(String label) { label_.SetText(std::move(label)); }
-
IEvent<std::nullptr_t>* RemoveEvent() { return &remove_event_; }
private:
ui::controls::Container border_;
ui::controls::FlexLayout container_;
ui::controls::FlexLayout head_container_;
- ui::controls::TextBlock label_;
ui::controls::IconButton remove_button_;
Event<std::nullptr_t> remove_event_;
diff --git a/src/ThemeBuilder/components/LabeledMixin.h b/src/ThemeBuilder/components/LabeledMixin.h
new file mode 100644
index 00000000..867bb4ad
--- /dev/null
+++ b/src/ThemeBuilder/components/LabeledMixin.h
@@ -0,0 +1,13 @@
+#pragma once
+#include "cru/ui/controls/TextBlock.h"
+
+namespace cru::theme_builder {
+class LabeledMixin {
+ public:
+ std::string GetLabel() { return label_.GetText(); }
+ void SetLabel(std::string label) { label_.SetText(std::move(label)); }
+
+ protected:
+ ui::controls::TextBlock label_;
+};
+} // namespace cru::theme_builder
diff --git a/src/ThemeBuilder/components/MainWindow.cpp b/src/ThemeBuilder/components/MainWindow.cpp
index 0c78ef25..4f5812b1 100644
--- a/src/ThemeBuilder/components/MainWindow.cpp
+++ b/src/ThemeBuilder/components/MainWindow.cpp
@@ -9,12 +9,12 @@ using namespace cru::ui::controls;
using namespace cru::platform::gui;
MainWindow::MainWindow() {
- window_.GetNativeWindow()->SetTitle(u"CruUI Theme Builder");
+ window_.GetNativeWindow()->SetTitle("CruUI Theme Builder");
main_layout_.SetFlexDirection(FlexDirection::Horizontal);
window_.AddChild(&main_layout_);
main_layout_.AddChild(&preview_layout_);
- preview_button_text_.SetText(u"Preview");
+ preview_button_text_.SetText("Preview");
preview_button_.SetChild(&preview_button_text_);
preview_layout_.AddChild(&preview_button_);
preview_layout_.SetChildLayoutData(
diff --git a/src/ThemeBuilder/components/StyleRuleEditor.cpp b/src/ThemeBuilder/components/StyleRuleEditor.cpp
index dcb33184..f57e4654 100644
--- a/src/ThemeBuilder/components/StyleRuleEditor.cpp
+++ b/src/ThemeBuilder/components/StyleRuleEditor.cpp
@@ -14,14 +14,14 @@ StyleRuleEditor::StyleRuleEditor() {
main_layout_.AddChild(&head_layout_);
- label_.SetText(u"Style Rule");
+ label_.SetText("Style Rule");
head_layout_.AddChild(&label_);
head_layout_.AddChild(&remove_button_);
remove_button_.GetStyleRuleSet()->SetParent(
ui::ThemeManager::GetInstance()->GetResourceStyleRuleSet(
- u"cru.theme_builder.icon-button.style"));
- remove_button_.SetIconWithSvgPathDataStringResourceKey(u"icon.close",
+ "cru.theme_builder.icon-button.style"));
+ remove_button_.SetIconWithSvgPathDataStringResourceKey("icon.close",
{0, 0, 16, 16});
remove_button_.SetIconFillColor(ui::colors::red);
@@ -43,7 +43,7 @@ ui::style::StyleRule StyleRuleEditor::GetValue() const {
void StyleRuleEditor::SetValue(const ui::style::StyleRule& style_rule,
bool trigger_change) {
- body_layout_.ClearChildren();
+ body_layout_.RemoveAllChild();
condition_editor_ =
components::conditions::CreateConditionEditor(style_rule.GetCondition());
styler_editor_ =
diff --git a/src/ThemeBuilder/components/StyleRuleSetEditor.cpp b/src/ThemeBuilder/components/StyleRuleSetEditor.cpp
index a1c19e08..f077d31a 100644
--- a/src/ThemeBuilder/components/StyleRuleSetEditor.cpp
+++ b/src/ThemeBuilder/components/StyleRuleSetEditor.cpp
@@ -1,7 +1,5 @@
#include "StyleRuleSetEditor.h"
-#include "cru/base/Exception.h"
-#include "cru/base/String.h"
-#include "cru/ui/DeleteLater.h"
+#include "cru/platform/gui/DeleteLater.h"
#include "cru/ui/ThemeManager.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/model/IListChangeNotify.h"
@@ -23,10 +21,10 @@ StyleRuleSetEditor::StyleRuleSetEditor() {
add_button_.GetStyleRuleSet()->SetParent(
ui::ThemeManager::GetInstance()->GetResourceStyleRuleSet(
- u"cru.theme_builder.icon-button.style"));
- add_button_.SetIconWithSvgPathDataStringResourceKey(u"icon.plus",
+ "cru.theme_builder.icon-button.style"));
+ add_button_.SetIconWithSvgPathDataStringResourceKey("icon.plus",
{0, 0, 16, 16});
- add_button_.SetPreferredSize({24, 24});
+ add_button_.SetSuggestSize({24, 24});
add_button_.SetPadding(ui::Thickness(2));
add_button_.SetIconFillColor(ui::colors::green);
@@ -51,11 +49,11 @@ void StyleRuleSetEditor::BindStyleRuleSet(
}
Index StyleRuleSetEditor::IndexOfRuleEditor(StyleRuleEditor* editor) {
- auto iter =
- std::find_if(style_rule_editors_.cbegin(), style_rule_editors_.cend(),
- [editor](const ui::DeleteLaterPtr<StyleRuleEditor>& p) {
- return p.get() == editor;
- });
+ auto iter = std::find_if(
+ style_rule_editors_.cbegin(), style_rule_editors_.cend(),
+ [editor](const platform::gui::DeleteLaterPtr<StyleRuleEditor>& p) {
+ return p.get() == editor;
+ });
return iter - style_rule_editors_.cbegin();
}
@@ -68,7 +66,8 @@ void StyleRuleSetEditor::UpdateView(
for (auto i = change->position; i < change->position + change->count;
++i) {
const auto& rule = style_rule_set->GetStyleRule(i);
- auto style_rule_editor = ui::MakeDeleteLaterPtr<StyleRuleEditor>();
+ auto style_rule_editor =
+ platform::gui::MakeDeleteLater<StyleRuleEditor>();
style_rule_editor->SetValue(rule, false);
style_rule_editor->RemoveEvent()->AddSpyOnlyHandler(
[this, editor = style_rule_editor.get()] {
@@ -82,8 +81,8 @@ void StyleRuleSetEditor::UpdateView(
});
style_rule_editors_.insert(style_rule_editors_.cbegin() + i,
std::move(style_rule_editor));
- rules_layout_.AddChildAt(style_rule_editors_.back()->GetRootControl(),
- i);
+ rules_layout_.InsertChildAt(
+ style_rule_editors_.back()->GetRootControl(), i);
}
break;
}
@@ -107,7 +106,7 @@ void StyleRuleSetEditor::UpdateView(
break;
}
case ui::model::ListChangeType::kItemMove: {
- throw Exception(u"Not supported now!");
+ throw Exception("Not supported now!");
break;
}
case ui::model::ListChangeType::kClear: {
diff --git a/src/ThemeBuilder/components/StyleRuleSetEditor.h b/src/ThemeBuilder/components/StyleRuleSetEditor.h
index 03148889..36ac8626 100644
--- a/src/ThemeBuilder/components/StyleRuleSetEditor.h
+++ b/src/ThemeBuilder/components/StyleRuleSetEditor.h
@@ -1,8 +1,8 @@
#pragma once
#include "StyleRuleEditor.h"
-#include "cru/ui/DeleteLater.h"
+#include "cru/platform/gui/DeleteLater.h"
#include "cru/ui/components/Component.h"
-#include "cru/ui/controls/Button.h"
+#include "cru/ui/controls/IconButton.h"
#include "cru/ui/controls/Control.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/controls/ScrollView.h"
@@ -36,7 +36,7 @@ class StyleRuleSetEditor : public ui::components::Component {
ui::controls::ScrollView scroll_view_;
ui::controls::FlexLayout container_;
ui::controls::FlexLayout rules_layout_;
- std::vector<ui::DeleteLaterPtr<StyleRuleEditor>> style_rule_editors_;
+ std::vector<platform::gui::DeleteLaterPtr<StyleRuleEditor>> style_rule_editors_;
ui::controls::IconButton add_button_;
bool suppress_next_set_ = false;
diff --git a/src/ThemeBuilder/components/conditions/CheckedConditionEditor.cpp b/src/ThemeBuilder/components/conditions/CheckedConditionEditor.cpp
index 57e72a0f..b45006db 100644
--- a/src/ThemeBuilder/components/conditions/CheckedConditionEditor.cpp
+++ b/src/ThemeBuilder/components/conditions/CheckedConditionEditor.cpp
@@ -1,12 +1,12 @@
#include "CheckedConditionEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
CheckedConditionEditor::CheckedConditionEditor() {
- SetLabel(u"Checked Condition");
+ SetLabel("Checked Condition");
- checked_check_box_.SetLabel(u"Checked");
+ checked_check_box_.SetLabel("Checked");
GetContainer()->AddChild(checked_check_box_.GetRootControl());
ConnectChangeEvent(checked_check_box_);
@@ -14,8 +14,7 @@ CheckedConditionEditor::CheckedConditionEditor() {
CheckedConditionEditor::~CheckedConditionEditor() {}
-ClonablePtr<ui::style::CheckedCondition> CheckedConditionEditor::GetValue()
- const {
+ClonePtr<ui::style::CheckedCondition> CheckedConditionEditor::GetValue() {
return ui::style::CheckedCondition::Create(checked_check_box_.GetValue());
}
diff --git a/src/ThemeBuilder/components/conditions/CheckedConditionEditor.h b/src/ThemeBuilder/components/conditions/CheckedConditionEditor.h
index b6e740f1..6fc6f97f 100644
--- a/src/ThemeBuilder/components/conditions/CheckedConditionEditor.h
+++ b/src/ThemeBuilder/components/conditions/CheckedConditionEditor.h
@@ -1,7 +1,7 @@
#pragma once
#include "../properties/CheckBoxPropertyEditor.h"
#include "ConditionEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
@@ -11,16 +11,14 @@ class CheckedConditionEditor : public ConditionEditor {
~CheckedConditionEditor() override;
public:
- ClonablePtr<ui::style::CheckedCondition> GetValue() const;
+ ClonePtr<ui::style::CheckedCondition> GetValue();
void SetValue(ui::style::CheckedCondition* value, bool trigger_change = true);
- void SetValue(const ClonablePtr<ui::style::CheckedCondition>& value,
+ void SetValue(const ClonePtr<ui::style::CheckedCondition>& value,
bool trigger_change = true) {
SetValue(value.get(), trigger_change);
}
- ClonablePtr<ui::style::Condition> GetCondition() override {
- return GetValue();
- }
+ ClonePtr<ui::style::Condition> GetCondition() override { return GetValue(); }
private:
properties::CheckBoxPropertyEditor checked_check_box_;
diff --git a/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.cpp b/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.cpp
index bf0b1d98..4862fd47 100644
--- a/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.cpp
+++ b/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.cpp
@@ -1,16 +1,16 @@
#include "ClickStateConditionEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/helper/ClickDetector.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
using ui::helper::ClickState;
namespace {
-const std::vector<String> kClickStates{
- u"None",
- u"Hover",
- u"Press",
- u"PressInactive",
+const std::vector<std::string> kClickStates{
+ "None",
+ "Hover",
+ "Press",
+ "PressInactive",
};
Index ConvertClickStateToIndex(ClickState click_state) {
@@ -43,10 +43,10 @@ ClickState ConvertIndexToClickState(Index index) {
} // namespace
ClickStateConditionEditor::ClickStateConditionEditor() {
- SetLabel(u"Click State Condition");
+ SetLabel("Click State Condition");
GetContainer()->AddChild(click_state_select_.GetRootControl());
- click_state_select_.SetLabel(u"Click State");
+ click_state_select_.SetLabel("Click State");
click_state_select_.SetItems(kClickStates);
click_state_select_.SetSelectedIndex(0, false);
@@ -55,8 +55,7 @@ ClickStateConditionEditor::ClickStateConditionEditor() {
ClickStateConditionEditor::~ClickStateConditionEditor() {}
-ClonablePtr<ui::style::ClickStateCondition>
-ClickStateConditionEditor::GetValue() const {
+ClonePtr<ui::style::ClickStateCondition> ClickStateConditionEditor::GetValue() {
return ui::style::ClickStateCondition::Create(
ConvertIndexToClickState(click_state_select_.GetSelectedIndex()));
}
diff --git a/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.h b/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.h
index 2ea4fcf4..6929732c 100644
--- a/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.h
+++ b/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.h
@@ -1,8 +1,7 @@
#pragma once
#include "../properties/SelectPropertyEditor.h"
#include "ConditionEditor.h"
-#include "cru/base/ClonablePtr.h"
-#include "cru/base/Event.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
@@ -12,17 +11,15 @@ class ClickStateConditionEditor : public ConditionEditor {
~ClickStateConditionEditor();
public:
- ClonablePtr<ui::style::ClickStateCondition> GetValue() const;
+ ClonePtr<ui::style::ClickStateCondition> GetValue();
void SetValue(ui::style::ClickStateCondition* value,
bool trigger_change = true);
- void SetValue(const ClonablePtr<ui::style::ClickStateCondition>& value,
+ void SetValue(const ClonePtr<ui::style::ClickStateCondition>& value,
bool trigger_change = true) {
SetValue(value.get(), trigger_change);
}
- ClonablePtr<ui::style::Condition> GetCondition() override {
- return GetValue();
- }
+ ClonePtr<ui::style::Condition> GetCondition() override { return GetValue(); }
private:
properties::SelectPropertyEditor click_state_select_;
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) {
diff --git a/src/ThemeBuilder/components/conditions/CompoundConditionEditor.h b/src/ThemeBuilder/components/conditions/CompoundConditionEditor.h
index 2948df36..6c1beeac 100644
--- a/src/ThemeBuilder/components/conditions/CompoundConditionEditor.h
+++ b/src/ThemeBuilder/components/conditions/CompoundConditionEditor.h
@@ -1,12 +1,8 @@
#pragma once
#include "ConditionEditor.h"
-#include "cru/base/ClonablePtr.h"
-#include "cru/base/Event.h"
-#include "cru/ui/components/Component.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/components/PopupButton.h"
-#include "cru/ui/controls/Button.h"
#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/controls/TextBlock.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
@@ -16,56 +12,48 @@ class CompoundConditionEditor : public ConditionEditor {
~CompoundConditionEditor();
protected:
- std::vector<ClonablePtr<ui::style::Condition>> GetChildren();
- void SetChildren(std::vector<ClonablePtr<ui::style::Condition>> children,
+ std::vector<ClonePtr<ui::style::Condition>> GetChildren();
+ void SetChildren(std::vector<ClonePtr<ui::style::Condition>> children,
bool trigger_change = true);
private:
ui::components::PopupMenuIconButton add_child_button_;
ui::controls::FlexLayout children_container_;
- std::vector<ui::DeleteLaterPtr<ConditionEditor>> children_;
+ std::vector<platform::gui::DeleteLaterPtr<ConditionEditor>> children_;
};
class AndConditionEditor : public CompoundConditionEditor {
public:
- AndConditionEditor() = default;
- ~AndConditionEditor() override = default;
-
- public:
- ClonablePtr<ui::style::AndCondition> GetValue() {
+ ClonePtr<ui::style::AndCondition> GetValue() {
return ui::style::AndCondition::Create(GetChildren());
}
void SetValue(ui::style::AndCondition* value, bool trigger_change = true) {
SetChildren(value->GetChildren(), trigger_change);
}
- void SetValue(const ClonablePtr<ui::style::AndCondition>& value,
+ void SetValue(const ClonePtr<ui::style::AndCondition>& value,
bool trigger_change = true) {
SetValue(value.get(), trigger_change);
}
- ClonablePtr<ui::style::Condition> GetCondition() override {
+ ClonePtr<ui::style::Condition> GetCondition() override {
return GetValue();
}
};
class OrConditionEditor : public CompoundConditionEditor {
public:
- OrConditionEditor() = default;
- ~OrConditionEditor() override = default;
-
- public:
- ClonablePtr<ui::style::OrCondition> GetValue() {
+ ClonePtr<ui::style::OrCondition> GetValue() {
return ui::style::OrCondition::Create(GetChildren());
}
void SetValue(ui::style::OrCondition* value, bool trigger_change = true) {
SetChildren(value->GetChildren(), trigger_change);
}
- void SetValue(const ClonablePtr<ui::style::OrCondition>& value,
+ void SetValue(const ClonePtr<ui::style::OrCondition>& value,
bool trigger_change = true) {
SetValue(value.get(), trigger_change);
}
- ClonablePtr<ui::style::Condition> GetCondition() override {
+ ClonePtr<ui::style::Condition> GetCondition() override {
return GetValue();
}
};
diff --git a/src/ThemeBuilder/components/conditions/ConditionEditor.cpp b/src/ThemeBuilder/components/conditions/ConditionEditor.cpp
index 421bb028..da0db194 100644
--- a/src/ThemeBuilder/components/conditions/ConditionEditor.cpp
+++ b/src/ThemeBuilder/components/conditions/ConditionEditor.cpp
@@ -5,7 +5,6 @@
#include "CompoundConditionEditor.h"
#include "FocusConditionEditor.h"
#include "NoConditionEditor.h"
-#include "cru/base/Exception.h"
#include "cru/ui/controls/FlexLayout.h"
namespace cru::theme_builder::components::conditions {
@@ -44,7 +43,7 @@ std::unique_ptr<ConditionEditor> CreateConditionEditor(
result->SetValue(checked_condition);
return result;
} else {
- throw Exception(u"Unknown condition type");
+ throw Exception("Unknown condition type");
}
}
} // namespace cru::theme_builder::components::conditions
diff --git a/src/ThemeBuilder/components/conditions/ConditionEditor.h b/src/ThemeBuilder/components/conditions/ConditionEditor.h
index f20132f6..ca632cc0 100644
--- a/src/ThemeBuilder/components/conditions/ConditionEditor.h
+++ b/src/ThemeBuilder/components/conditions/ConditionEditor.h
@@ -9,7 +9,7 @@ class ConditionEditor : public HeadBodyEditor {
~ConditionEditor() override;
public:
- virtual ClonablePtr<ui::style::Condition> GetCondition() = 0;
+ virtual ClonePtr<ui::style::Condition> GetCondition() = 0;
};
std::unique_ptr<ConditionEditor> CreateConditionEditor(
diff --git a/src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp b/src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp
index 78c99b5c..356f42ef 100644
--- a/src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp
+++ b/src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp
@@ -1,20 +1,20 @@
#include "FocusConditionEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
FocusConditionEditor::FocusConditionEditor() {
- SetLabel(u"Focus Condition");
+ SetLabel("Focus Condition");
GetContainer()->AddChild(focus_check_box_.GetRootControl());
- focus_check_box_.SetLabel(u"Focus");
+ focus_check_box_.SetLabel("Focus");
ConnectChangeEvent(focus_check_box_);
}
FocusConditionEditor::~FocusConditionEditor() {}
-ClonablePtr<ui::style::FocusCondition> FocusConditionEditor::GetValue() const {
+ClonePtr<ui::style::FocusCondition> FocusConditionEditor::GetValue() {
return ui::style::FocusCondition::Create(focus_check_box_.GetValue());
}
diff --git a/src/ThemeBuilder/components/conditions/FocusConditionEditor.h b/src/ThemeBuilder/components/conditions/FocusConditionEditor.h
index d5478653..1cfb883f 100644
--- a/src/ThemeBuilder/components/conditions/FocusConditionEditor.h
+++ b/src/ThemeBuilder/components/conditions/FocusConditionEditor.h
@@ -1,7 +1,7 @@
#pragma once
#include "../properties/CheckBoxPropertyEditor.h"
#include "ConditionEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
@@ -11,16 +11,14 @@ class FocusConditionEditor : public ConditionEditor {
~FocusConditionEditor() override;
public:
- ClonablePtr<ui::style::FocusCondition> GetValue() const;
+ ClonePtr<ui::style::FocusCondition> GetValue();
void SetValue(ui::style::FocusCondition* value, bool trigger_change = true);
- void SetValue(const ClonablePtr<ui::style::FocusCondition>& value,
+ void SetValue(const ClonePtr<ui::style::FocusCondition>& value,
bool trigger_change = true) {
SetValue(value.get(), trigger_change);
}
- ClonablePtr<ui::style::Condition> GetCondition() override {
- return GetValue();
- }
+ ClonePtr<ui::style::Condition> GetCondition() override { return GetValue(); }
private:
properties::CheckBoxPropertyEditor focus_check_box_;
diff --git a/src/ThemeBuilder/components/conditions/NoConditionEditor.cpp b/src/ThemeBuilder/components/conditions/NoConditionEditor.cpp
index a5087159..31b906de 100644
--- a/src/ThemeBuilder/components/conditions/NoConditionEditor.cpp
+++ b/src/ThemeBuilder/components/conditions/NoConditionEditor.cpp
@@ -1,7 +1,7 @@
#include "NoConditionEditor.h"
namespace cru::theme_builder::components::conditions {
-NoConditionEditor::NoConditionEditor() { SetLabel(u"No condition"); }
+NoConditionEditor::NoConditionEditor() { SetLabel("No condition"); }
NoConditionEditor::~NoConditionEditor() {}
} // namespace cru::theme_builder::components::conditions
diff --git a/src/ThemeBuilder/components/conditions/NoConditionEditor.h b/src/ThemeBuilder/components/conditions/NoConditionEditor.h
index b38806b5..1cb50947 100644
--- a/src/ThemeBuilder/components/conditions/NoConditionEditor.h
+++ b/src/ThemeBuilder/components/conditions/NoConditionEditor.h
@@ -1,6 +1,6 @@
#pragma once
#include "ConditionEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
@@ -10,7 +10,7 @@ class NoConditionEditor : public ConditionEditor {
~NoConditionEditor() override;
public:
- ClonablePtr<ui::style::Condition> GetCondition() override {
+ ClonePtr<ui::style::Condition> GetCondition() override {
return ui::style::NoCondition::Create();
}
};
diff --git a/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h b/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h
index f78ed6c9..8673a285 100644
--- a/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h
@@ -1,11 +1,11 @@
#pragma once
#include "../Editor.h"
+#include "../LabeledMixin.h"
#include "cru/ui/controls/CheckBox.h"
#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/controls/TextBlock.h"
namespace cru::theme_builder::components::properties {
-class CheckBoxPropertyEditor : public Editor {
+class CheckBoxPropertyEditor : public Editor, public LabeledMixin {
public:
using PropertyType = bool;
@@ -15,15 +15,11 @@ class CheckBoxPropertyEditor : public Editor {
public:
ui::controls::Control* GetRootControl() override { return &container_; }
- String GetLabel() const { return label_.GetText(); }
- void SetLabel(String label) { label_.SetText(std::move(label)); }
-
- bool GetValue() const { return check_box_.IsChecked(); }
+ bool GetValue() { return check_box_.IsChecked(); }
void SetValue(bool value, bool trigger_change = true);
private:
ui::controls::FlexLayout container_;
- ui::controls::TextBlock label_;
ui::controls::CheckBox check_box_;
};
} // namespace cru::theme_builder::components::properties
diff --git a/src/ThemeBuilder/components/properties/ColorPropertyEditor.cpp b/src/ThemeBuilder/components/properties/ColorPropertyEditor.cpp
index e9e486ac..c048734c 100644
--- a/src/ThemeBuilder/components/properties/ColorPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/ColorPropertyEditor.cpp
@@ -12,7 +12,7 @@ ColorPropertyEditor::ColorPropertyEditor() {
color_cube_.SetBorderEnabled(true);
color_cube_.GetStyleRuleSet()->SetParent(
ui::ThemeManager::GetInstance()->GetResourceStyleRuleSet(
- u"cru.theme_builder.color_cube.style"));
+ "cru.theme_builder.color_cube.style"));
color_cube_brush_ = platform::gui::IUiApplication::GetInstance()
->GetGraphicsFactory()
diff --git a/src/ThemeBuilder/components/properties/ColorPropertyEditor.h b/src/ThemeBuilder/components/properties/ColorPropertyEditor.h
index aa6cfcfa..a0f784e9 100644
--- a/src/ThemeBuilder/components/properties/ColorPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/ColorPropertyEditor.h
@@ -1,13 +1,13 @@
#pragma once
#include "../Editor.h"
+#include "../LabeledMixin.h"
#include "cru/platform/graphics/Base.h"
#include "cru/ui/controls/Container.h"
#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/controls/TextBlock.h"
#include "cru/ui/controls/TextBox.h"
namespace cru::theme_builder::components::properties {
-class ColorPropertyEditor : public Editor {
+class ColorPropertyEditor : public Editor, public LabeledMixin {
public:
using PropertyType = ui::Color;
@@ -17,17 +17,13 @@ class ColorPropertyEditor : public Editor {
public:
ui::controls::Control* GetRootControl() override { return &container_; }
- String GetLabel() const { return label_.GetText(); }
- void SetLabel(String label) { label_.SetText(std::move(label)); }
-
- ui::Color GetValue() const { return color_; }
+ ui::Color GetValue() { return color_; }
void SetValue(const ui::Color& color, bool trigger_change = true);
private:
ui::Color color_ = ui::colors::transparent;
ui::controls::FlexLayout container_;
- ui::controls::TextBlock label_;
ui::controls::Container color_cube_;
std::shared_ptr<platform::graphics::ISolidColorBrush> color_cube_brush_;
ui::controls::TextBox color_text_;
diff --git a/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp b/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp
index fc86b0ed..5b50ad38 100644
--- a/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp
@@ -6,10 +6,10 @@ namespace cru::theme_builder::components::properties {
CornerRadiusPropertyEditor::CornerRadiusPropertyEditor() {
container_.SetItemCrossAlign(ui::controls::FlexCrossAlignment::Start);
- left_top_editor_.SetLabel(u"⌜");
- right_top_editor_.SetLabel(u"⌝");
- left_bottom_editor_.SetLabel(u"⌞");
- right_bottom_editor_.SetLabel(u"⌟");
+ left_top_editor_.SetLabel("⌜");
+ right_top_editor_.SetLabel("⌝");
+ left_bottom_editor_.SetLabel("⌞");
+ right_bottom_editor_.SetLabel("⌟");
container_.SetFlexDirection(ui::controls::FlexDirection::Vertical);
container_.AddChild(left_top_editor_.GetRootControl());
@@ -25,7 +25,7 @@ CornerRadiusPropertyEditor::CornerRadiusPropertyEditor() {
CornerRadiusPropertyEditor::~CornerRadiusPropertyEditor() {}
-ui::CornerRadius CornerRadiusPropertyEditor::GetValue() const {
+ui::CornerRadius CornerRadiusPropertyEditor::GetValue() {
return ui::CornerRadius(
left_top_editor_.GetValue(), right_top_editor_.GetValue(),
left_bottom_editor_.GetValue(), right_bottom_editor_.GetValue());
diff --git a/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.h b/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.h
index 6b6833d1..376a2f30 100644
--- a/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.h
@@ -14,7 +14,7 @@ class CornerRadiusPropertyEditor : public Editor {
ui::controls::Control* GetRootControl() override { return &container_; }
- ui::CornerRadius GetValue() const;
+ ui::CornerRadius GetValue();
void SetValue(const ui::CornerRadius& corner_radius,
bool trigger_change = true);
diff --git a/src/ThemeBuilder/components/properties/FontPropertyEditor.cpp b/src/ThemeBuilder/components/properties/FontPropertyEditor.cpp
index 927ada7d..1024f446 100644
--- a/src/ThemeBuilder/components/properties/FontPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/FontPropertyEditor.cpp
@@ -3,7 +3,6 @@
#include "cru/platform/graphics/Font.h"
#include "cru/platform/gui/UiApplication.h"
#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/render/FlexLayoutRenderObject.h"
namespace cru::theme_builder::components::properties {
using namespace cru::ui::controls;
@@ -20,12 +19,12 @@ FontPropertyEditor::FontPropertyEditor() {
font_family_container_.SetFlexDirection(FlexDirection::Horizontal);
font_family_container_.AddChild(&font_family_label_);
font_family_container_.AddChild(&font_family_text_);
- font_family_label_.SetText(u"Font Family");
+ font_family_label_.SetText("Font Family");
font_size_container_.SetFlexDirection(FlexDirection::Horizontal);
font_size_container_.AddChild(&font_size_label_);
font_size_container_.AddChild(font_size_input_.GetRootControl());
- font_size_label_.SetText(u"Font Size");
+ font_size_label_.SetText("Font Size");
font_size_input_.SetMin(0.0f);
font_family_text_.TextChangeEvent()->AddSpyOnlyHandler(
@@ -39,8 +38,7 @@ FontPropertyEditor::~FontPropertyEditor() {}
Control* FontPropertyEditor::GetRootControl() { return &main_container_; }
-std::shared_ptr<platform::graphics::IFont> FontPropertyEditor::GetValue()
- const {
+std::shared_ptr<platform::graphics::IFont> FontPropertyEditor::GetValue() {
return platform::gui::IUiApplication::GetInstance()
->GetGraphicsFactory()
->CreateFont(font_family_text_.GetText(), font_size_input_.GetValue());
diff --git a/src/ThemeBuilder/components/properties/FontPropertyEditor.h b/src/ThemeBuilder/components/properties/FontPropertyEditor.h
index d349f1f2..4a6c601c 100644
--- a/src/ThemeBuilder/components/properties/FontPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/FontPropertyEditor.h
@@ -1,5 +1,6 @@
#pragma once
#include "../Editor.h"
+#include "../LabeledMixin.h"
#include "cru/platform/graphics/Font.h"
#include "cru/ui/components/Input.h"
#include "cru/ui/controls/Control.h"
@@ -8,7 +9,7 @@
#include "cru/ui/controls/TextBox.h"
namespace cru::theme_builder::components::properties {
-class FontPropertyEditor : public Editor {
+class FontPropertyEditor : public Editor, public LabeledMixin {
public:
using PropertyType = std::shared_ptr<platform::graphics::IFont>;
@@ -17,16 +18,12 @@ class FontPropertyEditor : public Editor {
ui::controls::Control* GetRootControl() override;
- String GetLabelText() const { return label_.GetText(); }
- void SetLabelText(String label) { label_.SetText(std::move(label)); }
-
- std::shared_ptr<platform::graphics::IFont> GetValue() const;
+ std::shared_ptr<platform::graphics::IFont> GetValue();
void SetValue(std::shared_ptr<platform::graphics::IFont> value,
bool trigger_change = true);
private:
ui::controls::FlexLayout main_container_;
- ui::controls::TextBlock label_;
ui::controls::FlexLayout right_container_;
ui::controls::FlexLayout font_family_container_;
ui::controls::TextBlock font_family_label_;
diff --git a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp
index e359199f..32723a6d 100644
--- a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp
@@ -10,12 +10,11 @@ MeasureLengthPropertyEditor::MeasureLengthPropertyEditor() {
container_.AddChild(&text_);
text_.TextChangeEvent()->AddHandler([this](std::nullptr_t) {
- auto text = text_.GetTextView();
+ auto text = text_.GetText();
auto measure_length_mapper = ui::mapper::MapperRegistry::GetInstance()
->GetMapper<ui::render::MeasureLength>();
try {
- auto measure_length =
- measure_length_mapper->MapFromString(text.ToString());
+ auto measure_length = measure_length_mapper->MapFromString(text);
measure_length_ = measure_length;
is_text_valid_ = true;
RaiseChangeEvent();
@@ -31,9 +30,8 @@ MeasureLengthPropertyEditor::~MeasureLengthPropertyEditor() {}
void MeasureLengthPropertyEditor::SetValue(
const ui::render::MeasureLength& value, bool trigger_change) {
if (!trigger_change) SuppressNextChangeEvent();
- text_.SetText(measure_length_.IsNotSpecified()
- ? u"unspecified"
- : String::FromUtf8(std::to_string(
- measure_length_.GetLengthOrUndefined())));
+ text_.SetText(measure_length_.IsSpecified()
+ ? std::to_string(measure_length_.GetLengthOrUndefined())
+ : "unspecified");
}
} // namespace cru::theme_builder::components::properties
diff --git a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h
index 43e783c5..412174a8 100644
--- a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h
@@ -1,14 +1,12 @@
#pragma once
#include "../Editor.h"
-#include "cru/platform/graphics/Base.h"
-#include "cru/ui/controls/Container.h"
+#include "../LabeledMixin.h"
#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/controls/TextBlock.h"
#include "cru/ui/controls/TextBox.h"
#include "cru/ui/render/MeasureRequirement.h"
namespace cru::theme_builder::components::properties {
-class MeasureLengthPropertyEditor : public Editor {
+class MeasureLengthPropertyEditor : public Editor, public LabeledMixin {
public:
using PropertyType = ui::render::MeasureLength;
@@ -18,17 +16,13 @@ class MeasureLengthPropertyEditor : public Editor {
public:
ui::controls::Control* GetRootControl() override { return &container_; }
- String GetLabel() const { return label_.GetText(); }
- void SetLabel(String label) { label_.SetText(std::move(label)); }
-
- PropertyType GetValue() const { return measure_length_; }
+ PropertyType GetValue() { return measure_length_; }
void SetValue(const PropertyType& value, bool trigger_change = true);
private:
PropertyType measure_length_;
ui::controls::FlexLayout container_;
- ui::controls::TextBlock label_;
ui::controls::TextBox text_;
bool is_text_valid_;
};
diff --git a/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h b/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h
index 0f22616a..b44b3b1b 100644
--- a/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h
@@ -1,14 +1,14 @@
#pragma once
#include "../Editor.h"
+#include "../LabeledMixin.h"
#include "cru/ui/controls/CheckBox.h"
#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/controls/TextBlock.h"
#include <optional>
namespace cru::theme_builder::components::properties {
template <typename TEditor>
-class OptionalPropertyEditor : public Editor {
+class OptionalPropertyEditor : public Editor, public LabeledMixin {
public:
using PropertyType = typename TEditor::PropertyType;
@@ -28,10 +28,7 @@ class OptionalPropertyEditor : public Editor {
ui::controls::Control* GetRootControl() override { return &container_; }
- String GetLabel() const { return label_.GetText(); }
- void SetLabel(String label) { label_.SetText(std::move(label)); }
-
- bool IsEnabled() const { return check_box_.IsChecked(); }
+ bool IsEnabled() { return check_box_.IsChecked(); }
void SetEnabled(bool enabled, bool trigger_change = true) {
check_box_.SetChecked(enabled);
if (trigger_change) {
@@ -39,7 +36,7 @@ class OptionalPropertyEditor : public Editor {
}
}
- std::optional<PropertyType> GetValue() const {
+ std::optional<PropertyType> GetValue() {
return IsEnabled() ? std::optional<PropertyType>(editor_.GetValue())
: std::nullopt;
}
@@ -58,7 +55,6 @@ class OptionalPropertyEditor : public Editor {
private:
ui::controls::FlexLayout container_;
- ui::controls::TextBlock label_;
ui::controls::CheckBox check_box_;
TEditor editor_;
};
diff --git a/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp b/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp
index f2d10cf7..51d6892e 100644
--- a/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp
@@ -1,6 +1,5 @@
#include "PointPropertyEditor.h"
#include "cru/ui/mapper/MapperRegistry.h"
-#include "cru/ui/mapper/PointMapper.h"
#include <format>
@@ -10,11 +9,11 @@ PointPropertyEditor::PointPropertyEditor() {
container_.AddChild(&text_);
text_.TextChangeEvent()->AddHandler([this](std::nullptr_t) {
- auto text = text_.GetTextView();
+ auto text = text_.GetText();
auto point_mapper =
ui::mapper::MapperRegistry::GetInstance()->GetMapper<ui::Point>();
try {
- auto point = point_mapper->MapFromString(text.ToString());
+ auto point = point_mapper->MapFromString(text);
point_ = point;
is_text_valid_ = true;
RaiseChangeEvent();
@@ -33,7 +32,7 @@ void PointPropertyEditor::SetValue(const ui::Point& point,
text_.SetText(ConvertPointToString(point));
}
-String PointPropertyEditor::ConvertPointToString(const ui::Point& point) {
- return String::FromUtf8(std::format("{} {}", point.x, point.y));
+std::string PointPropertyEditor::ConvertPointToString(const ui::Point& point) {
+ return std::format("{} {}", point.x, point.y);
}
} // namespace cru::theme_builder::components::properties
diff --git a/src/ThemeBuilder/components/properties/PointPropertyEditor.h b/src/ThemeBuilder/components/properties/PointPropertyEditor.h
index bd852e3a..299505dd 100644
--- a/src/ThemeBuilder/components/properties/PointPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/PointPropertyEditor.h
@@ -1,11 +1,11 @@
#pragma once
#include "../Editor.h"
+#include "../LabeledMixin.h"
#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/controls/TextBlock.h"
#include "cru/ui/controls/TextBox.h"
namespace cru::theme_builder::components::properties {
-class PointPropertyEditor : public Editor {
+class PointPropertyEditor : public Editor, public LabeledMixin {
public:
using PropertyType = ui::Point;
@@ -15,20 +15,16 @@ class PointPropertyEditor : public Editor {
public:
ui::controls::Control* GetRootControl() override { return &container_; }
- String GetLabel() const { return label_.GetText(); }
- void SetLabel(String label) { label_.SetText(std::move(label)); }
-
- ui::Point GetValue() const { return point_; }
+ ui::Point GetValue() { return point_; }
void SetValue(const ui::Point& point, bool trigger_change = true);
private:
- static String ConvertPointToString(const ui::Point& point);
+ static std::string ConvertPointToString(const ui::Point& point);
private:
ui::Point point_;
ui::controls::FlexLayout container_;
- ui::controls::TextBlock label_;
ui::controls::TextBox text_;
bool is_text_valid_;
};
diff --git a/src/ThemeBuilder/components/properties/SelectPropertyEditor.h b/src/ThemeBuilder/components/properties/SelectPropertyEditor.h
index 475d2d0a..c58c1829 100644
--- a/src/ThemeBuilder/components/properties/SelectPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/SelectPropertyEditor.h
@@ -1,11 +1,11 @@
#pragma once
#include "../Editor.h"
+#include "../LabeledMixin.h"
#include "cru/ui/components/Select.h"
#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/controls/TextBlock.h"
namespace cru::theme_builder::components::properties {
-class SelectPropertyEditor : public Editor {
+class SelectPropertyEditor : public Editor, public LabeledMixin {
public:
using PropertyType = Index;
@@ -15,28 +15,24 @@ class SelectPropertyEditor : public Editor {
public:
ui::controls::Control* GetRootControl() override { return &container_; }
- String GetLabel() const { return label_.GetText(); }
- void SetLabel(String label) { label_.SetText(std::move(label)); }
-
- Index GetSelectedIndex() const { return select_.GetSelectedIndex(); }
+ Index GetSelectedIndex() { return select_.GetSelectedIndex(); }
void SetSelectedIndex(Index index, bool trigger_change = true) {
if (trigger_change == false) SuppressNextChangeEvent();
select_.SetSelectedIndex(index);
}
- std::vector<String> GetItems() const { return select_.GetItems(); }
- void SetItems(std::vector<String> items) {
+ std::vector<std::string> GetItems() { return select_.GetItems(); }
+ void SetItems(std::vector<std::string> items) {
select_.SetItems(std::move(items));
}
- Index GetValue() const { return GetSelectedIndex(); }
+ Index GetValue() { return GetSelectedIndex(); }
void SetValue(Index value, bool trigger_change = true) {
SetSelectedIndex(value, trigger_change);
}
private:
ui::controls::FlexLayout container_;
- ui::controls::TextBlock label_;
ui::components::Select select_;
};
} // namespace cru::theme_builder::components::properties
diff --git a/src/ThemeBuilder/components/properties/TextPropertyEditor.cpp b/src/ThemeBuilder/components/properties/TextPropertyEditor.cpp
index 9854019c..4d34c9e6 100644
--- a/src/ThemeBuilder/components/properties/TextPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/TextPropertyEditor.cpp
@@ -4,7 +4,7 @@ namespace cru::theme_builder::components::properties {
TextPropertyEditor::TextPropertyEditor() {
editor_.TextChangeEvent()->AddHandler([this](std::nullptr_t) {
auto text_view = editor_.GetTextView();
- String error_message;
+ std::string error_message;
auto validation_result = Validate(text_view, &error_message);
if (validation_result) {
OnTextChanged(text_view);
@@ -14,9 +14,10 @@ TextPropertyEditor::TextPropertyEditor() {
TextPropertyEditor::~TextPropertyEditor() {}
-bool TextPropertyEditor::Validate(StringView text, String* error_message) {
+bool TextPropertyEditor::Validate(std::string_view text,
+ std::string* error_message) {
return true;
}
-void TextPropertyEditor::OnTextChanged(StringView text) {}
+void TextPropertyEditor::OnTextChanged(std::string_view text) {}
} // namespace cru::theme_builder::components::properties
diff --git a/src/ThemeBuilder/components/properties/TextPropertyEditor.h b/src/ThemeBuilder/components/properties/TextPropertyEditor.h
index c4944228..433143cd 100644
--- a/src/ThemeBuilder/components/properties/TextPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/TextPropertyEditor.h
@@ -1,27 +1,26 @@
#pragma once
+#include "../LabeledMixin.h"
#include "cru/ui/components/Component.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/controls/TextBlock.h"
#include "cru/ui/controls/TextBox.h"
namespace cru::theme_builder::components::properties {
-class TextPropertyEditor : public ui::components::Component {
+class TextPropertyEditor : public ui::components::Component,
+ public LabeledMixin {
public:
TextPropertyEditor();
~TextPropertyEditor() override;
ui::controls::Control* GetRootControl() override { return &container_; }
- String GetLabel() const { return label_.GetText(); }
- void SetLabel(String label) { label_.SetText(std::move(label)); }
-
- String GetText() const { return editor_.GetText(); }
- StringView GetTextView() const { return editor_.GetTextView(); }
- void SetText(String text) { editor_.SetText(std::move(text)); }
+ std::string GetText() { return editor_.GetText(); }
+ std::string_view GetTextView() { return editor_.GetTextView(); }
+ void SetText(std::string text) { editor_.SetText(std::move(text)); }
protected:
- virtual bool Validate(StringView text, String* error_message);
- virtual void OnTextChanged(StringView text);
+ virtual bool Validate(std::string_view text, std::string* error_message);
+ virtual void OnTextChanged(std::string_view text);
private:
ui::controls::FlexLayout container_;
diff --git a/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp b/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp
index 955a44f7..bd8c64b9 100644
--- a/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp
@@ -1,5 +1,5 @@
#include "ThicknessPropertyEditor.h"
-#include "cru/base/Format.h"
+#include <format>
#include "cru/ui/mapper/MapperRegistry.h"
#include "cru/ui/mapper/ThicknessMapper.h"
@@ -29,7 +29,7 @@ ThicknessPropertyEditor::~ThicknessPropertyEditor() {}
void ThicknessPropertyEditor::SetValue(const ui::Thickness &thickness,
bool trigger_change) {
if (!trigger_change) SuppressNextChangeEvent();
- text_.SetText(Format(u"{} {} {} {}", thickness.left, thickness.top,
- thickness.right, thickness.bottom));
+ text_.SetText(std::format("{} {} {} {}", thickness.left, thickness.top,
+ thickness.right, thickness.bottom));
}
} // namespace cru::theme_builder::components::properties
diff --git a/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h b/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h
index cea9ae9d..106e0e9e 100644
--- a/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h
+++ b/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h
@@ -1,11 +1,11 @@
#pragma once
#include "../Editor.h"
+#include "../LabeledMixin.h"
#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/controls/TextBlock.h"
#include "cru/ui/controls/TextBox.h"
namespace cru::theme_builder::components::properties {
-class ThicknessPropertyEditor : public Editor {
+class ThicknessPropertyEditor : public Editor, public LabeledMixin {
public:
using PropertyType = ui::Thickness;
@@ -14,17 +14,13 @@ class ThicknessPropertyEditor : public Editor {
ui::controls::Control* GetRootControl() override { return &container_; }
- String GetLabel() const { return label_.GetText(); }
- void SetLabel(String label) { label_.SetText(std::move(label)); }
-
- ui::Thickness GetValue() const { return thickness_; }
+ ui::Thickness GetValue() { return thickness_; }
void SetValue(const ui::Thickness& thickness, bool trigger_change = true);
private:
ui::Thickness thickness_;
ui::controls::FlexLayout container_;
- ui::controls::TextBlock label_;
ui::controls::TextBox text_;
bool is_text_valid_;
};
diff --git a/src/ThemeBuilder/components/stylers/BorderStylerEditor.cpp b/src/ThemeBuilder/components/stylers/BorderStylerEditor.cpp
index 1329a08a..74ce83ec 100644
--- a/src/ThemeBuilder/components/stylers/BorderStylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/BorderStylerEditor.cpp
@@ -1,5 +1,5 @@
#include "BorderStylerEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/platform/graphics/Brush.h"
#include "cru/platform/graphics/Factory.h"
#include "cru/platform/gui/UiApplication.h"
@@ -8,17 +8,17 @@
namespace cru::theme_builder::components::stylers {
BorderStylerEditor::BorderStylerEditor() {
- SetLabel(u"Border Styler");
+ SetLabel("Border Styler");
GetContainer()->AddChild(corner_radius_editor_.GetRootControl());
GetContainer()->AddChild(thickness_editor_.GetRootControl());
GetContainer()->AddChild(brush_editor_.GetRootControl());
GetContainer()->AddChild(foreground_brush_editor_.GetRootControl());
GetContainer()->AddChild(background_brush_editor_.GetRootControl());
- thickness_editor_.GetEditor()->SetLabel(u"Thickness");
- brush_editor_.GetEditor()->SetLabel(u"Border");
- foreground_brush_editor_.GetEditor()->SetLabel(u"Foreground");
- background_brush_editor_.GetEditor()->SetLabel(u"Background");
+ thickness_editor_.GetEditor()->SetLabel("Thickness");
+ brush_editor_.GetEditor()->SetLabel("Border");
+ foreground_brush_editor_.GetEditor()->SetLabel("Foreground");
+ background_brush_editor_.GetEditor()->SetLabel("Background");
ConnectChangeEvent(corner_radius_editor_);
ConnectChangeEvent(thickness_editor_);
@@ -29,7 +29,7 @@ BorderStylerEditor::BorderStylerEditor() {
BorderStylerEditor::~BorderStylerEditor() {}
-ClonablePtr<ui::style::BorderStyler> BorderStylerEditor::GetValue() {
+ClonePtr<ui::style::BorderStyler> BorderStylerEditor::GetValue() {
auto graphics_factory =
platform::gui::IUiApplication::GetInstance()->GetGraphicsFactory();
@@ -67,7 +67,7 @@ void BorderStylerEditor::SetValue(ui::style::BorderStyler* styler,
if (border_style.border_brush.has_value()) {
brush_editor_.GetEditor()->SetValue(
std::dynamic_pointer_cast<platform::graphics::ISolidColorBrush>(
- border_style.border_brush.value())
+ *border_style.border_brush)
->GetColor(),
false);
}
@@ -77,7 +77,7 @@ void BorderStylerEditor::SetValue(ui::style::BorderStyler* styler,
if (border_style.foreground_brush.has_value()) {
foreground_brush_editor_.GetEditor()->SetValue(
std::dynamic_pointer_cast<platform::graphics::ISolidColorBrush>(
- border_style.foreground_brush.value())
+ *border_style.foreground_brush)
->GetColor(),
false);
}
@@ -87,7 +87,7 @@ void BorderStylerEditor::SetValue(ui::style::BorderStyler* styler,
if (border_style.background_brush.has_value()) {
background_brush_editor_.GetEditor()->SetValue(
std::dynamic_pointer_cast<platform::graphics::ISolidColorBrush>(
- border_style.background_brush.value())
+ *border_style.background_brush)
->GetColor(),
false);
}
diff --git a/src/ThemeBuilder/components/stylers/BorderStylerEditor.h b/src/ThemeBuilder/components/stylers/BorderStylerEditor.h
index c9435ee9..ea92a8d4 100644
--- a/src/ThemeBuilder/components/stylers/BorderStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/BorderStylerEditor.h
@@ -4,7 +4,7 @@
#include "../properties/OptionalPropertyEditor.h"
#include "../properties/ThicknessPropertyEditor.h"
#include "StylerEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
namespace cru::theme_builder::components::stylers {
class BorderStylerEditor : public StylerEditor {
@@ -12,14 +12,14 @@ class BorderStylerEditor : public StylerEditor {
BorderStylerEditor();
~BorderStylerEditor() override;
- ClonablePtr<ui::style::BorderStyler> GetValue();
+ ClonePtr<ui::style::BorderStyler> GetValue();
void SetValue(ui::style::BorderStyler* styler, bool trigger_change = true);
- void SetValue(const ClonablePtr<ui::style::BorderStyler>& styler,
+ void SetValue(const ClonePtr<ui::style::BorderStyler>& styler,
bool trigger_change = true) {
SetValue(styler.get(), trigger_change);
}
- ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
+ ClonePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
private:
properties::OptionalPropertyEditor<properties::CornerRadiusPropertyEditor>
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());
}
}
diff --git a/src/ThemeBuilder/components/stylers/CompoundStylerEditor.h b/src/ThemeBuilder/components/stylers/CompoundStylerEditor.h
index 91d2bff5..454b3622 100644
--- a/src/ThemeBuilder/components/stylers/CompoundStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/CompoundStylerEditor.h
@@ -1,7 +1,7 @@
#pragma once
#include "StylerEditor.h"
-#include "cru/base/ClonablePtr.h"
-#include "cru/ui/DeleteLater.h"
+#include "cru/base/ClonePtr.h"
+#include "cru/platform/gui/DeleteLater.h"
#include "cru/ui/components/PopupButton.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/style/Styler.h"
@@ -13,18 +13,18 @@ class CompoundStylerEditor : public StylerEditor {
~CompoundStylerEditor() override;
public:
- ClonablePtr<ui::style::CompoundStyler> GetValue();
+ ClonePtr<ui::style::CompoundStyler> GetValue();
void SetValue(ui::style::CompoundStyler* styler, bool trigger_change = true);
- void SetValue(const ClonablePtr<ui::style::CompoundStyler>& styler,
+ void SetValue(const ClonePtr<ui::style::CompoundStyler>& styler,
bool trigger_change = true) {
SetValue(styler.get(), trigger_change);
}
- ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
+ ClonePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
private:
ui::controls::FlexLayout children_container_;
- std::vector<ui::DeleteLaterPtr<StylerEditor>> children_;
+ std::vector<platform::gui::DeleteLaterPtr<StylerEditor>> children_;
ui::components::PopupMenuIconButton add_child_button_;
};
} // namespace cru::theme_builder::components::stylers
diff --git a/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp b/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp
index bd649c67..98bc14b7 100644
--- a/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp
@@ -12,8 +12,7 @@ ContentBrushStylerEditor::ContentBrushStylerEditor() {
ContentBrushStylerEditor::~ContentBrushStylerEditor() {}
-ClonablePtr<ui::style::ContentBrushStyler> ContentBrushStylerEditor::GetValue()
- const {
+ClonePtr<ui::style::ContentBrushStyler> ContentBrushStylerEditor::GetValue() {
return ui::style::ContentBrushStyler::Create(
platform::gui::IUiApplication::GetInstance()
->GetGraphicsFactory()
diff --git a/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.h b/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.h
index ec51c041..b1b179a1 100644
--- a/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.h
@@ -1,8 +1,7 @@
#pragma once
-#include "../Editor.h"
#include "../properties/ColorPropertyEditor.h"
#include "StylerEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Styler.h"
namespace cru::theme_builder::components::stylers {
@@ -12,11 +11,11 @@ class ContentBrushStylerEditor : public StylerEditor {
~ContentBrushStylerEditor();
public:
- ClonablePtr<ui::style::ContentBrushStyler> GetValue() const;
+ ClonePtr<ui::style::ContentBrushStyler> GetValue();
void SetValue(ui::style::ContentBrushStyler* value,
bool trigger_change = true);
- ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
+ ClonePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
private:
properties::ColorPropertyEditor color_editor_;
diff --git a/src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp b/src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp
index 9984d81a..589efc2b 100644
--- a/src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp
@@ -4,11 +4,11 @@
namespace cru::theme_builder::components::stylers {
CursorStylerEditor::CursorStylerEditor() {
- SetLabel(u"Cursor Styler");
+ SetLabel("Cursor Styler");
GetContainer()->AddChild(cursor_select_.GetRootControl());
- cursor_select_.SetLabel(u"Cursor");
- cursor_select_.SetItems({u"arrow", u"hand", u"ibeam"});
+ cursor_select_.SetLabel("Cursor");
+ cursor_select_.SetItems({"arrow", "hand", "ibeam"});
cursor_select_.SetSelectedIndex(0);
ConnectChangeEvent(cursor_select_);
@@ -16,7 +16,7 @@ CursorStylerEditor::CursorStylerEditor() {
CursorStylerEditor::~CursorStylerEditor() {}
-ClonablePtr<ui::style::CursorStyler> CursorStylerEditor::GetValue() {
+ClonePtr<ui::style::CursorStyler> CursorStylerEditor::GetValue() {
auto cursor_manager =
platform::gui::IUiApplication::GetInstance()->GetCursorManager();
diff --git a/src/ThemeBuilder/components/stylers/CursorStylerEditor.h b/src/ThemeBuilder/components/stylers/CursorStylerEditor.h
index 552619a0..a40c8aa9 100644
--- a/src/ThemeBuilder/components/stylers/CursorStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/CursorStylerEditor.h
@@ -9,14 +9,14 @@ class CursorStylerEditor : public StylerEditor {
~CursorStylerEditor() override;
public:
- ClonablePtr<ui::style::CursorStyler> GetValue();
+ ClonePtr<ui::style::CursorStyler> GetValue();
void SetValue(ui::style::CursorStyler* styler, bool trigger_change = true);
- void SetValue(const ClonablePtr<ui::style::CursorStyler>& styler,
+ void SetValue(const ClonePtr<ui::style::CursorStyler>& styler,
bool trigger_change = true) {
SetValue(styler.get(), trigger_change);
}
- ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
+ ClonePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
private:
properties::SelectPropertyEditor cursor_select_;
diff --git a/src/ThemeBuilder/components/stylers/FontStylerEditor.cpp b/src/ThemeBuilder/components/stylers/FontStylerEditor.cpp
index 9787a4fd..e84a439c 100644
--- a/src/ThemeBuilder/components/stylers/FontStylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/FontStylerEditor.cpp
@@ -1,6 +1,4 @@
#include "FontStylerEditor.h"
-#include "cru/platform/graphics/Factory.h"
-#include "cru/platform/gui/UiApplication.h"
#include "cru/ui/style/Styler.h"
namespace cru::theme_builder::components::stylers {
@@ -12,7 +10,7 @@ FontStylerEditor::FontStylerEditor() {
FontStylerEditor::~FontStylerEditor() {}
-ClonablePtr<ui::style::FontStyler> FontStylerEditor::GetValue() const {
+ClonePtr<ui::style::FontStyler> FontStylerEditor::GetValue() {
return ui::style::FontStyler::Create(font_editor_.GetValue());
}
diff --git a/src/ThemeBuilder/components/stylers/FontStylerEditor.h b/src/ThemeBuilder/components/stylers/FontStylerEditor.h
index 847b0e2a..11c931d3 100644
--- a/src/ThemeBuilder/components/stylers/FontStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/FontStylerEditor.h
@@ -1,8 +1,7 @@
#pragma once
-#include "../Editor.h"
#include "../properties/FontPropertyEditor.h"
#include "StylerEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Styler.h"
namespace cru::theme_builder::components::stylers {
@@ -12,10 +11,10 @@ class FontStylerEditor : public StylerEditor {
~FontStylerEditor();
public:
- ClonablePtr<ui::style::FontStyler> GetValue() const;
+ ClonePtr<ui::style::FontStyler> GetValue();
void SetValue(ui::style::FontStyler* value, bool trigger_change = true);
- ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
+ ClonePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
private:
properties::FontPropertyEditor font_editor_;
diff --git a/src/ThemeBuilder/components/stylers/MarginStylerEditor.cpp b/src/ThemeBuilder/components/stylers/MarginStylerEditor.cpp
index d7d89acb..bfd15903 100644
--- a/src/ThemeBuilder/components/stylers/MarginStylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/MarginStylerEditor.cpp
@@ -3,17 +3,17 @@
namespace cru::theme_builder::components::stylers {
MarginStylerEditor::MarginStylerEditor() {
- SetLabel(u"Margin Styler");
+ SetLabel("Margin Styler");
GetContainer()->AddChild(thickness_editor_.GetRootControl());
- thickness_editor_.SetLabel(u"Thickness");
+ thickness_editor_.SetLabel("Thickness");
ConnectChangeEvent(thickness_editor_);
}
MarginStylerEditor::~MarginStylerEditor() {}
-ClonablePtr<ui::style::MarginStyler> MarginStylerEditor::GetValue() {
+ClonePtr<ui::style::MarginStyler> MarginStylerEditor::GetValue() {
return ui::style::MarginStyler::Create(thickness_editor_.GetValue());
}
diff --git a/src/ThemeBuilder/components/stylers/MarginStylerEditor.h b/src/ThemeBuilder/components/stylers/MarginStylerEditor.h
index 9a1ca750..e27bf61e 100644
--- a/src/ThemeBuilder/components/stylers/MarginStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/MarginStylerEditor.h
@@ -1,7 +1,7 @@
#pragma once
#include "../properties/ThicknessPropertyEditor.h"
#include "StylerEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Styler.h"
namespace cru::theme_builder::components::stylers {
@@ -10,14 +10,14 @@ class MarginStylerEditor : public StylerEditor {
MarginStylerEditor();
~MarginStylerEditor() override;
- ClonablePtr<ui::style::MarginStyler> GetValue();
+ ClonePtr<ui::style::MarginStyler> GetValue();
void SetValue(ui::style::MarginStyler* styler, bool trigger_change = true);
- void SetValue(const ClonablePtr<ui::style::MarginStyler>& styler,
+ void SetValue(const ClonePtr<ui::style::MarginStyler>& styler,
bool trigger_change = true) {
SetValue(styler.get(), trigger_change);
}
- ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
+ ClonePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
private:
properties::ThicknessPropertyEditor thickness_editor_;
diff --git a/src/ThemeBuilder/components/stylers/PaddingStylerEditor.cpp b/src/ThemeBuilder/components/stylers/PaddingStylerEditor.cpp
index 476d21f1..1ad6cf35 100644
--- a/src/ThemeBuilder/components/stylers/PaddingStylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/PaddingStylerEditor.cpp
@@ -3,17 +3,17 @@
namespace cru::theme_builder::components::stylers {
PaddingStylerEditor::PaddingStylerEditor() {
- SetLabel(u"Padding Styler");
+ SetLabel("Padding Styler");
GetContainer()->AddChild(thickness_editor_.GetRootControl());
- thickness_editor_.SetLabel(u"Thickness");
+ thickness_editor_.SetLabel("Thickness");
ConnectChangeEvent(thickness_editor_);
}
PaddingStylerEditor::~PaddingStylerEditor() {}
-ClonablePtr<ui::style::PaddingStyler> PaddingStylerEditor::GetValue() {
+ClonePtr<ui::style::PaddingStyler> PaddingStylerEditor::GetValue() {
return ui::style::PaddingStyler::Create(thickness_editor_.GetValue());
}
diff --git a/src/ThemeBuilder/components/stylers/PaddingStylerEditor.h b/src/ThemeBuilder/components/stylers/PaddingStylerEditor.h
index 69565cad..e11918f8 100644
--- a/src/ThemeBuilder/components/stylers/PaddingStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/PaddingStylerEditor.h
@@ -1,7 +1,7 @@
#pragma once
#include "../properties/ThicknessPropertyEditor.h"
#include "StylerEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Styler.h"
namespace cru::theme_builder::components::stylers {
@@ -10,14 +10,14 @@ class PaddingStylerEditor : public StylerEditor {
PaddingStylerEditor();
~PaddingStylerEditor() override;
- ClonablePtr<ui::style::PaddingStyler> GetValue();
+ ClonePtr<ui::style::PaddingStyler> GetValue();
void SetValue(ui::style::PaddingStyler* styler, bool trigger_change = true);
- void SetValue(const ClonablePtr<ui::style::PaddingStyler>& styler,
+ void SetValue(const ClonePtr<ui::style::PaddingStyler>& styler,
bool trigger_change = true) {
SetValue(styler.get(), trigger_change);
}
- ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
+ ClonePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
private:
properties::ThicknessPropertyEditor thickness_editor_;
diff --git a/src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.cpp b/src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.cpp
index fb713c8c..d230e09c 100644
--- a/src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.cpp
@@ -3,12 +3,12 @@
namespace cru::theme_builder::components::stylers {
PreferredSizeStylerEditor::PreferredSizeStylerEditor() {
- SetLabel(u"Preferred Size Styler");
+ SetLabel("Preferred Size Styler");
GetContainer()->AddChild(width_editor_.GetRootControl());
GetContainer()->AddChild(height_editor_.GetRootControl());
- width_editor_.SetLabel(u"Width");
- height_editor_.SetLabel(u"Height");
+ width_editor_.SetLabel("Width");
+ height_editor_.SetLabel("Height");
ConnectChangeEvent(width_editor_);
ConnectChangeEvent(height_editor_);
@@ -16,7 +16,7 @@ PreferredSizeStylerEditor::PreferredSizeStylerEditor() {
PreferredSizeStylerEditor::~PreferredSizeStylerEditor() {}
-ClonablePtr<ui::style::PreferredSizeStyler>
+ClonePtr<ui::style::PreferredSizeStyler>
PreferredSizeStylerEditor::GetValue() {
return ui::style::PreferredSizeStyler::Create(ui::render::MeasureSize{
width_editor_.GetValue(), height_editor_.GetValue()});
@@ -24,8 +24,8 @@ PreferredSizeStylerEditor::GetValue() {
void PreferredSizeStylerEditor::SetValue(ui::style::PreferredSizeStyler* styler,
bool trigger_change) {
- width_editor_.SetValue(styler->GetPreferredSize().width, false);
- height_editor_.SetValue(styler->GetPreferredSize().height, false);
+ width_editor_.SetValue(styler->GetSuggestSize().width, false);
+ height_editor_.SetValue(styler->GetSuggestSize().height, false);
if (trigger_change) {
RaiseChangeEvent();
diff --git a/src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.h b/src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.h
index 36fdc3d6..2c83b533 100644
--- a/src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.h
@@ -1,7 +1,7 @@
#pragma once
#include "../properties/MeasureLengthPropertyEditor.h"
#include "StylerEditor.h"
-#include "cru/base/ClonablePtr.h"
+#include "cru/base/ClonePtr.h"
#include "cru/ui/style/Styler.h"
namespace cru::theme_builder::components::stylers {
@@ -10,15 +10,15 @@ class PreferredSizeStylerEditor : public StylerEditor {
PreferredSizeStylerEditor();
~PreferredSizeStylerEditor() override;
- ClonablePtr<ui::style::PreferredSizeStyler> GetValue();
+ ClonePtr<ui::style::PreferredSizeStyler> GetValue();
void SetValue(ui::style::PreferredSizeStyler* styler,
bool trigger_change = true);
- void SetValue(const ClonablePtr<ui::style::PreferredSizeStyler>& styler,
+ void SetValue(const ClonePtr<ui::style::PreferredSizeStyler>& styler,
bool trigger_change = true) {
SetValue(styler.get(), trigger_change);
}
- ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
+ ClonePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
private:
properties::MeasureLengthPropertyEditor width_editor_;
diff --git a/src/ThemeBuilder/components/stylers/StylerEditor.cpp b/src/ThemeBuilder/components/stylers/StylerEditor.cpp
index b3147a15..fbc97808 100644
--- a/src/ThemeBuilder/components/stylers/StylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/StylerEditor.cpp
@@ -8,7 +8,6 @@
#include "MarginStylerEditor.h"
#include "PaddingStylerEditor.h"
#include "PreferredSizeStylerEditor.h"
-#include "cru/base/Exception.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/render/FlexLayoutRenderObject.h"
#include "cru/ui/style/Styler.h"
@@ -58,7 +57,7 @@ std::unique_ptr<StylerEditor> CreateStylerEditor(ui::style::Styler* styler) {
editor->SetValue(font_styler);
return editor;
} else {
- throw Exception(u"Unknown styler type");
+ throw Exception("Unknown styler type");
}
}
} // namespace cru::theme_builder::components::stylers
diff --git a/src/ThemeBuilder/components/stylers/StylerEditor.h b/src/ThemeBuilder/components/stylers/StylerEditor.h
index 8aa52bda..8bd6af48 100644
--- a/src/ThemeBuilder/components/stylers/StylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/StylerEditor.h
@@ -9,7 +9,7 @@ class StylerEditor : public HeadBodyEditor {
~StylerEditor() override;
public:
- virtual ClonablePtr<ui::style::Styler> GetStyler() = 0;
+ virtual ClonePtr<ui::style::Styler> GetStyler() = 0;
};
std::unique_ptr<StylerEditor> CreateStylerEditor(ui::style::Styler* styler);