aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/border_delegate.h
diff options
context:
space:
mode:
authorYuqian Yang <crupest@outlook.com>2018-10-04 16:52:11 +0000
committerYuqian Yang <crupest@outlook.com>2018-10-04 16:52:11 +0000
commit7e870dd16e2f5b41fa6c6f687723aaa50c16274d (patch)
treebe2b26a42dc9fde97379f98f035113e08e0bc331 /src/ui/controls/border_delegate.h
parent30ecda8bb354d5982978af97aa90b5f49d9ea195 (diff)
parentc5384d496e9ed429ca2baa3ca5e586ff255235eb (diff)
downloadcru-7e870dd16e2f5b41fa6c6f687723aaa50c16274d.tar.gz
cru-7e870dd16e2f5b41fa6c6f687723aaa50c16274d.tar.bz2
cru-7e870dd16e2f5b41fa6c6f687723aaa50c16274d.zip
Merge branch '12-layout' into 'master'
Resolve "Add padding, margin, border to Control." Closes #12 See merge request crupest/CruUI!12
Diffstat (limited to 'src/ui/controls/border_delegate.h')
-rw-r--r--src/ui/controls/border_delegate.h101
1 files changed, 0 insertions, 101 deletions
diff --git a/src/ui/controls/border_delegate.h b/src/ui/controls/border_delegate.h
deleted file mode 100644
index 6d8663e9..00000000
--- a/src/ui/controls/border_delegate.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#pragma once
-
-#include "ui/control.h"
-
-namespace cru::ui::controls
-{
- class BorderProperty : public PropertyChangedNotifyObject
- {
- public:
- using Ptr = std::shared_ptr<BorderProperty>;
- static Ptr Create();
-
- constexpr static auto brush_property_name = L"Brush";
- constexpr static auto width_property_name = L"Width";
- 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";
-
- BorderProperty() = default;
- explicit BorderProperty(Microsoft::WRL::ComPtr<ID2D1Brush> brush);
- BorderProperty(const BorderProperty& other) = delete;
- BorderProperty(BorderProperty&& other) = delete;
- BorderProperty& operator=(const BorderProperty& other) = delete;
- BorderProperty& operator=(BorderProperty&& other) = delete;
- ~BorderProperty() override = default;
-
-
- Microsoft::WRL::ComPtr<ID2D1Brush> GetBrush() const
- {
- return brush_;
- }
-
- float GetWidth() const
- {
- return width_;
- }
-
- Microsoft::WRL::ComPtr<ID2D1StrokeStyle> GetStrokeStyle() const
- {
- return stroke_style_;
- }
-
- float GetRadiusX() const
- {
- return radius_x_;
- }
-
- float GetRadiusY() const
- {
- return radius_y_;
- }
-
- void SetBrush(Microsoft::WRL::ComPtr<ID2D1Brush> brush);
- void SetWidth(float width);
- void SetStrokeStyle(Microsoft::WRL::ComPtr<ID2D1StrokeStyle> stroke_style);
- void SetRadiusX(float radius_x);
- void SetRadiusY(float radius_y);
-
- private:
- Microsoft::WRL::ComPtr<ID2D1Brush> brush_ = nullptr;
- float width_ = 1.0f;
- Microsoft::WRL::ComPtr<ID2D1StrokeStyle> stroke_style_ = nullptr;
- float radius_x_ = 0.0f;
- float radius_y_ = 0.0f;
- };
-
-
- // BorderDelegate is a delegate for border painting and layout.
- // It must bind a control and not change the binding.
- // But multiple BorderDelegate may share a common BorderProperty.
- class BorderDelegate : public Object
- {
- public:
- explicit BorderDelegate(Control* control);
- BorderDelegate(Control* control, std::shared_ptr<BorderProperty> border_property);
- BorderDelegate(const BorderDelegate& other) = delete;
- BorderDelegate(BorderDelegate&& other) = delete;
- BorderDelegate& operator=(const BorderDelegate& other) = delete;
- BorderDelegate& operator=(BorderDelegate&& other) = delete;
- ~BorderDelegate() override;
-
- std::shared_ptr<BorderProperty> GetBorderProperty() const
- {
- return border_property_;
- }
-
- void SetBorderProperty(std::shared_ptr<BorderProperty> border_property);
-
- void Draw(ID2D1DeviceContext* device_context, const Size& size) const;
-
- Thickness GetBorderThickness() const
- {
- return Thickness(border_property_->GetWidth());
- }
-
- private:
- Control* control_;
- std::shared_ptr<BorderProperty> border_property_;
- FunctionPtr<void(String)> border_property_changed_listener_;
- };
-}