aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/border.h
blob: 7880e6902434f88cdfe2029ee7878e7f4f408433 (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
#pragma once

#include <initializer_list>

#include "ui/control.h"
#include "border_delegate.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);

        BorderProperty::Ptr GetBorderProperty() const
        {
            return border_delegate_.GetBorderProperty();
        }

    protected:
        void OnDraw(ID2D1DeviceContext* device_context) override;

        Size OnMeasure(const Size& available_size) override;
        void OnLayout(const Rect& rect) override;

    private:
        bool draw_border_ = true;

        BorderDelegate border_delegate_;
    };
}