libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiTheme.cpp
1/****************************************************************************
2 * libgui
3 * Daryl Borth 2026
4 * GuiTheme.cpp
5 ***************************************************************************/
6
7#include "GuiTheme.h"
8
9static PixelColor rgb(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
10{
11 PixelColor c = { r, g, b, a };
12 return c;
13}
14
16 background(rgb(18, 22, 29)),
17 surface(rgb(28, 35, 48)),
18 surfaceRaised(rgb(36, 46, 64)),
19 outline(rgb(43, 54, 71)),
20 outlineStrong(rgb(74, 90, 115)),
21 accent(rgb(255, 150, 40)),
22 accentLight(rgb(255, 200, 110)),
23 accentDark(rgb(200, 110, 20)),
24 text(rgb(232, 237, 244)),
25 textMuted(rgb(152, 164, 181)),
26 textOnAccent(rgb(30, 20, 5)),
27 good(rgb(63, 208, 176)),
28 radius(12.0f),
29 strokeWidth(2.0f),
30 padding(12.0f),
31 spacing(8.0f),
32 shadowBlur(14.0f)
33{}
34
36{
37 static GuiTheme theme;
38 return theme;
39}
40
42{
43 return GuiShapeStyle(GuiPaint().color(surface).stroke(strokeWidth, outline));
44}
45
47{
48 GuiPaint rest = GuiPaint()
49 .gradient(surfaceRaised, surface)
50 .stroke(strokeWidth, outline)
51 .shadow(shadowBlur, rgb(0, 0, 0, 150), 0.0f, 4.0f);
52 GuiPaint lit = GuiPaint()
53 .gradient(surfaceRaised, surface)
54 .stroke(strokeWidth, accent)
55 .glow(shadowBlur + 2.0f, rgb(accent.r, accent.g, accent.b, 110), 2.0f);
56 GuiPaint pressed = GuiPaint()
57 .gradient(surface, surfaceRaised)
58 .stroke(strokeWidth, accent)
59 .glow(shadowBlur, rgb(accent.r, accent.g, accent.b, 70));
60 GuiPaint off = GuiPaint()
61 .color(rgb(surface.r, surface.g, surface.b, 140))
62 .stroke(strokeWidth, rgb(outline.r, outline.g, outline.b, 140));
63 return GuiShapeStyle(rest).onFocus(lit).onPress(pressed).onDisable(off);
64}
65
67{
68 GuiPaint rest = GuiPaint()
69 .gradient(outlineStrong, outline)
70 .stroke(strokeWidth, outlineStrong);
71 GuiPaint lit = GuiPaint()
72 .gradient(accentLight, accent)
73 .stroke(strokeWidth, GuiMixColor(accentLight, rgb(255, 255, 255), 0.35f))
74 .glow(10.0f, rgb(accent.r, accent.g, accent.b, 90));
75 GuiPaint pressed = GuiPaint()
76 .gradient(accent, accentDark)
77 .stroke(strokeWidth, GuiMixColor(accentLight, rgb(255, 255, 255), 0.35f));
78 GuiPaint off = GuiPaint()
79 .color(rgb(surface.r, surface.g, surface.b, 150))
80 .stroke(strokeWidth, rgb(outline.r, outline.g, outline.b, 150));
81 return GuiShapeStyle(rest).onFocus(lit).onPress(pressed).onDisable(off);
82}
83
85{
86 return GuiShapeStyle(GuiPaint().color(outline));
87}
88
90{
91 GuiPaint lit = GuiPaint().color(GuiMixColor(surfaceRaised, outlineStrong, 0.65f));
92 GuiPaint pressed = GuiPaint().color(rgb(accent.r, accent.g, accent.b, 110));
93 return GuiShapeStyle(GuiPaint()).onFocus(lit).onPress(pressed);
94}
95
97{
98 return GuiShapeStyle(GuiPaint().color(GuiMixColor(background, rgb(0, 0, 0), 0.55f)));
99}
PixelColor GuiMixColor(PixelColor a, PixelColor b, float t)
Blends two colors per channel (alpha included): t = 0 gives a, t = 1 gives b.
Definition GuiPaint.cpp:250
A set of paints, one per state. States left unset fall back to the normal paint. GuiShapeStyle(rest)....
Definition GuiPaint.h:80
GuiShapeStyle cardStyle() const
A raised card: gradient surface, outline, drop shadow; a glowing accent outline when focused.
Definition GuiTheme.cpp:46
float padding
Space inside a card.
Definition GuiTheme.h:34
PixelColor text
Primary text.
Definition GuiTheme.h:26
PixelColor surface
Panels and resting cards.
Definition GuiTheme.h:19
PixelColor good
Positive state (connected, charged).
Definition GuiTheme.h:29
GuiShapeStyle panelStyle() const
A quiet container: flat surface with a thin outline.
Definition GuiTheme.cpp:41
PixelColor outline
Quiet outlines.
Definition GuiTheme.h:21
GuiShapeStyle chipStyle() const
A small label background (a "chip")
Definition GuiTheme.cpp:84
static GuiTheme & current()
The theme the rest of the library reads. Starts as the default dark theme.
Definition GuiTheme.cpp:35
PixelColor accentLight
Light end of the focused-button gradient.
Definition GuiTheme.h:24
PixelColor accent
Highlight: focus outline, focused button.
Definition GuiTheme.h:23
float spacing
Gap between siblings.
Definition GuiTheme.h:35
float strokeWidth
Outline width.
Definition GuiTheme.h:33
PixelColor textMuted
Secondary text.
Definition GuiTheme.h:27
GuiShapeStyle buttonStyle() const
A capsule or rounded button: lights up in the accent color when focused, darkens when pressed.
Definition GuiTheme.cpp:66
PixelColor outlineStrong
Resting button outline and fill.
Definition GuiTheme.h:22
PixelColor surfaceRaised
Lighter end of a card's gradient, chips.
Definition GuiTheme.h:20
GuiShapeStyle barStyle() const
A dark strip for a hint or status bar.
Definition GuiTheme.cpp:96
GuiTheme()
The default dark theme.
Definition GuiTheme.cpp:15
float radius
Corner radius of cards and panels.
Definition GuiTheme.h:32
PixelColor accentDark
Pressed-button fill.
Definition GuiTheme.h:25
GuiShapeStyle rowStyle() const
A flat list row: invisible at rest, a gray bar when focused, tinted when pressed.
Definition GuiTheme.cpp:89
PixelColor background
Screen background.
Definition GuiTheme.h:18
float shadowBlur
Softness of a resting card's shadow.
Definition GuiTheme.h:36
PixelColor textOnAccent
Text drawn over the accent color.
Definition GuiTheme.h:28
8-bit-per-channel RGBA color used by the video interfaces.
Definition Mesh.h:16