diff options
Diffstat (limited to 'src/ThemeBuilder/components/properties')
13 files changed, 34 insertions, 71 deletions
diff --git a/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h b/src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h index 8cdd541b..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_; } - std::string GetLabel() const { return label_.GetText(); } - void SetLabel(std::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.h b/src/ThemeBuilder/components/properties/ColorPropertyEditor.h index 7c76297b..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_; } - std::string GetLabel() const { return label_.GetText(); } - void SetLabel(std::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 47a51ddd..5b50ad38 100644 --- a/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp +++ b/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp @@ -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 231e45dd..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; @@ -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 ec6a6b56..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; - 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; + 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.h b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h index ee99579f..dd4101bf 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,9 +16,6 @@ class MeasureLengthPropertyEditor : public Editor { public: ui::controls::Control* GetRootControl() override { return &container_; } - 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); @@ -28,7 +23,6 @@ class MeasureLengthPropertyEditor : public Editor { 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 8db14114..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_; } - std::string GetLabel() const { return label_.GetText(); } - void SetLabel(std::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 82fee18f..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> diff --git a/src/ThemeBuilder/components/properties/PointPropertyEditor.h b/src/ThemeBuilder/components/properties/PointPropertyEditor.h index 4f078c8b..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,10 +15,7 @@ class PointPropertyEditor : public Editor { public: ui::controls::Control* GetRootControl() override { return &container_; } - std::string GetLabel() const { return label_.GetText(); } - void SetLabel(std::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: @@ -28,7 +25,6 @@ class PointPropertyEditor : public Editor { 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 0d6cbfcd..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_; } - std::string GetLabel() const { return label_.GetText(); } - void SetLabel(std::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<std::string> GetItems() const { return select_.GetItems(); } + 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.h b/src/ThemeBuilder/components/properties/TextPropertyEditor.h index 040f776a..433143cd 100644 --- a/src/ThemeBuilder/components/properties/TextPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/TextPropertyEditor.h @@ -1,22 +1,21 @@ #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_; } - std::string GetLabel() const { return label_.GetText(); } - void SetLabel(std::string label) { label_.SetText(std::move(label)); } - - std::string GetText() const { return editor_.GetText(); } - std::string_view GetTextView() const { return editor_.GetTextView(); } + std::string GetText() { return editor_.GetText(); } + std::string_view GetTextView() { return editor_.GetTextView(); } void SetText(std::string text) { editor_.SetText(std::move(text)); } protected: diff --git a/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h b/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h index dae2e612..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_; } - std::string GetLabel() const { return label_.GetText(); } - void SetLabel(std::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_; }; |
