aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ThemeBuilder/components/HeadBodyEditor.h9
-rw-r--r--src/ThemeBuilder/components/LabeledMixin.h13
-rw-r--r--src/ThemeBuilder/components/conditions/CheckedConditionEditor.cpp3
-rw-r--r--src/ThemeBuilder/components/conditions/CheckedConditionEditor.h6
-rw-r--r--src/ThemeBuilder/components/conditions/ClickStateConditionEditor.cpp3
-rw-r--r--src/ThemeBuilder/components/conditions/ClickStateConditionEditor.h7
-rw-r--r--src/ThemeBuilder/components/conditions/CompoundConditionEditor.h12
-rw-r--r--src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp2
-rw-r--r--src/ThemeBuilder/components/conditions/FocusConditionEditor.h6
-rw-r--r--src/ThemeBuilder/components/properties/CheckBoxPropertyEditor.h10
-rw-r--r--src/ThemeBuilder/components/properties/ColorPropertyEditor.h10
-rw-r--r--src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp2
-rw-r--r--src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.h2
-rw-r--r--src/ThemeBuilder/components/properties/FontPropertyEditor.cpp4
-rw-r--r--src/ThemeBuilder/components/properties/FontPropertyEditor.h9
-rw-r--r--src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.h10
-rw-r--r--src/ThemeBuilder/components/properties/OptionalPropertyEditor.h12
-rw-r--r--src/ThemeBuilder/components/properties/PointPropertyEditor.cpp1
-rw-r--r--src/ThemeBuilder/components/properties/PointPropertyEditor.h10
-rw-r--r--src/ThemeBuilder/components/properties/SelectPropertyEditor.h14
-rw-r--r--src/ThemeBuilder/components/properties/TextPropertyEditor.h11
-rw-r--r--src/ThemeBuilder/components/properties/ThicknessPropertyEditor.h10
-rw-r--r--src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp3
-rw-r--r--src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.h3
-rw-r--r--src/ThemeBuilder/components/stylers/FontStylerEditor.cpp4
-rw-r--r--src/ThemeBuilder/components/stylers/FontStylerEditor.h3
-rw-r--r--src/platform/gui/win/Keyboard.cpp2
-rw-r--r--src/platform/gui/win/Window.cpp10
-rw-r--r--src/ui/components/Input.cpp14
-rw-r--r--src/ui/controls/Button.cpp5
-rw-r--r--src/ui/controls/CheckBox.cpp9
-rw-r--r--src/ui/controls/Container.cpp8
-rw-r--r--src/ui/controls/Control.cpp19
-rw-r--r--src/ui/controls/FlexLayout.cpp11
-rw-r--r--src/ui/controls/IconButton.cpp30
-rw-r--r--src/ui/controls/ScrollView.cpp4
-rw-r--r--src/ui/controls/StackLayout.cpp7
-rw-r--r--src/ui/controls/TextBlock.cpp29
-rw-r--r--src/ui/controls/TextBox.cpp11
-rw-r--r--src/ui/controls/TreeView.cpp5
-rw-r--r--src/ui/controls/Window.cpp6
41 files changed, 143 insertions, 206 deletions
diff --git a/src/ThemeBuilder/components/HeadBodyEditor.h b/src/ThemeBuilder/components/HeadBodyEditor.h
index c8671841..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_; }
- std::string GetLabel() const { return label_.GetText(); }
- void SetLabel(std::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/conditions/CheckedConditionEditor.cpp b/src/ThemeBuilder/components/conditions/CheckedConditionEditor.cpp
index e207c761..b45006db 100644
--- a/src/ThemeBuilder/components/conditions/CheckedConditionEditor.cpp
+++ b/src/ThemeBuilder/components/conditions/CheckedConditionEditor.cpp
@@ -14,8 +14,7 @@ CheckedConditionEditor::CheckedConditionEditor() {
CheckedConditionEditor::~CheckedConditionEditor() {}
-ClonePtr<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 c83a1cff..6fc6f97f 100644
--- a/src/ThemeBuilder/components/conditions/CheckedConditionEditor.h
+++ b/src/ThemeBuilder/components/conditions/CheckedConditionEditor.h
@@ -11,16 +11,14 @@ class CheckedConditionEditor : public ConditionEditor {
~CheckedConditionEditor() override;
public:
- ClonePtr<ui::style::CheckedCondition> GetValue() const;
+ ClonePtr<ui::style::CheckedCondition> GetValue();
void SetValue(ui::style::CheckedCondition* value, bool trigger_change = true);
void SetValue(const ClonePtr<ui::style::CheckedCondition>& value,
bool trigger_change = true) {
SetValue(value.get(), trigger_change);
}
- ClonePtr<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 24e83a0e..4862fd47 100644
--- a/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.cpp
+++ b/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.cpp
@@ -55,8 +55,7 @@ ClickStateConditionEditor::ClickStateConditionEditor() {
ClickStateConditionEditor::~ClickStateConditionEditor() {}
-ClonePtr<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 24d60f7b..6929732c 100644
--- a/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.h
+++ b/src/ThemeBuilder/components/conditions/ClickStateConditionEditor.h
@@ -2,7 +2,6 @@
#include "../properties/SelectPropertyEditor.h"
#include "ConditionEditor.h"
#include "cru/base/ClonePtr.h"
-#include "cru/base/Event.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
@@ -12,7 +11,7 @@ class ClickStateConditionEditor : public ConditionEditor {
~ClickStateConditionEditor();
public:
- ClonePtr<ui::style::ClickStateCondition> GetValue() const;
+ ClonePtr<ui::style::ClickStateCondition> GetValue();
void SetValue(ui::style::ClickStateCondition* value,
bool trigger_change = true);
void SetValue(const ClonePtr<ui::style::ClickStateCondition>& value,
@@ -20,9 +19,7 @@ class ClickStateConditionEditor : public ConditionEditor {
SetValue(value.get(), trigger_change);
}
- ClonePtr<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.h b/src/ThemeBuilder/components/conditions/CompoundConditionEditor.h
index c0f0891a..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/ClonePtr.h"
-#include "cru/base/Event.h"
-#include "cru/ui/components/Component.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 {
@@ -28,10 +24,6 @@ class CompoundConditionEditor : public ConditionEditor {
class AndConditionEditor : public CompoundConditionEditor {
public:
- AndConditionEditor() = default;
- ~AndConditionEditor() override = default;
-
- public:
ClonePtr<ui::style::AndCondition> GetValue() {
return ui::style::AndCondition::Create(GetChildren());
}
@@ -50,10 +42,6 @@ class AndConditionEditor : public CompoundConditionEditor {
class OrConditionEditor : public CompoundConditionEditor {
public:
- OrConditionEditor() = default;
- ~OrConditionEditor() override = default;
-
- public:
ClonePtr<ui::style::OrCondition> GetValue() {
return ui::style::OrCondition::Create(GetChildren());
}
diff --git a/src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp b/src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp
index 67a660d1..356f42ef 100644
--- a/src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp
+++ b/src/ThemeBuilder/components/conditions/FocusConditionEditor.cpp
@@ -14,7 +14,7 @@ FocusConditionEditor::FocusConditionEditor() {
FocusConditionEditor::~FocusConditionEditor() {}
-ClonePtr<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 c9c8018e..1cfb883f 100644
--- a/src/ThemeBuilder/components/conditions/FocusConditionEditor.h
+++ b/src/ThemeBuilder/components/conditions/FocusConditionEditor.h
@@ -11,16 +11,14 @@ class FocusConditionEditor : public ConditionEditor {
~FocusConditionEditor() override;
public:
- ClonePtr<ui::style::FocusCondition> GetValue() const;
+ ClonePtr<ui::style::FocusCondition> GetValue();
void SetValue(ui::style::FocusCondition* value, bool trigger_change = true);
void SetValue(const ClonePtr<ui::style::FocusCondition>& value,
bool trigger_change = true) {
SetValue(value.get(), trigger_change);
}
- ClonePtr<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/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_;
};
diff --git a/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp b/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp
index 00b40d10..98bc14b7 100644
--- a/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp
+++ b/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp
@@ -12,8 +12,7 @@ ContentBrushStylerEditor::ContentBrushStylerEditor() {
ContentBrushStylerEditor::~ContentBrushStylerEditor() {}
-ClonePtr<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 91e8adc2..b1b179a1 100644
--- a/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.h
@@ -1,5 +1,4 @@
#pragma once
-#include "../Editor.h"
#include "../properties/ColorPropertyEditor.h"
#include "StylerEditor.h"
#include "cru/base/ClonePtr.h"
@@ -12,7 +11,7 @@ class ContentBrushStylerEditor : public StylerEditor {
~ContentBrushStylerEditor();
public:
- ClonePtr<ui::style::ContentBrushStyler> GetValue() const;
+ ClonePtr<ui::style::ContentBrushStyler> GetValue();
void SetValue(ui::style::ContentBrushStyler* value,
bool trigger_change = true);
diff --git a/src/ThemeBuilder/components/stylers/FontStylerEditor.cpp b/src/ThemeBuilder/components/stylers/FontStylerEditor.cpp
index c8687e6d..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() {}
-ClonePtr<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 a5145e31..11c931d3 100644
--- a/src/ThemeBuilder/components/stylers/FontStylerEditor.h
+++ b/src/ThemeBuilder/components/stylers/FontStylerEditor.h
@@ -1,5 +1,4 @@
#pragma once
-#include "../Editor.h"
#include "../properties/FontPropertyEditor.h"
#include "StylerEditor.h"
#include "cru/base/ClonePtr.h"
@@ -12,7 +11,7 @@ class FontStylerEditor : public StylerEditor {
~FontStylerEditor();
public:
- ClonePtr<ui::style::FontStyler> GetValue() const;
+ ClonePtr<ui::style::FontStyler> GetValue();
void SetValue(ui::style::FontStyler* value, bool trigger_change = true);
ClonePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
diff --git a/src/platform/gui/win/Keyboard.cpp b/src/platform/gui/win/Keyboard.cpp
index f4286fbc..29932ff3 100644
--- a/src/platform/gui/win/Keyboard.cpp
+++ b/src/platform/gui/win/Keyboard.cpp
@@ -64,7 +64,7 @@ KeyCode VirtualKeyToKeyCode(int virtual_key) {
}
}
-KeyModifier RetrieveKeyMofifier() {
+KeyModifier RetrieveKeyModifier() {
KeyModifier result{0};
if (::GetKeyState(VK_SHIFT) < 0) result |= KeyModifiers::Shift;
if (::GetKeyState(VK_CONTROL) < 0) result |= KeyModifiers::Ctrl;
diff --git a/src/platform/gui/win/Window.cpp b/src/platform/gui/win/Window.cpp
index eb5112f5..2c0bc5a1 100644
--- a/src/platform/gui/win/Window.cpp
+++ b/src/platform/gui/win/Window.cpp
@@ -585,29 +585,29 @@ void WinNativeWindow::OnMouseLeaveInternal() {
void WinNativeWindow::OnMouseDownInternal(platform::gui::MouseButton button,
POINT point) {
const auto dip_point = PixelToDip(point);
- mouse_down_event_.Raise({button, dip_point, RetrieveKeyMofifier()});
+ mouse_down_event_.Raise({button, dip_point, RetrieveKeyModifier()});
}
void WinNativeWindow::OnMouseUpInternal(platform::gui::MouseButton button,
POINT point) {
const auto dip_point = PixelToDip(point);
- mouse_up_event_.Raise({button, dip_point, RetrieveKeyMofifier()});
+ mouse_up_event_.Raise({button, dip_point, RetrieveKeyModifier()});
}
void WinNativeWindow::OnMouseWheelInternal(short delta, POINT point) {
const auto dip_point = PixelToDip(point);
const float d = -((float)delta / 120.f);
- mouse_wheel_event_.Raise({d, dip_point, RetrieveKeyMofifier()});
+ mouse_wheel_event_.Raise({d, dip_point, RetrieveKeyModifier()});
}
void WinNativeWindow::OnKeyDownInternal(int virtual_code) {
key_down_event_.Raise(
- {VirtualKeyToKeyCode(virtual_code), RetrieveKeyMofifier()});
+ {VirtualKeyToKeyCode(virtual_code), RetrieveKeyModifier()});
}
void WinNativeWindow::OnKeyUpInternal(int virtual_code) {
key_up_event_.Raise(
- {VirtualKeyToKeyCode(virtual_code), RetrieveKeyMofifier()});
+ {VirtualKeyToKeyCode(virtual_code), RetrieveKeyModifier()});
}
void WinNativeWindow::OnActivatedInternal() {}
diff --git a/src/ui/components/Input.cpp b/src/ui/components/Input.cpp
index 0a14c7b8..770cfc86 100644
--- a/src/ui/components/Input.cpp
+++ b/src/ui/components/Input.cpp
@@ -19,11 +19,11 @@ Input::~Input() {}
controls::Control* Input::GetRootControl() { return &text_box_; }
-std::string Input::GetText() const { return text_box_.GetText(); }
+std::string Input::GetText() { return text_box_.GetText(); }
void Input::SetText(std::string text) { text_box_.SetText(std::move(text)); }
-IInputValidator* Input::GetValidator() const { return validator_; }
+IInputValidator* Input::GetValidator() { return validator_; }
void Input::SetValidator(IInputValidator* validator) {
validator_ = validator;
@@ -38,11 +38,11 @@ InputValidateResult Input::Validate() {
return last_validate_result_;
}
-InputValidateResult Input::GetLastValidateResult() const {
+InputValidateResult Input::GetLastValidateResult() {
return last_validate_result_;
}
-InputValidateResult FloatInputValidator::Validate(std::string_view text) const {
+InputValidateResult FloatInputValidator::Validate(std::string_view text) {
auto result = cru::string::ParseToNumber<float>(
text, cru::string::ParseToNumberFlags::AllowLeadingSpaces |
cru::string::ParseToNumberFlags::AllowTrailingSpaces);
@@ -77,18 +77,18 @@ FloatInput::FloatInput() {
FloatInput::~FloatInput() {}
-float FloatInput::GetValue() const { return value_; }
+float FloatInput::GetValue() { return value_; }
void FloatInput::SetValue(float value) { SetText(std::to_string(value)); }
-std::optional<float> FloatInput::GetMin() const { return validator_.min; }
+std::optional<float> FloatInput::GetMin() { return validator_.min; }
void FloatInput::SetMin(std::optional<float> min) {
validator_.min = std::move(min);
Validate();
}
-std::optional<float> FloatInput::GetMax() const { return validator_.max; }
+std::optional<float> FloatInput::GetMax() { return validator_.max; }
void FloatInput::SetMax(std::optional<float> max) {
validator_.max = std::move(max);
diff --git a/src/ui/controls/Button.cpp b/src/ui/controls/Button.cpp
index a44a7074..4d897f08 100644
--- a/src/ui/controls/Button.cpp
+++ b/src/ui/controls/Button.cpp
@@ -1,11 +1,12 @@
#include "cru/ui/controls/Button.h"
-
#include "cru/ui/ThemeManager.h"
#include "cru/ui/helper/ClickDetector.h"
#include "cru/ui/render/BorderRenderObject.h"
namespace cru::ui::controls {
-Button::Button() : click_detector_(this) {
+Button::Button()
+ : SingleChildControl<render::BorderRenderObject>(kControlName),
+ click_detector_(this) {
GetContainerRenderObject()->SetBorderEnabled(true);
auto default_button_style =
ThemeManager::GetInstance()->GetResourceStyleRuleSet("button.style");
diff --git a/src/ui/controls/CheckBox.cpp b/src/ui/controls/CheckBox.cpp
index 778a7b4f..a6cac1a1 100644
--- a/src/ui/controls/CheckBox.cpp
+++ b/src/ui/controls/CheckBox.cpp
@@ -5,11 +5,10 @@
namespace cru::ui::controls {
CheckBox::CheckBox()
- : container_render_object_(new render::BorderRenderObject()),
- click_detector_(this) {
- container_render_object_->SetAttachedControl(this);
+ : Control(kControlName), checked_(false), click_detector_(this) {
+ container_render_object_.SetAttachedControl(this);
- container_render_object_->SetBorderEnabled(true);
+ container_render_object_.SetBorderEnabled(true);
auto default_checkbox_style =
ThemeManager::GetInstance()->GetResourceStyleRuleSet("checkbox.style");
GetStyleRuleSet()->SetParent(std::move(default_checkbox_style));
@@ -26,6 +25,6 @@ void CheckBox::SetChecked(bool checked) {
}
void CheckBox::ApplyBorderStyle(const style::ApplyBorderStyleInfo& style) {
- container_render_object_->ApplyBorderStyle(style);
+ container_render_object_.ApplyBorderStyle(style);
}
} // namespace cru::ui::controls
diff --git a/src/ui/controls/Container.cpp b/src/ui/controls/Container.cpp
index 7b0c10a9..32efa233 100644
--- a/src/ui/controls/Container.cpp
+++ b/src/ui/controls/Container.cpp
@@ -1,11 +1,7 @@
#include "cru/ui/controls/Container.h"
-
-#include "cru/platform/graphics/Factory.h"
#include "cru/ui/render/BorderRenderObject.h"
-#include "cru/ui/render/RenderObject.h"
namespace cru::ui::controls {
-Container::Container() {}
-
-Container::~Container() = default;
+Container::Container()
+ : SingleChildControl<render::BorderRenderObject>(kControlName) {}
} // namespace cru::ui::controls
diff --git a/src/ui/controls/Control.cpp b/src/ui/controls/Control.cpp
index 70a3b1f3..41644755 100644
--- a/src/ui/controls/Control.cpp
+++ b/src/ui/controls/Control.cpp
@@ -14,7 +14,8 @@ using platform::gui::ICursor;
using platform::gui::IUiApplication;
using platform::gui::SystemCursorType;
-Control::Control() {
+Control::Control(std::string name)
+ : name_(std::move(name)), host_(nullptr), parent_(nullptr) {
style_rule_set_ = std::make_shared<style::StyleRuleSet>();
style_rule_set_bind_ =
std::make_unique<style::StyleRuleSetBind>(this, style_rule_set_);
@@ -30,9 +31,10 @@ Control::~Control() {
RemoveAllChild();
}
-std::string Control::GetDebugId() const {
- return std::format("{}({})", GetControlType(),
- static_cast<const void*>(this));
+std::string Control::GetName() { return name_; }
+
+std::string Control::GetDebugId() {
+ return std::format("{}({})", GetName(), static_cast<const void*>(this));
}
ControlHost* Control::GetControlHost() { return host_; }
@@ -50,6 +52,15 @@ bool Control::HasAncestor(Control* control) {
const std::vector<Control*>& Control::GetChildren() { return children_; }
+Index Control::IndexOfChild(Control* control) {
+ const auto& children = GetChildren();
+ auto iter = std::ranges::find(children, control);
+ if (iter == children.cend()) {
+ return -1;
+ }
+ return iter - children.begin();
+}
+
void Control::RemoveChild(Control* child) {
auto iter = std::ranges::find(children_, child);
if (iter != children_.cend()) {
diff --git a/src/ui/controls/FlexLayout.cpp b/src/ui/controls/FlexLayout.cpp
index 8d71cfdb..ffe953d7 100644
--- a/src/ui/controls/FlexLayout.cpp
+++ b/src/ui/controls/FlexLayout.cpp
@@ -1,11 +1,10 @@
#include "cru/ui/controls/FlexLayout.h"
namespace cru::ui::controls {
-FlexLayout::FlexLayout() = default;
+FlexLayout::FlexLayout()
+ : LayoutControl<render::FlexLayoutRenderObject>(kControlName) {}
-FlexLayout::~FlexLayout() = default;
-
-FlexMainAlignment FlexLayout::GetContentMainAlign() const {
+FlexMainAlignment FlexLayout::GetContentMainAlign() {
return GetContainerRenderObject()->GetContentMainAlign();
}
@@ -13,7 +12,7 @@ void FlexLayout::SetContentMainAlign(FlexMainAlignment value) {
GetContainerRenderObject()->SetContentMainAlign(value);
}
-FlexDirection FlexLayout::GetFlexDirection() const {
+FlexDirection FlexLayout::GetFlexDirection() {
return GetContainerRenderObject()->GetFlexDirection();
}
@@ -21,7 +20,7 @@ void FlexLayout::SetFlexDirection(FlexDirection direction) {
GetContainerRenderObject()->SetFlexDirection(direction);
}
-FlexCrossAlignment FlexLayout::GetItemCrossAlign() const {
+FlexCrossAlignment FlexLayout::GetItemCrossAlign() {
return GetContainerRenderObject()->GetItemCrossAlign();
}
diff --git a/src/ui/controls/IconButton.cpp b/src/ui/controls/IconButton.cpp
index 059a7784..e20e422f 100644
--- a/src/ui/controls/IconButton.cpp
+++ b/src/ui/controls/IconButton.cpp
@@ -1,20 +1,16 @@
#include "cru/ui/controls/IconButton.h"
-
-#include "../Helper.h"
#include "cru/platform/graphics/Factory.h"
#include "cru/platform/graphics/Geometry.h"
+#include "cru/platform/gui/UiApplication.h"
#include "cru/ui/ThemeManager.h"
namespace cru::ui::controls {
-IconButton::IconButton()
- : container_render_object_(new render::BorderRenderObject()),
- geometry_render_object_(new render::GeometryRenderObject()),
- click_detector_(this) {
- container_render_object_->SetChild(geometry_render_object_.get());
- container_render_object_->SetAttachedControl(this);
- geometry_render_object_->SetAttachedControl(this);
-
- container_render_object_->SetBorderEnabled(true);
+IconButton::IconButton() : Control(kControlName), click_detector_(this) {
+ container_render_object_.SetChild(&geometry_render_object_);
+ container_render_object_.SetAttachedControl(this);
+ geometry_render_object_.SetAttachedControl(this);
+
+ container_render_object_.SetBorderEnabled(true);
GetStyleRuleSet()->SetParent(
ThemeManager::GetInstance()->GetResourceStyleRuleSet(
"icon-button.style"));
@@ -29,14 +25,18 @@ IconButton::IconButton(std::string_view icon_svg_path_data_string,
IconButton::~IconButton() {}
void IconButton::SetIconFillColor(const Color& color) {
- SetIconFillBrush(GetGraphicsFactory()->CreateSolidColorBrush(color));
+ SetIconFillBrush(platform::gui::IUiApplication::GetInstance()
+ ->GetGraphicsFactory()
+ ->CreateSolidColorBrush(color));
}
void IconButton::SetIconWithSvgPathDataString(
std::string_view icon_svg_path_data_string, const Rect& view_port) {
- SetIconGeometry(platform::graphics::CreateGeometryFromSvgPathData(
- GetGraphicsFactory(), icon_svg_path_data_string),
- view_port);
+ SetIconGeometry(
+ platform::graphics::CreateGeometryFromSvgPathData(
+ platform::gui::IUiApplication::GetInstance()->GetGraphicsFactory(),
+ icon_svg_path_data_string),
+ view_port);
}
void IconButton::SetIconWithSvgPathDataStringResourceKey(
diff --git a/src/ui/controls/ScrollView.cpp b/src/ui/controls/ScrollView.cpp
index f3b3750f..e156f643 100644
--- a/src/ui/controls/ScrollView.cpp
+++ b/src/ui/controls/ScrollView.cpp
@@ -1,7 +1,7 @@
#include "cru/ui/controls/ScrollView.h"
namespace cru::ui::controls {
-ScrollView::ScrollView() {}
+ScrollView::ScrollView()
+ : SingleChildControl<render::ScrollRenderObject>(kControlName) {}
-ScrollView::~ScrollView() {}
} // namespace cru::ui::controls
diff --git a/src/ui/controls/StackLayout.cpp b/src/ui/controls/StackLayout.cpp
index 55964bcd..b5ca8f35 100644
--- a/src/ui/controls/StackLayout.cpp
+++ b/src/ui/controls/StackLayout.cpp
@@ -1,9 +1,6 @@
#include "cru/ui/controls/StackLayout.h"
namespace cru::ui::controls {
-using render::StackLayoutRenderObject;
-
-StackLayout::StackLayout() = default;
-
-StackLayout::~StackLayout() = default;
+StackLayout::StackLayout()
+ : LayoutControl<render::StackLayoutRenderObject>(kControlName) {}
} // namespace cru::ui::controls
diff --git a/src/ui/controls/TextBlock.cpp b/src/ui/controls/TextBlock.cpp
index 790c534b..a36c6b41 100644
--- a/src/ui/controls/TextBlock.cpp
+++ b/src/ui/controls/TextBlock.cpp
@@ -1,20 +1,15 @@
#include "cru/ui/controls/TextBlock.h"
-
-#include "../Helper.h"
#include "cru/platform/graphics/Factory.h"
#include "cru/platform/gui/UiApplication.h"
#include "cru/ui/ThemeManager.h"
-#include "cru/ui/render/CanvasRenderObject.h"
-#include "cru/ui/render/StackLayoutRenderObject.h"
#include "cru/ui/render/TextRenderObject.h"
-namespace cru::ui::controls {
-using render::TextRenderObject;
-
-TextBlock::TextBlock() {
- const auto theme_manager = ThemeManager::GetInstance();
+#include <memory>
- text_render_object_ = std::make_unique<TextRenderObject>(
+namespace cru::ui::controls {
+TextBlock::TextBlock() : Control(kControlName) {
+ auto theme_manager = ThemeManager::GetInstance();
+ text_render_object_ = std::make_unique<render::TextRenderObject>(
theme_manager->GetResourceBrush("text.brush"),
theme_manager->GetResourceFont("text.font"),
theme_manager->GetResourceBrush("text.selection.brush"),
@@ -23,30 +18,28 @@ TextBlock::TextBlock() {
text_render_object_->SetAttachedControl(this);
service_ = std::make_unique<TextHostControlService>(this);
-
service_->SetEnabled(false);
service_->SetEditable(false);
}
-TextBlock::~TextBlock() = default;
-
-render::RenderObject* TextBlock::GetRenderObject() const {
+render::RenderObject* TextBlock::GetRenderObject() {
return text_render_object_.get();
}
-std::string TextBlock::GetText() const { return service_->GetText(); }
+std::string TextBlock::GetText() { return service_->GetText(); }
void TextBlock::SetText(std::string text) {
service_->SetText(std::move(text));
}
-bool TextBlock::IsSelectable() const { return service_->IsEnabled(); }
+bool TextBlock::IsSelectable() { return service_->IsEnabled(); }
void TextBlock::SetSelectable(bool value) { service_->SetEnabled(value); }
void TextBlock::SetTextColor(const Color& color) {
- text_render_object_->SetBrush(
- GetUiApplication()->GetGraphicsFactory()->CreateSolidColorBrush(color));
+ text_render_object_->SetBrush(platform::gui::IUiApplication::GetInstance()
+ ->GetGraphicsFactory()
+ ->CreateSolidColorBrush(color));
}
render::TextRenderObject* TextBlock::GetTextRenderObject() {
diff --git a/src/ui/controls/TextBox.cpp b/src/ui/controls/TextBox.cpp
index 70695a01..1e35de69 100644
--- a/src/ui/controls/TextBox.cpp
+++ b/src/ui/controls/TextBox.cpp
@@ -2,9 +2,7 @@
#include "cru/ui/ThemeManager.h"
#include "cru/ui/render/BorderRenderObject.h"
-#include "cru/ui/render/CanvasRenderObject.h"
#include "cru/ui/render/ScrollRenderObject.h"
-#include "cru/ui/render/StackLayoutRenderObject.h"
#include "cru/ui/render/TextRenderObject.h"
namespace cru::ui::controls {
@@ -13,7 +11,8 @@ using render::ScrollRenderObject;
using render::TextRenderObject;
TextBox::TextBox()
- : border_render_object_(new BorderRenderObject()),
+ : Control(kControlName),
+ border_render_object_(new BorderRenderObject()),
scroll_render_object_(new ScrollRenderObject()) {
auto theme_manager = ThemeManager::GetInstance();
@@ -43,13 +42,11 @@ TextBox::TextBox()
theme_manager->GetResourceStyleRuleSet("textbox.style"));
}
-TextBox::~TextBox() {}
-
-render::RenderObject* TextBox::GetRenderObject() const {
+render::RenderObject* TextBox::GetRenderObject() {
return border_render_object_.get();
}
-bool TextBox::GetMultiLine() const { return service_->IsMultiLine(); }
+bool TextBox::GetMultiLine() { return service_->IsMultiLine(); }
void TextBox::SetMultiLine(bool value) { service_->SetMultiLine(value); }
diff --git a/src/ui/controls/TreeView.cpp b/src/ui/controls/TreeView.cpp
index 89613763..c2dbcae7 100644
--- a/src/ui/controls/TreeView.cpp
+++ b/src/ui/controls/TreeView.cpp
@@ -65,9 +65,8 @@ void TreeViewItem::TraverseDescendants(
}
TreeView::TreeView()
- : root_item_(this, nullptr, render_object_.GetRootItem()) {}
-
-TreeView::~TreeView() {}
+ : Control(kControlType),
+ root_item_(this, nullptr, render_object_.GetRootItem()) {}
void TreeView::OnChildRemoved(Control* control, Index index) {
root_item_.TraverseDescendants([control](TreeViewItem* item) {
diff --git a/src/ui/controls/Window.cpp b/src/ui/controls/Window.cpp
index a5fbf05f..9722a3c6 100644
--- a/src/ui/controls/Window.cpp
+++ b/src/ui/controls/Window.cpp
@@ -8,7 +8,9 @@
namespace cru::ui::controls {
Window::Window()
- : control_host_(new ControlHost(this)), attached_control_(nullptr) {
+ : LayoutControl<render::StackLayoutRenderObject>(kControlName),
+ control_host_(new ControlHost(this)),
+ attached_control_(nullptr) {
GetContainerRenderObject()->SetDefaultHorizontalAlignment(Alignment::Stretch);
GetContainerRenderObject()->SetDefaultVertialAlignment(Alignment::Stretch);
}
@@ -21,8 +23,6 @@ Window* Window::CreatePopup() {
return window;
}
-std::string Window::GetControlType() const { return std::string(kControlType); }
-
void Window::SetAttachedControl(Control* control) {
attached_control_ = control;
}