Skip to content

Commit 7eae161

Browse files
committed
Make color constants make use of the Color struct
1 parent 7ebc36d commit 7eae161

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

include/tesla.hpp

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,38 @@ namespace tsl {
9494

9595
}
9696

97+
/**
98+
* @brief RGBA4444 Color structure
99+
*/
100+
struct Color {
101+
102+
union {
103+
struct {
104+
u16 r: 4, g: 4, b: 4, a: 4;
105+
} PACKED;
106+
u16 rgba;
107+
};
108+
109+
constexpr inline Color(u16 raw): rgba(raw) {}
110+
constexpr inline Color(u8 r, u8 g, u8 b, u8 a): r(r), g(g), b(b), a(a) {}
111+
};
112+
97113
namespace style {
98-
constexpr u32 ListItemDefaultHeight = 70; ///< Standard list item height
99-
constexpr u32 TrackBarDefaultHeight = 90; ///< Standard track bar height
100-
constexpr u8 ListItemHighlightSaturation = 0x6; ///< Maximum saturation of Listitem highlights
101-
constexpr u8 ListItemHighlightLength = 22; ///< Maximum length of Listitem highlights
114+
constexpr u32 ListItemDefaultHeight = 70; ///< Standard list item height
115+
constexpr u32 TrackBarDefaultHeight = 90; ///< Standard track bar height
116+
constexpr u8 ListItemHighlightSaturation = 6; ///< Maximum saturation of Listitem highlights
117+
constexpr u8 ListItemHighlightLength = 22; ///< Maximum length of Listitem highlights
102118

103119
namespace color {
104-
constexpr u16 ColorFrameBackground = 0xD000; ///< Overlay frame background color
105-
constexpr u16 ColorTransparent = 0x0000; ///< Transparent color
106-
constexpr u16 ColorHighlight = 0xFDF0; ///< Greenish highlight color
107-
constexpr u16 ColorFrame = 0xF777; ///< Outer boarder color
108-
constexpr u16 ColorHandle = 0xF555; ///< Track bar handle color
109-
constexpr u16 ColorText = 0xFFFF; ///< Standard text color
110-
constexpr u16 ColorDescription = 0xFAAA; ///< Description text color
111-
constexpr u16 ColorHeaderBar = 0xFCCC; ///< Category header rectangle color
112-
constexpr u16 ColorClickAnimation = 0xF220;
120+
constexpr Color ColorFrameBackground = { 0x0, 0x0, 0x0, 0xD }; ///< Overlay frame background color
121+
constexpr Color ColorTransparent = { 0x0, 0x0, 0x0, 0x0 }; ///< Transparent color
122+
constexpr Color ColorHighlight = { 0x0, 0xF, 0xD, 0xF }; ///< Greenish highlight color
123+
constexpr Color ColorFrame = { 0x7, 0x7, 0x7, 0xF }; ///< Outer boarder color
124+
constexpr Color ColorHandle = { 0x5, 0x5, 0x5, 0xF }; ///< Track bar handle color
125+
constexpr Color ColorText = { 0xF, 0xF, 0xF, 0xF }; ///< Standard text color
126+
constexpr Color ColorDescription = { 0xA, 0xA, 0xA, 0xF }; ///< Description text color
127+
constexpr Color ColorHeaderBar = { 0xC, 0xC, 0xC, 0xF }; ///< Category header rectangle color
128+
constexpr Color ColorClickAnimation = { 0x0, 0x2, 0x2, 0xF }; ///< Element click animation color
113129
}
114130
}
115131

@@ -528,22 +544,6 @@ namespace tsl {
528544

529545
extern "C" u64 __nx_vi_layer_id;
530546

531-
/**
532-
* @brief RGBA4444 Color structure
533-
*/
534-
struct Color {
535-
536-
union {
537-
struct {
538-
u16 r: 4, g: 4, b: 4, a: 4;
539-
} PACKED;
540-
u16 rgba;
541-
};
542-
543-
inline Color(u16 raw): rgba(raw) {}
544-
inline Color(u8 r, u8 g, u8 b, u8 a): r(r), g(g), b(b), a(a) {}
545-
};
546-
547547
struct ScissoringConfig {
548548
s32 x, y, w, h;
549549
};
@@ -1317,7 +1317,7 @@ namespace tsl {
13171317
* @param renderer Renderer
13181318
*/
13191319
virtual void drawClickAnimation(gfx::Renderer *renderer) {
1320-
gfx::Color animColor = tsl::style::color::ColorClickAnimation;
1320+
Color animColor = tsl::style::color::ColorClickAnimation;
13211321
u8 saturation = tsl::style::ListItemHighlightSaturation * (float(this->m_clickAnimationProgress) / float(tsl::style::ListItemHighlightLength));
13221322

13231323
animColor.g = saturation;
@@ -1350,7 +1350,7 @@ namespace tsl {
13501350
virtual void drawHighlight(gfx::Renderer *renderer) {
13511351
static float counter = 0;
13521352
const float progress = (std::sin(counter) + 1) / 2;
1353-
gfx::Color highlightColor = { static_cast<u8>((0x2 - 0x8) * progress + 0x8),
1353+
Color highlightColor = { static_cast<u8>((0x2 - 0x8) * progress + 0x8),
13541354
static_cast<u8>((0x8 - 0xF) * progress + 0xF),
13551355
static_cast<u8>((0xC - 0xF) * progress + 0xF),
13561356
0xF };
@@ -1768,7 +1768,7 @@ namespace tsl {
17681768
*
17691769
* @param color Color of the rectangle
17701770
*/
1771-
DebugRectangle(gfx::Color color) : Element(), m_color(color) {}
1771+
DebugRectangle(Color color) : Element(), m_color(color) {}
17721772
virtual ~DebugRectangle() {}
17731773

17741774
virtual void draw(gfx::Renderer *renderer) override {
@@ -1778,7 +1778,7 @@ namespace tsl {
17781778
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {}
17791779

17801780
private:
1781-
gfx::Color m_color;
1781+
Color m_color;
17821782
};
17831783

17841784

@@ -2492,7 +2492,7 @@ namespace tsl {
24922492
virtual void drawHighlight(gfx::Renderer *renderer) override {
24932493
static float counter = 0;
24942494
const float progress = (std::sin(counter) + 1) / 2;
2495-
gfx::Color highlightColor = { static_cast<u8>((0x2 - 0x8) * progress + 0x8),
2495+
Color highlightColor = { static_cast<u8>((0x2 - 0x8) * progress + 0x8),
24962496
static_cast<u8>((0x8 - 0xF) * progress + 0xF),
24972497
static_cast<u8>((0xC - 0xF) * progress + 0xF),
24982498
static_cast<u8>((0x6 - 0xD) * progress + 0xD) };

0 commit comments

Comments
 (0)