dl
dl_ui_color.h
浏览该文件的文档.
1
12
13#include "base/dl_color.h"
14
15namespace dl::UI
16{
19{
20public:
22 {
23 _col[0] = ColorDef::RED;
24 _col[1] = ColorDef::RED;
25 _col[2] = ColorDef::WHITE;
26 _col[3] = ColorDef::GRAY;
27 _col[4] = ColorDef::GRAY;
28 }
29
30 Color operator[](size_t i)
31 {
32 if (i >= _col.size())
33 return ColorDef::WHITE;
34 return _col[i];
35 }
36
37 // 普通 经过 按下 禁用 禁用(按下)
38 void Set(const std::vector<Color>& mul_col)
39 {
40 if (mul_col.size() == 1)
41 {
42 _col[0] = mul_col[0];
43 _col[1] = mul_col[0];
44 _col[2] = mul_col[0];
45 }
46 else if (mul_col.size() == 2)
47 {
48 _col[0] = mul_col[0];
49 _col[1] = mul_col[1];
50 _col[2] = mul_col[0];
51 }
52 else if (mul_col.size() >= 3)
53 {
54 _col[0] = mul_col[0];
55 _col[1] = mul_col[1];
56 _col[2] = mul_col[2];
57 if (mul_col.size() == 4)
58 {
59 _col[3] = mul_col[3];
60 _col[4] = mul_col[3];
61 }
62 else if (mul_col.size() == 5)
63 {
64 _col[3] = mul_col[3];
65 _col[4] = mul_col[4];
66 }
67 else if (mul_col.size() != 3)
68 log_warn0("传入过多的颜色没有意义!");
69 }
70 }
71private:
72 std::array<Color, 5> _col;
73};
74}
Color operator[](size_t i)
void Set(const std::vector< Color > &mul_col)
constexpr Color RED
constexpr Color WHITE
constexpr Color GRAY
Array< float, 4 > Color
void log_warn0(std::string_view str, DL_SOURCE_LOCATION)