aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/border.cpp
diff options
context:
space:
mode:
authorYuqian Yang <crupest@outlook.com>2018-09-27 15:01:15 +0000
committerYuqian Yang <crupest@outlook.com>2018-09-27 15:01:15 +0000
commitb0b5a481c9b0460f275887b15e8edecc34e99186 (patch)
tree914b66de1428ddfa55a190495e7e24cbb5f8b8c2 /src/ui/controls/border.cpp
parent1fdc86fe5f8d18fdc8927f663aaeaa0b6b8f1e9b (diff)
parenteab8d69ccac6f7b306561a49e9c1f8fda21376d2 (diff)
downloadcru-b0b5a481c9b0460f275887b15e8edecc34e99186.tar.gz
cru-b0b5a481c9b0460f275887b15e8edecc34e99186.tar.bz2
cru-b0b5a481c9b0460f275887b15e8edecc34e99186.zip
Merge branch '5-border' into 'master'
Resolve "Develop border." Closes #5 See merge request crupest/CruUI!7
Diffstat (limited to 'src/ui/controls/border.cpp')
-rw-r--r--src/ui/controls/border.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/ui/controls/border.cpp b/src/ui/controls/border.cpp
new file mode 100644
index 00000000..f79d610f
--- /dev/null
+++ b/src/ui/controls/border.cpp
@@ -0,0 +1,58 @@
+#include "border.h"
+
+#include "graph/graph.h"
+
+namespace cru::ui::controls
+{
+ using graph::CreateSolidBrush;
+
+ Border::Border() : Control(true)
+ {
+ border_brush_ = CreateSolidBrush(D2D1::ColorF(D2D1::ColorF::Black));
+ }
+
+ void Border::SetDrawBorder(bool draw_border)
+ {
+ draw_border_ = draw_border;
+ Repaint();
+ }
+
+ void Border::SetBorderBrush(Microsoft::WRL::ComPtr<ID2D1Brush> border_brush)
+ {
+ border_brush_ = std::move(border_brush);
+ Repaint();
+ }
+
+ void Border::SetBorderWidth(const float border_width)
+ {
+ border_width_ = border_width;
+ Repaint();
+ }
+
+ void Border::SetBorderStrokeStyle(Microsoft::WRL::ComPtr<ID2D1StrokeStyle> stroke_style)
+ {
+ border_stroke_style_ = std::move(stroke_style);
+ Repaint();
+ }
+
+ void Border::SetBorderRadiusX(const float border_radius_x)
+ {
+ border_radius_x_ = border_radius_x;
+ Repaint();
+ }
+
+ void Border::SetBorderRadiusY(const float border_radius_y)
+ {
+ border_radius_y_ = border_radius_y;
+ Repaint();
+ }
+
+ void Border::OnDraw(ID2D1DeviceContext* device_context)
+ {
+ if (draw_border_)
+ {
+ const auto size = GetSize();
+ device_context->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(0.0f, 0.0f, size.width, size.height), border_radius_x_, border_radius_y_), border_brush_.Get(), border_width_, border_stroke_style_.Get());
+ }
+ }
+}