blob: f79d610faa10acd2683e82f1007850215f291367 (
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
|
#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());
}
}
}
|