aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-12 21:38:34 +0800
committercrupest <crupest@outlook.com>2022-02-12 21:38:34 +0800
commit947664150cf0ae96cbffffe431107ec28d85d9cc (patch)
tree829662c5d18aa378d1b59be1381a63107008b890 /src
parentb7946e28a08c945e26d39f095d2e55c952a936c4 (diff)
downloadcru-947664150cf0ae96cbffffe431107ec28d85d9cc.tar.gz
cru-947664150cf0ae96cbffffe431107ec28d85d9cc.tar.bz2
cru-947664150cf0ae96cbffffe431107ec28d85d9cc.zip
...
Diffstat (limited to 'src')
-rw-r--r--src/theme_builder/components/properties/ColorPropertyEditor.cpp2
-rw-r--r--src/theme_builder/components/properties/CornerRadiusPropertyEditor.cpp52
-rw-r--r--src/theme_builder/components/properties/CornerRadiusPropertyEditor.h30
-rw-r--r--src/theme_builder/components/properties/PointPropertyEditor.cpp2
-rw-r--r--src/theme_builder/components/properties/PointPropertyEditor.h5
-rw-r--r--src/theme_builder/components/properties/TextPropertyEditor.cpp2
-rw-r--r--src/theme_builder/components/properties/ThicknessPropertyEditor.cpp4
7 files changed, 93 insertions, 4 deletions
diff --git a/src/theme_builder/components/properties/ColorPropertyEditor.cpp b/src/theme_builder/components/properties/ColorPropertyEditor.cpp
index cf9599b3..2f4e7762 100644
--- a/src/theme_builder/components/properties/ColorPropertyEditor.cpp
+++ b/src/theme_builder/components/properties/ColorPropertyEditor.cpp
@@ -29,7 +29,7 @@ ColorPropertyEditor::ColorPropertyEditor() {
});
}
-ColorPropertyEditor::~ColorPropertyEditor() {}
+ColorPropertyEditor::~ColorPropertyEditor() { container_.RemoveFromParent(); }
void ColorPropertyEditor::SetColor(const ui::Color &color) {
color_cube_brush_->SetColor(color);
diff --git a/src/theme_builder/components/properties/CornerRadiusPropertyEditor.cpp b/src/theme_builder/components/properties/CornerRadiusPropertyEditor.cpp
new file mode 100644
index 00000000..0da7e18c
--- /dev/null
+++ b/src/theme_builder/components/properties/CornerRadiusPropertyEditor.cpp
@@ -0,0 +1,52 @@
+#include "CornerRadiusPropertyEditor.h"
+
+namespace cru::theme_builder::components::properties {
+CornerRadiusPropertyEditor::CornerRadiusPropertyEditor() {
+ left_top_editor_.SetLabel(u"Left Top");
+ right_top_editor_.SetLabel(u"Right Top");
+ left_bottom_editor_.SetLabel(u"Left Bottom");
+ right_bottom_editor_.SetLabel(u"Right Bottom");
+
+ container_.SetFlexDirection(ui::controls::FlexDirection::Vertical);
+ container_.AddChild(left_top_editor_.GetRootControl());
+ container_.AddChild(right_top_editor_.GetRootControl());
+ container_.AddChild(left_bottom_editor_.GetRootControl());
+ container_.AddChild(right_bottom_editor_.GetRootControl());
+
+ left_top_editor_.PointChangeEvent()->AddHandler(
+ [this](const ui::Point& point) {
+ corner_radius_.left_top = point;
+ corner_radius_change_event_.Raise(corner_radius_);
+ });
+
+ right_top_editor_.PointChangeEvent()->AddHandler(
+ [this](const ui::Point& point) {
+ corner_radius_.right_top = point;
+ corner_radius_change_event_.Raise(corner_radius_);
+ });
+
+ left_bottom_editor_.PointChangeEvent()->AddHandler(
+ [this](const ui::Point& point) {
+ corner_radius_.left_bottom = point;
+ corner_radius_change_event_.Raise(corner_radius_);
+ });
+
+ right_bottom_editor_.PointChangeEvent()->AddHandler(
+ [this](const ui::Point& point) {
+ corner_radius_.right_bottom = point;
+ corner_radius_change_event_.Raise(corner_radius_);
+ });
+}
+
+CornerRadiusPropertyEditor::~CornerRadiusPropertyEditor() {
+ container_.RemoveFromParent();
+}
+
+void CornerRadiusPropertyEditor::SetCornerRadius(
+ const ui::CornerRadius& corner_radius) {
+ left_top_editor_.SetPoint(corner_radius_.left_top);
+ right_top_editor_.SetPoint(corner_radius_.right_top);
+ left_bottom_editor_.SetPoint(corner_radius_.left_bottom);
+ right_bottom_editor_.SetPoint(corner_radius_.right_bottom);
+}
+} // namespace cru::theme_builder::components::properties
diff --git a/src/theme_builder/components/properties/CornerRadiusPropertyEditor.h b/src/theme_builder/components/properties/CornerRadiusPropertyEditor.h
new file mode 100644
index 00000000..de55cdd4
--- /dev/null
+++ b/src/theme_builder/components/properties/CornerRadiusPropertyEditor.h
@@ -0,0 +1,30 @@
+#pragma once
+#include "PointPropertyEditor.h"
+#include "cru/ui/components/Component.h"
+#include "cru/ui/controls/FlexLayout.h"
+
+namespace cru::theme_builder::components::properties {
+class CornerRadiusPropertyEditor : public ui::components::Component {
+ public:
+ CornerRadiusPropertyEditor();
+ ~CornerRadiusPropertyEditor() override;
+
+ ui::CornerRadius GetCornerRadius() const { return corner_radius_; }
+ void SetCornerRadius(const ui::CornerRadius& corner_radius);
+
+ IEvent<ui::CornerRadius>* CornerRadiusChangeEvent() {
+ return &corner_radius_change_event_;
+ }
+
+ private:
+ ui::CornerRadius corner_radius_;
+
+ ui::controls::FlexLayout container_;
+ PointPropertyEditor left_top_editor_;
+ PointPropertyEditor right_top_editor_;
+ PointPropertyEditor left_bottom_editor_;
+ PointPropertyEditor right_bottom_editor_;
+
+ Event<ui::CornerRadius> corner_radius_change_event_;
+};
+} // namespace cru::theme_builder::components::properties
diff --git a/src/theme_builder/components/properties/PointPropertyEditor.cpp b/src/theme_builder/components/properties/PointPropertyEditor.cpp
index a8549c8d..dde97b79 100644
--- a/src/theme_builder/components/properties/PointPropertyEditor.cpp
+++ b/src/theme_builder/components/properties/PointPropertyEditor.cpp
@@ -24,7 +24,7 @@ PointPropertyEditor::PointPropertyEditor() {
});
}
-PointPropertyEditor::~PointPropertyEditor() {}
+PointPropertyEditor::~PointPropertyEditor() { container_.RemoveFromParent(); }
void PointPropertyEditor::SetPoint(const ui::Point& point) {
point_ = point;
diff --git a/src/theme_builder/components/properties/PointPropertyEditor.h b/src/theme_builder/components/properties/PointPropertyEditor.h
index 8588d77c..d1c84c33 100644
--- a/src/theme_builder/components/properties/PointPropertyEditor.h
+++ b/src/theme_builder/components/properties/PointPropertyEditor.h
@@ -11,6 +11,11 @@ class PointPropertyEditor : public ui::components::Component {
~PointPropertyEditor() override;
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 GetPoint() const { return point_; }
void SetPoint(const ui::Point& point);
diff --git a/src/theme_builder/components/properties/TextPropertyEditor.cpp b/src/theme_builder/components/properties/TextPropertyEditor.cpp
index 9854019c..916e907b 100644
--- a/src/theme_builder/components/properties/TextPropertyEditor.cpp
+++ b/src/theme_builder/components/properties/TextPropertyEditor.cpp
@@ -12,7 +12,7 @@ TextPropertyEditor::TextPropertyEditor() {
});
}
-TextPropertyEditor::~TextPropertyEditor() {}
+TextPropertyEditor::~TextPropertyEditor() { container_.RemoveFromParent(); }
bool TextPropertyEditor::Validate(StringView text, String* error_message) {
return true;
diff --git a/src/theme_builder/components/properties/ThicknessPropertyEditor.cpp b/src/theme_builder/components/properties/ThicknessPropertyEditor.cpp
index 3121d288..56374e86 100644
--- a/src/theme_builder/components/properties/ThicknessPropertyEditor.cpp
+++ b/src/theme_builder/components/properties/ThicknessPropertyEditor.cpp
@@ -23,7 +23,9 @@ ThicknessPropertyEditor::ThicknessPropertyEditor() {
});
}
-ThicknessPropertyEditor::~ThicknessPropertyEditor() {}
+ThicknessPropertyEditor::~ThicknessPropertyEditor() {
+ container_.RemoveFromParent();
+}
void ThicknessPropertyEditor::SetThickness(const ui::Thickness &thickness) {
thickness_ = thickness;