aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/border.cpp
blob: 1caed91dae66ca4d8dc838008c7e77514d56bb23 (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
#include "border.h"

#include "graph/graph.h"

namespace cru::ui::controls
{
    using graph::CreateSolidBrush;

    Border::Border() : Control(true), border_delegate_(this)
    {

    }

    void Border::SetDrawBorder(const bool draw_border)
    {
        draw_border_ = draw_border;
        Repaint();
    }

    void Border::OnDraw(ID2D1DeviceContext* device_context)
    {
        if (draw_border_)
        {
            border_delegate_.Draw(device_context, GetSize());
        }
    }

    Size Border::OnMeasure(const Size& available_size)
    {
        return Control::DefaultMeasureWithPadding(available_size, border_delegate_.GetBorderThickness());
    }

    void Border::OnLayout(const Rect& rect)
    {
        Control::DefaultLayoutWithPadding(rect, border_delegate_.GetBorderThickness());
    }
}