aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/border.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-09-27 22:53:54 +0800
committercrupest <crupest@outlook.com>2018-09-27 22:53:54 +0800
commiteab8d69ccac6f7b306561a49e9c1f8fda21376d2 (patch)
tree914b66de1428ddfa55a190495e7e24cbb5f8b8c2 /src/ui/controls/border.h
parent692af0a1b202f128b6871ba790c0610f036e2944 (diff)
downloadcru-eab8d69ccac6f7b306561a49e9c1f8fda21376d2.tar.gz
cru-eab8d69ccac6f7b306561a49e9c1f8fda21376d2.tar.bz2
cru-eab8d69ccac6f7b306561a49e9c1f8fda21376d2.zip
Create Border. Make text control relayout when text changed.
Diffstat (limited to 'src/ui/controls/border.h')
-rw-r--r--src/ui/controls/border.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/ui/controls/border.h b/src/ui/controls/border.h
new file mode 100644
index 00000000..74e12c92
--- /dev/null
+++ b/src/ui/controls/border.h
@@ -0,0 +1,85 @@
+#pragma once
+
+#include <initializer_list>
+
+#include "ui/control.h"
+
+namespace cru::ui::controls
+{
+ class Border : public Control
+ {
+ public:
+ static Border* Create(const std::initializer_list<Control*>& children = std::initializer_list<Control*>())
+ {
+ const auto border = new Border();
+ for (const auto control : children)
+ border->AddChild(control);
+ return border;
+ }
+
+ protected:
+ Border();
+
+ public:
+ Border(const Border& other) = delete;
+ Border(Border&& other) = delete;
+ Border& operator=(const Border& other) = delete;
+ Border& operator=(Border&& other) = delete;
+ ~Border() override = default;
+
+ bool IsDrawBorder() const
+ {
+ return draw_border_;
+ }
+
+ void SetDrawBorder(bool draw_border);
+
+ Microsoft::WRL::ComPtr<ID2D1Brush> GetBorderBrush() const
+ {
+ return border_brush_;
+ }
+
+ void SetBorderBrush(Microsoft::WRL::ComPtr<ID2D1Brush> border_brush);
+
+ float GetBorderWidth() const
+ {
+ return border_width_;
+ }
+
+ void SetBorderWidth(float border_width);
+
+ Microsoft::WRL::ComPtr<ID2D1StrokeStyle> GetBorderStrokeStyle() const
+ {
+ return border_stroke_style_;
+ }
+
+ void SetBorderStrokeStyle(Microsoft::WRL::ComPtr<ID2D1StrokeStyle> stroke_style);
+
+ float GetBorderRadiusX() const
+ {
+ return border_radius_x_;
+ }
+
+ void SetBorderRadiusX(float border_radius_x);
+
+ float GetBorderRadiusY() const
+ {
+ return border_radius_y_;
+ }
+
+ void SetBorderRadiusY(float border_radius_y);
+
+ protected:
+ void OnDraw(ID2D1DeviceContext* device_context) override;
+
+ private:
+ bool draw_border_ = true;
+
+ Microsoft::WRL::ComPtr<ID2D1Brush> border_brush_;
+ float border_width_ = 1.0f;
+ Microsoft::WRL::ComPtr<ID2D1StrokeStyle> border_stroke_style_ = nullptr;
+
+ float border_radius_x_ = 0.0f;
+ float border_radius_y_ = 0.0f;
+ };
+}