aboutsummaryrefslogtreecommitdiff
path: root/src/ThemeBuilder/components/properties
diff options
context:
space:
mode:
Diffstat (limited to 'src/ThemeBuilder/components/properties')
-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
17 files changed, 63 insertions, 101 deletions
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_;
};