diff options
Diffstat (limited to 'src/ThemeBuilder/components/properties')
16 files changed, 52 insertions, 51 deletions
diff --git a/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h b/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h index f78ed6c9..8cdd541b 100644 --- a/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h @@ -15,8 +15,8 @@ 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)); } + std::string GetLabel() const { return label_.GetText(); } + void SetLabel(std::string label) { label_.SetText(std::move(label)); } bool GetValue() const { return check_box_.IsChecked(); } void SetValue(bool value, bool trigger_change = true); diff --git a/src/ThemeBuilder/components/properties/ColorPropertyEditor.cpp b/src/ThemeBuilder/components/properties/ColorPropertyEditor.cpp index 0fe3908e..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() @@ -20,12 +20,12 @@ ColorPropertyEditor::ColorPropertyEditor() { color_cube_.SetForegroundBrush(color_cube_brush_); - color_text_.SetText(String::FromUtf8(color_.ToString())); + color_text_.SetText(color_.ToString()); color_text_.SetMargin(ui::Thickness(10, 0, 0, 0)); color_text_.TextChangeEvent()->AddHandler([this](std::nullptr_t) { auto text = color_text_.GetTextView(); - auto color = ui::Color::Parse(text.ToUtf8()); + auto color = ui::Color::Parse(text); if (color) { color_ = *color; color_cube_brush_->SetColor(*color); @@ -43,6 +43,6 @@ ColorPropertyEditor::~ColorPropertyEditor() {} void ColorPropertyEditor::SetValue(const ui::Color &color, bool trigger_change) { if (!trigger_change) SuppressNextChangeEvent(); - color_text_.SetText(String::FromUtf8(color.ToString())); + color_text_.SetText(color.ToString()); } } // namespace cru::theme_builder::components::properties diff --git a/src/ThemeBuilder/components/properties/ColorPropertyEditor.h b/src/ThemeBuilder/components/properties/ColorPropertyEditor.h index aa6cfcfa..7c76297b 100644 --- a/src/ThemeBuilder/components/properties/ColorPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/ColorPropertyEditor.h @@ -17,8 +17,8 @@ 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)); } + std::string GetLabel() const { return label_.GetText(); } + void SetLabel(std::string label) { label_.SetText(std::move(label)); } ui::Color GetValue() const { return color_; } void SetValue(const ui::Color& color, bool trigger_change = true); diff --git a/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp b/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp index fc86b0ed..47a51ddd 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()); diff --git a/src/ThemeBuilder/components/properties/FontPropertyEditor.cpp b/src/ThemeBuilder/components/properties/FontPropertyEditor.cpp index 927ada7d..231e45dd 100644 --- a/src/ThemeBuilder/components/properties/FontPropertyEditor.cpp +++ b/src/ThemeBuilder/components/properties/FontPropertyEditor.cpp @@ -20,12 +20,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( diff --git a/src/ThemeBuilder/components/properties/FontPropertyEditor.h b/src/ThemeBuilder/components/properties/FontPropertyEditor.h index d349f1f2..ec6a6b56 100644 --- a/src/ThemeBuilder/components/properties/FontPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/FontPropertyEditor.h @@ -17,8 +17,8 @@ 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::string GetLabelText() const { return label_.GetText(); } + void SetLabelText(std::string label) { label_.SetText(std::move(label)); } std::shared_ptr<platform::graphics::IFont> GetValue() const; void SetValue(std::shared_ptr<platform::graphics::IFont> value, diff --git a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp index 9280718d..001665ae 100644 --- a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp +++ b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp @@ -10,12 +10,12 @@ 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().ToUtf8()); + measure_length_mapper->MapFromString(text); measure_length_ = measure_length; is_text_valid_ = true; RaiseChangeEvent(); @@ -32,8 +32,7 @@ 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()))); + ? "unspecified" + : std::to_string(measure_length_.GetLengthOrUndefined())); } } // namespace cru::theme_builder::components::properties diff --git a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h index 43e783c5..ee99579f 100644 --- a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h @@ -18,8 +18,8 @@ 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)); } + std::string GetLabel() const { return label_.GetText(); } + void SetLabel(std::string label) { label_.SetText(std::move(label)); } PropertyType GetValue() const { return measure_length_; } void SetValue(const PropertyType& value, bool trigger_change = true); diff --git a/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h b/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h index 0f22616a..8db14114 100644 --- a/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h @@ -28,8 +28,8 @@ 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)); } + std::string GetLabel() const { return label_.GetText(); } + void SetLabel(std::string label) { label_.SetText(std::move(label)); } bool IsEnabled() const { return check_box_.IsChecked(); } void SetEnabled(bool enabled, bool trigger_change = true) { diff --git a/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp b/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp index 8d7ac942..82fee18f 100644 --- a/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp +++ b/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp @@ -10,11 +10,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().ToUtf8()); + auto point = point_mapper->MapFromString(text); point_ = point; is_text_valid_ = true; RaiseChangeEvent(); @@ -33,7 +33,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..4f078c8b 100644 --- a/src/ThemeBuilder/components/properties/PointPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/PointPropertyEditor.h @@ -15,14 +15,14 @@ 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)); } + std::string GetLabel() const { return label_.GetText(); } + void SetLabel(std::string label) { label_.SetText(std::move(label)); } ui::Point GetValue() const { 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_; diff --git a/src/ThemeBuilder/components/properties/SelectPropertyEditor.h b/src/ThemeBuilder/components/properties/SelectPropertyEditor.h index 475d2d0a..0d6cbfcd 100644 --- a/src/ThemeBuilder/components/properties/SelectPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/SelectPropertyEditor.h @@ -15,8 +15,8 @@ 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)); } + std::string GetLabel() const { return label_.GetText(); } + void SetLabel(std::string label) { label_.SetText(std::move(label)); } Index GetSelectedIndex() const { return select_.GetSelectedIndex(); } void SetSelectedIndex(Index index, bool trigger_change = true) { @@ -24,8 +24,8 @@ class SelectPropertyEditor : public Editor { select_.SetSelectedIndex(index); } - std::vector<String> GetItems() const { return select_.GetItems(); } - void SetItems(std::vector<String> items) { + std::vector<std::string> GetItems() const { return select_.GetItems(); } + void SetItems(std::vector<std::string> items) { select_.SetItems(std::move(items)); } 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..040f776a 100644 --- a/src/ThemeBuilder/components/properties/TextPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/TextPropertyEditor.h @@ -12,16 +12,16 @@ class TextPropertyEditor : public ui::components::Component { ui::controls::Control* GetRootControl() override { return &container_; } - String GetLabel() const { return label_.GetText(); } - void SetLabel(String label) { label_.SetText(std::move(label)); } + std::string GetLabel() const { return label_.GetText(); } + void SetLabel(std::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() const { return editor_.GetText(); } + std::string_view GetTextView() const { 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 0790cd98..2ee13c06 100644 --- a/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp +++ b/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp @@ -1,4 +1,5 @@ #include "ThicknessPropertyEditor.h" +#include <format> #include "cru/base/Format.h" #include "cru/ui/mapper/MapperRegistry.h" #include "cru/ui/mapper/ThicknessMapper.h" @@ -13,7 +14,7 @@ ThicknessPropertyEditor::ThicknessPropertyEditor() { auto thickness_mapper = ui::mapper::MapperRegistry::GetInstance()->GetMapper<ui::Thickness>(); try { - auto thickness = thickness_mapper->MapFromString(text.ToUtf8()); + auto thickness = thickness_mapper->MapFromString(text); thickness_ = thickness; is_text_valid_ = true; RaiseChangeEvent(); @@ -29,7 +30,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..dae2e612 100644 --- a/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h @@ -14,8 +14,8 @@ 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)); } + std::string GetLabel() const { return label_.GetText(); } + void SetLabel(std::string label) { label_.SetText(std::move(label)); } ui::Thickness GetValue() const { return thickness_; } void SetValue(const ui::Thickness& thickness, bool trigger_change = true); |