aboutsummaryrefslogtreecommitdiff
path: root/src/ui/border_property.hpp
blob: 4dee0e0fd5ef56707f9415e921d60c201d157088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once

// ReSharper disable once CppUnusedIncludeDirective
#include "pre.hpp"

#include "system_headers.hpp"

#include "base.hpp"


namespace cru::ui
{
    class BorderProperty final
    {
    public:
        BorderProperty();
        explicit BorderProperty(Microsoft::WRL::ComPtr<ID2D1Brush> brush);
        BorderProperty(Microsoft::WRL::ComPtr<ID2D1Brush> brush, float width, float radius_x, float radius_y, Microsoft::WRL::ComPtr<ID2D1StrokeStyle> stroke_style = nullptr);
        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<ID2D1Brush> GetBrush() const
        {
            return brush_;
        }

        float GetStrokeWidth() const
        {
            return stroke_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)
        {
            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<ID2D1StrokeStyle> 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<ID2D1Brush> brush_;
        float stroke_width_ = 1.0f;
        float radius_x_ = 0.0f;
        float radius_y_ = 0.0f;
        Microsoft::WRL::ComPtr<ID2D1StrokeStyle> stroke_style_ = nullptr;
    };
}