libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiPaint.h
1/****************************************************************************
2 * libgui
3 * Daryl Borth 2026
4 * GuiPaint.h
5 *
6 * Platform-agnostic description of how a shape looks: fill, outline and
7 * shadow, plus the per-state sets a widget switches between (normal,
8 * focused, pressed, disabled). Paints are plain values that can be copied,
9 * compared and blended, which is what lets a highlight fade in instead of
10 * snapping.
11 ***************************************************************************/
12#pragma once
13#include "GuiGeometry.h"
14
17enum class SHAPE {
20};
21
26struct GuiPaint {
27 GuiFill fill;
28 bool hasFill;
29 GuiFill strokeFill;
30 float strokeWidth;
31 STROKE strokeAlign;
32 PixelColor shadowColor;
33 float shadowBlur;
34 float shadowSpread;
35 float shadowDx;
36 float shadowDy;
37
39 GuiPaint();
40
42 GuiPaint& color(PixelColor c);
44 GuiPaint& gradient(PixelColor from, PixelColor to, float angleDeg = 90.0f);
46 GuiPaint& stroke(float width, PixelColor c, STROKE align = STROKE::INSIDE);
48 GuiPaint& shadow(float blur, PixelColor c, float dx = 0.0f, float dy = 0.0f, float spread = 0.0f);
50 GuiPaint& glow(float blur, PixelColor c, float spread = 0.0f);
51
53 bool operator==(const GuiPaint& o) const;
54 bool operator!=(const GuiPaint& o) const { return !(*this == o); }
55
61 static GuiPaint mix(const GuiPaint& a, const GuiPaint& b, float t);
62};
63
67
70enum class SHAPE_STATE {
71 NORMAL,
73 PRESSED,
74 DISABLED
75};
76
80struct GuiShapeStyle {
81 GuiPaint normal;
82 GuiPaint focused;
83 GuiPaint pressed;
84 GuiPaint disabled;
85 bool hasFocused;
86 bool hasPressed;
87 bool hasDisabled;
88
89 GuiShapeStyle(const GuiPaint& normalPaint = GuiPaint());
90 GuiShapeStyle& onFocus(const GuiPaint& p);
91 GuiShapeStyle& onPress(const GuiPaint& p);
92 GuiShapeStyle& onDisable(const GuiPaint& p);
94 const GuiPaint& forState(SHAPE_STATE s) const;
95};
96
101void GuiAddPaintedShape(GuiMesh& mesh, SHAPE shape, const GuiRect& r, const GuiCorners& corners, const GuiPaint& paint);
Accumulates shapes as a triangle list of MeshVertex.
bool hasFill
The look of a shape: an optional fill, an optional outline and an optional shadow or glow.
Definition GuiPaint.h:28
STROKE
Where a stroke sits relative to the shape's geometric edge.
Definition GuiGeometry.h:52
SHAPE_STATE
The states a styled shape distinguishes.
Definition GuiPaint.h:70
void GuiAddPaintedShape(GuiMesh &mesh, SHAPE shape, const GuiRect &r, const GuiCorners &corners, const GuiPaint &paint)
Adds a painted shape to a mesh: shadow first, then fill, then outline.
Definition GuiPaint.cpp:218
SHAPE
Basic shape kinds a paint can be applied to.
Definition GuiPaint.h:17
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
@ INSIDE
Entirely inside the edge (the shape keeps its size)
Definition GuiGeometry.h:53
@ FOCUSED
Highlighted: under the cursor, or selected with the D-pad.
Definition GuiPaint.h:72
@ ELLIPSE
Ellipse inscribed in the rectangle (a circle when it is square)
Definition GuiPaint.h:19
@ RECTANGLE
Rectangle, with optional rounded corners (see GuiCorners)
Definition GuiPaint.h:18
Per-corner radii, in the order top-left, top-right, bottom-right, bottom-left.
Definition GuiGeometry.h:40
A solid color or a two-color linear gradient.
Definition GuiGeometry.h:60
An axis-aligned rectangle (top-left origin) in design-canvas pixels.
Definition GuiGeometry.h:30
const GuiPaint & forState(SHAPE_STATE s) const
Gets the paint for a state, falling back to normal when none was set.
Definition GuiPaint.cpp:207
8-bit-per-channel RGBA color used by the video interfaces.
Definition Mesh.h:16