-
Notifications
You must be signed in to change notification settings - Fork 0
/
RectangleWidget.h
83 lines (63 loc) · 1.83 KB
/
RectangleWidget.h
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
#pragma once
#include "HUDWidget.h"
class RectangleWidget :public HUDWidget
{
public:
RectangleWidget()
{
}
~RectangleWidget()
{
}
virtual void Tick(float DeltaTime) override
{
HUDWidget::Tick(DeltaTime);
if (!m_visible)return;
auto& transform = m_EntityComponentSystemManager->GetComponent<TransformComponent2D>(m_ID);
// std::cout<<m_Brush->GetColor().a;
//std::cout << transform.scale.m_x;
HUD::GetHUDSystem()->DrawRectangle(transform.position, transform.scale, m_Brush,m_offset, m_rect_type, m_border_width, m_border_Brush);
//std::cout << "ok";
}
virtual void BeginPlay() override
{
HUDWidget::BeginPlay();
}
void CreateColor(Vector3D brush_color, Vector3D border_brush_color = Vector3D(0,0,0))
{
D2D1_COLOR_F color = D2D1::ColorF(brush_color.m_x, brush_color.m_y, brush_color.m_z, 1);
D2D1_COLOR_F border_color = D2D1::ColorF(border_brush_color.m_x, border_brush_color.m_y, border_brush_color.m_z, 1);
// HUD_Render_System->CreateBrush(m_Brush) ;
HUD::GetHUDSystem()->GetRenderTarget()->CreateSolidColorBrush(
color,
&m_Brush
);
HUD::GetHUDSystem()->GetRenderTarget()->CreateSolidColorBrush(
border_color,
&m_border_Brush
);
}
void SetBrushColor(Vector3D brush_color)
{
D2D1_COLOR_F color = D2D1::ColorF(brush_color.m_x, brush_color.m_y, brush_color.m_z, 1);
m_Brush->SetColor(color);
}
ID2D1SolidColorBrush* GetBrush()
{
return m_Brush;
}
void SetRectType(ShapeType rect_type)
{
m_rect_type = rect_type;
}
void SetBorderWidth(float width)
{
m_border_width = width;
}
private:
ID2D1SolidColorBrush* m_Brush= NULL ;
ID2D1SolidColorBrush* m_border_Brush = NULL;
float m_border_width = 0;
ShapeType m_rect_type = ShapeType::Filled;
//friend class WidgetManager;
};