-
Notifications
You must be signed in to change notification settings - Fork 0
/
Colorfield.hpp
115 lines (97 loc) · 3.85 KB
/
Colorfield.hpp
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// AmigaOS MUI C++ wrapper
//
// (c) 2022-2024 TDolphin
//
#pragma once
#include "Area.hpp"
#include "Core/RGBColor.hpp"
namespace MUI
{
class Colorfield : public Area
{
public:
explicit Colorfield(Object *pMuiObject)
: Area(pMuiObject)
{
}
// instanceOf
const static std::string className;
static inline bool instanceOf(Object *pMuiObject)
{
return MUI::instanceOf(pMuiObject, className.c_str());
}
// is/get/set (attributes), all setters return object reference
/// @brief [ @b MUIA_Colorfield_Blue ]
unsigned char getBlue() const;
/// @brief [ @b MUIA_Colorfield_Green ]
unsigned char getGreen() const;
/// @brief [ @b MUIA_Colorfield_Pen ]
unsigned long getPen() const;
/// @brief [ @b MUIA_Colorfield_Red ]
unsigned char getRed() const;
/// @brief [ @b MUIA_Colorfield_RGB ]
RGBColor getRGB() const;
/// @brief [ @b MUIA_Colorfield_Blue ]
Colorfield &setBlue(const unsigned char blue);
/// @brief [ @b MUIA_Colorfield_Green ]
Colorfield &setGreen(const unsigned char green);
/// @brief [ @b MUIA_Colorfield_Red ]
Colorfield &setRed(const unsigned char red);
/// @brief [ @b MUIA_Colorfield_RGB ]
Colorfield &setRGB(const unsigned char red, const unsigned char green, const unsigned char blue);
/// @brief [ @b MUIA_Colorfield_RGB ]
Colorfield &setRGB(const RGBColor &rgbColor);
};
template <typename T, typename U> class ColorfieldBuilderTemplate : public AreaBuilderTemplate<T, U>
{
public:
ColorfieldBuilderTemplate(const std::string &uniqueId = MUI::EmptyUniqueId, const std::string &muiClassName = MUIC_Colorfield)
: AreaBuilderTemplate<T, U>(uniqueId, muiClassName)
{
}
/// @brief [ @b MUIA_Colorfield_Blue ]
T &tagBlue(const unsigned char blue);
/// @brief [ @b MUIA_Colorfield_Green ]
T &tagGreen(const unsigned char green);
/// @brief [ @b MUIA_Colorfield_Red ]
T &tagRed(const unsigned char red);
/// @brief [ @b MUIA_Colorfield_RGB ]
T &tagRGB(const unsigned char red, const unsigned char green, const unsigned char blue);
/// @brief [ @b MUIA_Colorfield_RGB ]
T &tagRGB(const RGBColor &rgbColor);
};
class ColorfieldBuilder : public ColorfieldBuilderTemplate<ColorfieldBuilder, Colorfield>
{
public:
ColorfieldBuilder();
};
template <typename T, typename U> inline T &ColorfieldBuilderTemplate<T, U>::tagBlue(const unsigned char blue)
{
this->PushTag(MUIA_Colorfield_Blue, RGBColor::to32Bit(blue));
return (T &)*this;
}
template <typename T, typename U> inline T &ColorfieldBuilderTemplate<T, U>::tagGreen(const unsigned char green)
{
this->PushTag(MUIA_Colorfield_Green, RGBColor::to32Bit(green));
return (T &)*this;
}
template <typename T, typename U> inline T &ColorfieldBuilderTemplate<T, U>::tagRed(const unsigned char red)
{
this->PushTag(MUIA_Colorfield_Red, RGBColor::to32Bit(red));
return (T &)*this;
}
template <typename T, typename U>
inline T &ColorfieldBuilderTemplate<T, U>::tagRGB(const unsigned char red, const unsigned char green, const unsigned char blue)
{
unsigned long rgb[3] = { RGBColor::to32Bit(red), RGBColor::to32Bit(green), RGBColor::to32Bit(blue) };
this->PushTag(MUIA_Colorfield_RGB, rgb);
return (T &)*this;
}
template <typename T, typename U> inline T &ColorfieldBuilderTemplate<T, U>::tagRGB(const RGBColor &rgbColor)
{
unsigned long rgb[3] = { rgbColor.red32bit(), rgbColor.green32bit(), rgbColor.blue32bit() };
this->PushTag(MUIA_Colorfield_RGB, rgb);
return (T &)*this;
}
}