From 1dab244aaad8694ba37ef43caedd8c8ba0310c00 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 5 Nov 2018 20:54:48 +0800 Subject: ... --- src/ui/border_property.h | 61 ++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 25 deletions(-) (limited to 'src/ui/border_property.h') diff --git a/src/ui/border_property.h b/src/ui/border_property.h index 71ec0e7d..ce16dea7 100644 --- a/src/ui/border_property.h +++ b/src/ui/border_property.h @@ -7,28 +7,16 @@ namespace cru::ui { - class BorderProperty final : public PropertyChangedNotifyObject + class BorderProperty final { public: - constexpr static auto brush_property_name = L"Brush"; - constexpr static auto width_property_name = L"StrokeWidth"; - constexpr static auto stroke_style_property_name = L"StrokeStyle"; - constexpr static auto radius_x_property_name = L"RadiusX"; - constexpr static auto radius_y_property_name = L"RadiusY"; - - using Ptr = std::shared_ptr; - - static Ptr Create() - { - return std::make_shared(); - } - BorderProperty(); - BorderProperty(const BorderProperty& other) = delete; - BorderProperty(BorderProperty&& other) = delete; - BorderProperty& operator=(const BorderProperty& other) = delete; - BorderProperty& operator=(BorderProperty&& other) = delete; - ~BorderProperty() override = default; + explicit BorderProperty(Microsoft::WRL::ComPtr brush); + BorderProperty(const BorderProperty& other) = default; + BorderProperty(BorderProperty&& other) = default; + BorderProperty& operator=(const BorderProperty& other) = default; + BorderProperty& operator=(BorderProperty&& other) = default; + ~BorderProperty() = default; Microsoft::WRL::ComPtr GetBrush() const @@ -56,14 +44,37 @@ namespace cru::ui return radius_y_; } - void SetBrush(Microsoft::WRL::ComPtr brush); - void SetWidth(float width); - void SetStrokeStyle(Microsoft::WRL::ComPtr stroke_style); - void SetRadiusX(float radius_x); - void SetRadiusY(float radius_y); + void SetBrush(Microsoft::WRL::ComPtr brush) + { + Require(brush == nullptr, "Brush of BorderProperty mustn't be null."); + brush_ = std::move(brush); + } + + void SetStrokeWidth(const float stroke_width) + { + Require(stroke_width >= 0.0f, "Stroke width must be no less than 0."); + stroke_width_ = stroke_width; + } + + void SetStrokeStyle(Microsoft::WRL::ComPtr stroke_style) + { + stroke_style_ = std::move(stroke_style); + } + + void SetRadiusX(const float radius_x) + { + Require(radius_x >= 0.0f, "Radius-x must be no less than 0."); + radius_x_ = radius_x; + } + + void SetRadiusY(const float radius_y) + { + Require(radius_y >= 0.0f, "Radius-y must be no less than 0."); + radius_y_ = radius_y; + } private: - Microsoft::WRL::ComPtr brush_ = nullptr; + Microsoft::WRL::ComPtr brush_; float stroke_width_ = 1.0f; Microsoft::WRL::ComPtr stroke_style_ = nullptr; float radius_x_ = 0.0f; -- cgit v1.2.3