ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
theme.h
Go to the documentation of this file.
1
8
9#ifndef ASW_MODULES_UI_THEME_H
10#define ASW_MODULES_UI_THEME_H
11
12#include <cstddef>
13
14#include "../color.h"
15#include "../geometry.h"
16#include "../types.h"
17#include "widget.h"
18
19namespace asw::ui {
20
26 asw::Color bg { 55, 55, 55, 255 };
27
29 asw::Color bg_hover { 75, 75, 75, 255 };
30
32 asw::Color bg_pressed { 95, 95, 95, 255 };
33
35 asw::Color bg_disabled { 30, 30, 30, 255 };
36
38 asw::Color text { 255, 255, 255, 255 };
39
41 asw::Color text_hover { 255, 255, 255, 255 };
42
44 asw::Color text_disabled { 200, 200, 200, 255 };
45
47 asw::Color border { 0, 0, 0, 0 };
48
50 float border_width = 0.0F;
51
54};
55
58enum class BoxSide {
59 Left,
60 Right,
61};
62
68 asw::Color bg { 0, 0, 0, 0 };
69
71 asw::Color bg_hover { 0, 0, 0, 0 };
72
74 asw::Color border { 0, 0, 0, 0 };
75
77 float border_width = 0.0F;
78
80 asw::Color box { 55, 55, 55, 255 };
81
83 asw::Color box_hover { 75, 75, 75, 255 };
84
86 asw::Color box_pressed { 95, 95, 95, 255 };
87
89 asw::Color box_disabled { 30, 30, 30, 255 };
90
92 asw::Color box_border { 0, 0, 0, 0 };
93
95 float box_border_width = 0.0F;
96
98 asw::Color mark { 255, 255, 255, 255 };
99
101 asw::Color mark_disabled { 200, 200, 200, 255 };
102
104 asw::Color text { 255, 255, 255, 255 };
105
107 asw::Color text_disabled { 200, 200, 200, 255 };
108
111};
112
118 asw::Color bg { 20, 20, 20, 255 };
119
121 asw::Color bg_disabled { 30, 30, 30, 255 };
122
124 asw::Color border { 55, 55, 55, 255 };
125
127 asw::Color border_hover { 75, 75, 75, 255 };
128
130 float border_width = 1.0F;
131
133 asw::Color text { 255, 255, 255, 255 };
134
136 asw::Color placeholder { 200, 200, 200, 255 };
137
139 asw::Color caret { 255, 255, 255, 255 };
140};
141
147 asw::Color track { 55, 55, 55, 255 };
148
150 asw::Color fill { 255, 200, 80, 255 };
151
153 asw::Color knob { 200, 200, 200, 255 };
154
156 asw::Color knob_hover { 255, 255, 255, 255 };
157
159 asw::Color knob_editing { 255, 200, 80, 255 };
160
162 asw::Color disabled { 90, 90, 90, 255 };
163
165 float track_height = 4.0F;
166
168 float knob_width = 10.0F;
169};
170
178 asw::Color bg { 20, 20, 20, 230 };
179
181 asw::Color text { 255, 255, 255, 255 };
182
184 asw::Color border { 0, 0, 0, 0 };
185
187 float border_width = 0.0F;
188
190 float padding = 12.0F;
191
193 float margin = 16.0F;
194
196 float gap = 8.0F;
197
199 float seconds = 3.0F;
200
202 float fade_seconds = 0.25F;
203
205 std::size_t max_visible = 3;
206
210};
211
216 asw::Color dim { 0, 0, 0, 160 };
217
219 asw::Color bg { 30, 30, 30, 255 };
220
222 asw::Color border { 0, 0, 0, 0 };
223
225 float border_width = 0.0F;
226
228 float padding = 20.0F;
229
231 float gap = 12.0F;
232
234 float min_width = 320.0F;
235};
236
239 asw::Color color { 255, 200, 80, 255 };
240
242 float width = 1.0F;
243
245 float offset = 2.0F;
246};
247
250struct Theme {
252 asw::Color text { 255, 255, 255, 255 };
253
255 asw::Color text_dim { 200, 200, 200, 255 };
256
258 asw::Color panel_bg { 30, 30, 30, 255 };
259
262
265
268
271
274
277
280
283
285 float padding = 10.0f;
286
288 float gap = 8.0f;
289
292
296};
297
304inline const asw::Font& pick_font(const asw::Font& own, const Theme& theme)
305{
306 return own != nullptr ? own : theme.font;
307}
308
314void draw_focus_ring(const FocusRingStyle& style, const asw::Quad<float>& bounds);
315
316} // namespace asw::ui
317
318#endif // ASW_MODULES_UI_THEME_H
A 2D rectangle in space.
Definition geometry.h:504
Common geometry types.
Anchor
A point of the parent an anchored widget sits at, see Widget::anchor.
Definition widget.h:24
const asw::Font & pick_font(const asw::Font &own, const Theme &theme)
The font a widget draws with: its own, or the theme font.
Definition theme.h:304
void draw_focus_ring(const FocusRingStyle &style, const asw::Quad< float > &bounds)
Draw a focus ring around a widget.
Definition theme.cpp:5
BoxSide
Which side of a checkbox the box is on.
Definition theme.h:58
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Definition types.h:79
std::shared_ptr< MIX_Audio > Sample
Alias for a shared pointer to an MIX_Audio.
Definition types.h:82
TextJustify
Text justification options for text rendering.
Definition types.h:58
RGBA color struct with 8-bit channels.
Definition color.h:18
How a button looks. Set on Theme::button for every button, or on Button::style for one button.
Definition theme.h:24
asw::Color bg_disabled
Background color while disabled.
Definition theme.h:35
float border_width
Border width in pixels, drawn inside the button. 0 draws no border.
Definition theme.h:50
asw::Color bg_pressed
Background color while pressed.
Definition theme.h:32
asw::Color text_disabled
Text color while disabled.
Definition theme.h:44
asw::TextJustify text_align
Where the text sits. Left and right are inset by the button padding.
Definition theme.h:53
asw::Color bg_hover
Background color while hovered, or focused with focus shown.
Definition theme.h:29
asw::Color text_hover
Text color while hovered, or focused with focus shown.
Definition theme.h:41
asw::Color border
Border color.
Definition theme.h:47
asw::Color text
Text color.
Definition theme.h:38
asw::Color bg
Background color.
Definition theme.h:26
How a checkbox looks. Set on Theme::checkbox for every checkbox, or on Checkbox::checkbox_style for o...
Definition theme.h:66
float border_width
Row border width in pixels. 0 draws no border.
Definition theme.h:77
asw::Color bg_hover
Row background color while hovered, or focused with focus shown.
Definition theme.h:71
BoxSide box_side
Which side the box is on. The text is on the other side.
Definition theme.h:110
asw::Color box_pressed
Box color while pressed.
Definition theme.h:86
asw::Color box_border
Box border color.
Definition theme.h:92
asw::Color text_disabled
Text color while disabled.
Definition theme.h:107
asw::Color box
Box color.
Definition theme.h:80
asw::Color border
Row border color.
Definition theme.h:74
asw::Color mark
Check mark color.
Definition theme.h:98
asw::Color mark_disabled
Check mark color while disabled.
Definition theme.h:101
float box_border_width
Box border width in pixels. 0 draws no border.
Definition theme.h:95
asw::Color box_disabled
Box color while disabled.
Definition theme.h:89
asw::Color bg
Background color of the whole row.
Definition theme.h:68
asw::Color text
Text color.
Definition theme.h:104
asw::Color box_hover
Box color while hovered, or focused with focus shown.
Definition theme.h:83
asw::Color color
Ring color.
Definition theme.h:239
float width
Ring width in pixels. 0 draws no ring.
Definition theme.h:242
float offset
Gap between the widget and the ring, in pixels.
Definition theme.h:245
How an input box looks. Set on Theme::input for every input box, or on InputBox::style for one input ...
Definition theme.h:116
asw::Color border
Border color.
Definition theme.h:124
asw::Color bg
Background color.
Definition theme.h:118
float border_width
Border width in pixels. 0 draws no border.
Definition theme.h:130
asw::Color caret
Text cursor color.
Definition theme.h:139
asw::Color placeholder
Placeholder text color.
Definition theme.h:136
asw::Color bg_disabled
Background color while disabled.
Definition theme.h:121
asw::Color border_hover
Border color while hovered.
Definition theme.h:127
asw::Color text
Text color.
Definition theme.h:133
Look of a Modal and the dimmed screen behind it.
Definition theme.h:214
float min_width
Narrowest the modal gets.
Definition theme.h:234
float border_width
Outline width.
Definition theme.h:225
asw::Color dim
Colour laid over the screen behind the modal.
Definition theme.h:216
asw::Color bg
Fill of the modal.
Definition theme.h:219
asw::Color border
Outline, none when the width is 0.
Definition theme.h:222
float padding
Space between the modal's edge and its content.
Definition theme.h:228
float gap
Space between its widgets.
Definition theme.h:231
How a slider looks. Set on Theme::slider for every slider, or on Slider::style for one slider.
Definition theme.h:145
asw::Color knob_hover
Knob color while hovered, pressed, or focused with focus shown.
Definition theme.h:156
float knob_width
Knob width in pixels. The knob is as tall as the widget.
Definition theme.h:168
asw::Color disabled
Knob and fill color while disabled.
Definition theme.h:162
asw::Color knob
Knob color.
Definition theme.h:153
asw::Color track
Track color.
Definition theme.h:147
float track_height
Track height in pixels, centred in the widget.
Definition theme.h:165
asw::Color fill
Color of the track up to the value.
Definition theme.h:150
asw::Color knob_editing
Knob color while editing with left and right, see Slider.
Definition theme.h:159
Theme configuration for UI elements.
Definition theme.h:250
asw::Color text
Default text color.
Definition theme.h:252
CheckboxStyle checkbox
Default checkbox style.
Definition theme.h:267
InputStyle input
Default input box style.
Definition theme.h:270
float gap
Default gap between elements.
Definition theme.h:288
asw::Color panel_bg
Panel background color.
Definition theme.h:258
ModalStyle modal
Modals from Root::open_modal.
Definition theme.h:282
FocusRingStyle focus_ring
Focus ring style.
Definition theme.h:276
SliderStyle slider
Default slider style.
Definition theme.h:273
asw::Sample sound_move
Played on the UI bus when navigation moves focus. Optional.
Definition theme.h:291
asw::Font font
Font for widgets that do not set their own.
Definition theme.h:261
ButtonStyle button
Default button style.
Definition theme.h:264
asw::Sample sound_activate
Played on the UI bus when a widget is clicked or activated. Optional.
Definition theme.h:295
asw::Color text_dim
Dimmed text color.
Definition theme.h:255
float padding
Default padding.
Definition theme.h:285
ToastStyle toast
Messages from Root::toast.
Definition theme.h:279
The ring drawn around the focused widget during keyboard or controller navigation.
Definition theme.h:176
float border_width
Outline width.
Definition theme.h:187
float padding
Space around the text inside each message.
Definition theme.h:190
float gap
Space between messages.
Definition theme.h:196
float seconds
How long a message stays, from when it shows.
Definition theme.h:199
float fade_seconds
How long a message takes to fade out at the end.
Definition theme.h:202
Anchor anchor
Where messages show: Top, TopLeft or TopRight stack down from the top, Bottom, BottomLeft or BottomRi...
Definition theme.h:209
asw::Color text
Message text.
Definition theme.h:181
asw::Color border
Outline, none when the width is 0.
Definition theme.h:184
asw::Color bg
Fill behind each message.
Definition theme.h:178
float margin
Space from the top of the screen to the first message.
Definition theme.h:193
std::size_t max_visible
Messages on screen at once, the rest wait their turn.
Definition theme.h:205
Types used throughout the ASW library.
Base widget class for the ASW UI module.