diff options
Diffstat (limited to 'src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp')
-rw-r--r-- | src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp b/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp new file mode 100644 index 00000000..fc86b0ed --- /dev/null +++ b/src/ThemeBuilder/components/properties/CornerRadiusPropertyEditor.cpp @@ -0,0 +1,42 @@ +#include "CornerRadiusPropertyEditor.h" +#include "cru/ui/Base.h" +#include "cru/ui/controls/FlexLayout.h" + +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"⌟"); + + 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()); + + ConnectChangeEvent(left_top_editor_); + ConnectChangeEvent(right_top_editor_); + ConnectChangeEvent(left_bottom_editor_); + ConnectChangeEvent(right_bottom_editor_); +} + +CornerRadiusPropertyEditor::~CornerRadiusPropertyEditor() {} + +ui::CornerRadius CornerRadiusPropertyEditor::GetValue() const { + return ui::CornerRadius( + left_top_editor_.GetValue(), right_top_editor_.GetValue(), + left_bottom_editor_.GetValue(), right_bottom_editor_.GetValue()); +} + +void CornerRadiusPropertyEditor::SetValue(const ui::CornerRadius& corner_radius, + bool trigger_change) { + left_top_editor_.SetValue(corner_radius.left_top, false); + right_top_editor_.SetValue(corner_radius.right_top, false); + left_bottom_editor_.SetValue(corner_radius.left_bottom, false); + right_bottom_editor_.SetValue(corner_radius.right_bottom, false); + if (trigger_change) RaiseChangeEvent(); +} +} // namespace cru::theme_builder::components::properties |