-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.h
More file actions
188 lines (155 loc) · 3.35 KB
/
Copy pathui.h
File metadata and controls
188 lines (155 loc) · 3.35 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#ifndef UI_H
#define UI_H
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <stdbool.h>
typedef struct {
Uint8 r;
Uint8 g;
Uint8 b;
Uint8 a;
} UIColor;
typedef struct {
float scale;
int window_w;
int window_h;
/*
Base design resolution.
*/
float base_w;
float base_h;
bool dark;
} UIContext;
/* ---------------------------------------------------------
Context
--------------------------------------------------------- */
void ui_begin(
UIContext *ui,
int width,
int height
);
/* ---------------------------------------------------------
Geometry
--------------------------------------------------------- */
SDL_Rect ui_rect(
UIContext *ui,
float x,
float y,
float w,
float h
);
bool ui_point_in_rect(
int x,
int y,
SDL_Rect rect
);
/* ---------------------------------------------------------
Primitive rendering
--------------------------------------------------------- */
void ui_fill_rounded_rect(
SDL_Renderer *renderer,
SDL_Rect rect,
int radius,
UIColor color
);
void ui_outline_rounded_rect(
SDL_Renderer *renderer,
SDL_Rect rect,
int radius,
UIColor color
);
void ui_fill_circle(
SDL_Renderer *renderer,
int cx,
int cy,
int radius,
UIColor color
);
void ui_fill_capsule(
SDL_Renderer *renderer,
SDL_Rect rect,
UIColor color
);
/* ---------------------------------------------------------
Materials
--------------------------------------------------------- */
void ui_glass(
SDL_Renderer *renderer,
SDL_Rect rect,
int radius,
bool active,
bool dark
);
/* ---------------------------------------------------------
Gradient fill
--------------------------------------------------------- */
void ui_fill_rounded_rect_gradient(
SDL_Renderer *renderer,
SDL_Rect rect,
int radius,
UIColor top,
UIColor bottom
);
void ui_fill_gradient_rect(
SDL_Renderer *renderer,
SDL_Rect rect,
UIColor top,
UIColor bottom
);
UIColor ui_color_lerp(
UIColor a,
UIColor b,
float t
);
UIColor ui_theme(
bool dark,
UIColor light,
UIColor dark_color
);
/* ---------------------------------------------------------
Radial gradient (for soft orbs)
--------------------------------------------------------- */
void ui_fill_radial_gradient(
SDL_Renderer *renderer,
int cx,
int cy,
int radius,
UIColor center,
UIColor edge
);
/* ---------------------------------------------------------
Easing
--------------------------------------------------------- */
float ui_ease_out_cubic(float t);
float ui_ease_in_out_cubic(float t);
/* ---------------------------------------------------------
Text (cached, with optional shadow)
--------------------------------------------------------- */
void ui_text_cache_clear(void);
void ui_text_cache_shutdown(void);
void ui_text(
SDL_Renderer *renderer,
TTF_Font *font,
const char *text,
int x,
int y,
UIColor color
);
void ui_text_shadow(
SDL_Renderer *renderer,
TTF_Font *font,
const char *text,
int x,
int y,
UIColor color,
UIColor shadow,
int offset
);
void ui_text_center(
SDL_Renderer *renderer,
TTF_Font *font,
const char *text,
SDL_Rect rect,
UIColor color
);
#endif /* UI_H */