TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_base_types.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <assert.h>
5#include <functional>
6
7
8namespace tachyon
9{
12
13 using OnGuiFunc = std::function<void()>;
14
17 struct int2
18 {
19 int32_t x, y;
20
21 inline int32_t& operator[](int index) { assert(index >= 0 && index < 2); return (&x)[index]; }
22 inline const int32_t& operator[](int index) const { assert(index >= 0 && index < 2); return (&x)[index]; }
23 inline bool operator==(const int2& other) const { return x == other.x && y == other.y; }
24 inline bool operator!=(const int2& other) const { return !(*this == other); }
25
26 inline int2 operator-() const { return int2{ -x, -y }; }
27 inline int2 operator+() const { return int2{ x, y }; }
28
29 inline int2 operator- (const int2& other) const { return int2 { x - other.x, y - other.y }; }
30 inline int2 operator+ (const int2& other) const { return int2 { x + other.x, y + other.y }; }
31 inline int2& operator-=(const int2& other) { x -= other.x; y -= other.y; return *this; }
32 inline int2& operator+=(const int2& other) { x += other.x; y += other.y; return *this; }
33 };
34
35 struct int3
36 {
37 int32_t x = 0, y = 0, z = 0;
38
39 inline int32_t& operator[](int index) { assert(index >= 0 && index < 3); return (&x)[index]; }
40 inline const int32_t& operator[](int index) const { assert(index >= 0 && index < 3); return (&x)[index]; }
41 inline bool operator==(const int3& other) const { return x == other.x && y == other.y && z == other.z; }
42 inline bool operator!=(const int3& other) const { return !(*this == other); }
43
44 inline int3 operator-() const { return int3{ -x, -y, -z }; }
45 inline int3 operator+() const { return int3{ x, y, z }; }
46
47 inline int3 operator- (const int3& other) const { return int3 { x - other.x, y - other.y, z - other.z }; }
48 inline int3 operator+ (const int3& other) const { return int3 { x + other.x, y + other.y, z + other.z }; }
49 inline int3& operator-=(const int3& other) { x -= other.x; y -= other.y; z -= other.z; return *this; }
50 inline int3& operator+=(const int3& other) { x += other.x; y += other.y; z += other.z; return *this; }
51 };
52
53 struct int4
54 {
55 int32_t x = 0, y = 0, z = 0, w = 0;
56
57 inline int32_t& operator[](int index) { assert(index >= 0 && index < 4); return (&x)[index]; }
58 inline const int32_t& operator[](int index) const { assert(index >= 0 && index < 4); return (&x)[index]; }
59 inline bool operator==(const int4& other) const { return x == other.x && y == other.y && z == other.z && w == other.w; }
60 inline bool operator!=(const int4& other) const { return !(*this == other); }
61
62 inline int4 operator-() const { return int4{ -x, -y, -z, -w }; }
63 inline int4 operator+() const { return int4{ x, y, z, w }; }
64
65 inline int4 operator- (const int4& other) const { return int4 { x - other.x, y - other.y, z - other.z, w - other.w }; }
66 inline int4 operator+ (const int4& other) const { return int4 { x + other.x, y + other.y, z + other.z, w + other.w }; }
67 inline int4& operator-=(const int4& other) { x -= other.x; y -= other.y; z -= other.z; w -= other.w; return *this; }
68 inline int4& operator+=(const int4& other) { x += other.x; y += other.y; z += other.z; w += other.w; return *this; }
69 };
70
71
72
73 struct uint2
74 {
75 uint32_t x = 0, y = 0;
76
77 inline uint32_t& operator[](int index) { assert(index >= 0 && index < 2); return (&x)[index]; }
78 inline const uint32_t& operator[](int index) const { assert(index >= 0 && index < 2); return (&x)[index]; }
79 inline bool operator==(const uint2& other) const { return x == other.x && y == other.y; }
80 inline bool operator!=(const uint2& other) const { return !(*this == other); }
81
82 inline uint2 operator- (const uint2& other) const { return uint2 { x - other.x, y - other.y }; }
83 inline uint2 operator+ (const uint2& other) const { return uint2 { x + other.x, y + other.y }; }
84 inline uint2& operator-=(const uint2& other) { x -= other.x; y -= other.y; return *this; }
85 inline uint2& operator+=(const uint2& other) { x += other.x; y += other.y; return *this; }
86 };
87
88 struct uint3
89 {
90 uint32_t x = 0, y = 0, z = 0;
91
92 inline uint32_t& operator[](int index) { assert(index >= 0 && index < 3); return (&x)[index]; }
93 inline const uint32_t& operator[](int index) const { assert(index >= 0 && index < 3); return (&x)[index]; }
94 inline bool operator==(const uint3& other) const { return x == other.x && y == other.y && z == other.z; }
95 inline bool operator!=(const uint3& other) const { return !(*this == other); }
96
97 inline uint3 operator- (const uint3& other) const { return uint3 { x - other.x, y - other.y, z - other.z }; }
98 inline uint3 operator+ (const uint3& other) const { return uint3 { x + other.x, y + other.y, z + other.z }; }
99 inline uint3& operator-=(const uint3& other) { x -= other.x; y -= other.y; z -= other.z; return *this; }
100 inline uint3& operator+=(const uint3& other) { x += other.x; y += other.y; z += other.z; return *this; }
101 };
102
103 struct uint4
104 {
105 uint32_t x = 0, y = 0, z = 0, w = 0;
106
107 inline uint32_t& operator[](int index) { assert(index >= 0 && index < 4); return (&x)[index]; }
108 inline const uint32_t& operator[](int index) const { assert(index >= 0 && index < 4); return (&x)[index]; }
109 inline bool operator==(const uint4& other) const { return x == other.x && y == other.y && z == other.z && w == other.w; }
110 inline bool operator!=(const uint4& other) const { return !(*this == other); }
111
112 inline uint4 operator- (const uint4& other) const { return uint4 { x - other.x, y - other.y, z - other.z, w - other.w }; }
113 inline uint4 operator+ (const uint4& other) const { return uint4 { x + other.x, y + other.y, z + other.z, w + other.w }; }
114 inline uint4& operator-=(const uint4& other) { x -= other.x; y -= other.y; z -= other.z; w -= other.w; return *this; }
115 inline uint4& operator+=(const uint4& other) { x += other.x; y += other.y; z += other.z; w += other.w; return *this; }
116 };
117
118
119 struct float2
120 {
121 float x = 0, y = 0;
122
123 inline float& operator[](int index) { assert(index >= 0 && index < 2); return (&x)[index]; }
124 inline const float& operator[](int index) const { assert(index >= 0 && index < 2); return (&x)[index]; }
125
126 inline float2 operator-() const { return float2{ -x, -y }; }
127 inline float2 operator+() const { return float2{ x, y }; }
128
129 inline float2 operator- (const int2& other) const { return float2{ x - other.x, y - other.y }; }
130 inline float2 operator+ (const int2& other) const { return float2{ x + other.x, y + other.y }; }
131 inline float2& operator-=(const int2& other) { x -= other.x; y -= other.y; return *this; }
132 inline float2& operator+=(const int2& other) { x += other.x; y += other.y; return *this; }
133
134 inline float2 operator- (const float2& other) const { return float2{ x - other.x, y - other.y }; }
135 inline float2 operator+ (const float2& other) const { return float2{ x + other.x, y + other.y }; }
136 inline float2& operator-=(const float2& other) { x -= other.x; y -= other.y; return *this; }
137 inline float2& operator+=(const float2& other) { x += other.x; y += other.y; return *this; }
138
139 inline float2 operator* (float other) const { return float2{ x * other, y * other }; }
140 inline float2 operator/ (float other) const { return float2{ x / other, y / other }; }
141 inline float2& operator*=(float other) { x *= other; y *= other; return *this; }
142 inline float2& operator/=(float other) { x /= other; y /= other; return *this; }
143
144 inline bool operator==(const float2& other) const { return x == other.x && y == other.y; }
145 inline bool operator!=(const float2& other) const { return !(*this == other); }
146 };
147
148 struct float3
149 {
150 float x = 0, y = 0, z = 0;
151
152 inline float& operator[](int index) { assert(index >= 0 && index < 3); return (&x)[index]; }
153 inline const float& operator[](int index) const { assert(index >= 0 && index < 3); return (&x)[index]; }
154
155 inline float3 operator-() const { return float3{ -x, -y, -z }; }
156 inline float3 operator+() const { return float3{ x, y, z }; }
157
158 inline float3 operator- (const float3& other) const { return float3{ x - other.x, y - other.y, z - other.z }; }
159 inline float3 operator+ (const float3& other) const { return float3{ x + other.x, y + other.y, z + other.z }; }
160 inline float3& operator-=(const float3& other) { x -= other.x; y -= other.y; z -= other.z; return *this; }
161 inline float3& operator+=(const float3& other) { x += other.x; y += other.y; z += other.z; return *this; }
162
163 inline float3 operator* (float other) const { return float3{ x * other, y * other, z * other }; }
164 inline float3 operator/ (float other) const { return float3{ x / other, y / other, z / other }; }
165 inline float3& operator*=(float other) { x *= other; y *= other; z *= other; return *this; }
166 inline float3& operator/=(float other) { x /= other; y /= other; z /= other; return *this; }
167
168 inline bool operator==(const float3& other) const { return x == other.x && y == other.y && z == other.z; }
169 inline bool operator!=(const float3& other) const { return !(*this == other); }
170 };
171
172 struct float4
173 {
174 float x = 0, y = 0, z = 0, w = 0;
175
176 inline float& operator[](int index) { assert(index >= 0 && index < 4); return (&x)[index]; }
177 inline const float& operator[](int index) const { assert(index >= 0 && index < 4); return (&x)[index]; }
178
179 inline float4 operator-() const { return float4{ -x, -y, -z, -w }; }
180 inline float4 operator+() const { return float4{ x, y, z, w }; }
181
182 inline float4 operator- (const float4& other) const { return float4{ x - other.x, y - other.y, z - other.z, w - other.w }; }
183 inline float4 operator+ (const float4& other) const { return float4{ x + other.x, y + other.y, z + other.z, w + other.w }; }
184 inline float4& operator-=(const float4& other) { x -= other.x; y -= other.y; z -= other.z; w -= other.w; return *this; }
185 inline float4& operator+=(const float4& other) { x += other.x; y += other.y; z += other.z; w += other.w; return *this; }
186
187 inline float4 operator* (float other) const { return float4{ x * other, y * other, z * other, w * other }; }
188 inline float4 operator/ (float other) const { return float4{ x / other, y / other, z / other, w / other }; }
189 inline float4& operator*=(float other) { x *= other; y *= other; z *= other; w *= other; return *this; }
190 inline float4& operator/=(float other) { x /= other; y /= other; z /= other; w /= other; return *this; }
191
192 inline bool operator==(const float4& other) const { return x == other.x && y == other.y && z == other.z && w == other.w; }
193 inline bool operator!=(const float4& other) const { return !(*this == other); }
194
195 inline float4 operator*(float const scale)
196 {
197 return float4{x * scale, y * scale, z * scale, w * scale};
198 }
199 };
200
201 struct float2x2
202 {
203 float2 r0 = float2{1,0}, r1 = float2{0,1};
204
205 inline float2& operator[](int index) { assert(index >= 0 && index < 2); return (&r0)[index]; }
206 inline const float2& operator[](int index) const { assert(index >= 0 && index < 2); return (&r0)[index]; }
207
208 inline bool operator==(const float2x2& other) const { return r0 == other.r0 && r1 == other.r1; }
209 inline bool operator!=(const float2x2& other) const { return !(*this == other); }
210
212 };
213
217 struct float3x2
218 {
219 float3 r0 = float3 { 1,0,0 }, r1 = float3 { 0,1,0 };
220
221 inline float3& operator[](int index) { assert(index >= 0 && index < 2); return (&r0)[index]; }
222 inline const float3& operator[](int index) const { assert(index >= 0 && index < 2); return (&r0)[index]; }
223
224 inline bool operator==(const float3x2& other) const { return r0 == other.r0 && r1 == other.r1; }
225 inline bool operator!=(const float3x2& other) const { return !(*this == other); }
226
227 static constexpr float3x2 Identity() { return float3x2{}; }
228
229 inline bool IsIdentity() const
230 {
231 return r0.x == 1.0f && r0.y == 0.0f && r0.z == 0.0f &&
232 r1.x == 0.0f && r1.y == 1.0f && r1.z == 0.0f;
233 }
234
235 // Compose: apply this transform after b (result = this * b)
236 float3x2 operator*(const float3x2& b) const;
237
238
239 inline static float3x2 Scale(int2 scale) { return { { (float)scale.x, 0, 0 }, { 0, (float)scale.y, 0 } }; }
240 inline static float3x2 Scale(int x, int y) { return { { (float)x, 0, 0 }, { 0, (float)y, 0 } }; }
241 inline static float3x2 Scale(int s) { return { { (float)s, 0, 0 }, { 0, (float)s, 0 } }; }
242 inline static float3x2 Translate(int2 translation) { return { { 1, 0, (float)translation.x }, { 0, 1, (float)translation.y } }; }
243 inline static float3x2 Translate(int x, int y) { return { { 1, 0, (float)x }, { 0, 1, (float)y } }; }
244
245 inline static float3x2 Scale(float2 scale) { return { { scale.x, 0, 0 }, { 0, scale.y, 0 } }; }
246 inline static float3x2 Scale(float x, float y) { return { { x, 0, 0 }, { 0, y, 0 } }; }
247 inline static float3x2 Scale(float s) { return { { s, 0, 0 }, { 0, s, 0 } }; }
248 inline static float3x2 Translate(float2 translation) { return { { 1, 0, translation.x }, { 0, 1, translation.y } }; }
249 inline static float3x2 Translate(float x, float y) { return { { 1, 0, x }, { 0, 1, y } }; }
250
253
255 };
256
257 struct float4x4
258 {
259 float4 r0 = float4{1,0,0,0}, r1 = float4{0,1,0,0}, r2 = float4{0,0,1,0}, r3 = float4{0,0,0,1};
260
261 inline float4& operator[](int index) { assert(index >= 0 && index < 4); return (&r0)[index]; }
262 inline const float4& operator[](int index) const { assert(index >= 0 && index < 4); return (&r0)[index]; }
263
264 inline bool operator==(const float4x4& other) const { return r0 == other.r0 && r1 == other.r1 && r2 == other.r2 && r3 == other.r3; }
265 inline bool operator!=(const float4x4& other) const { return !(*this == other); }
266
267
268 float4x4 operator*(float4x4 const& m2) const;
269 };
270
271
272
273 using byte = unsigned char;
274
275 struct byte2
276 {
277 byte x = 0, y = 0;
278
279 inline byte& operator[](int index) { assert(index >= 0 && index < 2); return (&x)[index]; }
280 inline const byte& operator[](int index) const { assert(index >= 0 && index < 2); return (&x)[index]; }
281
282 inline bool operator==(const byte2& other) const { return x == other.x && y == other.y; }
283 inline bool operator!=(const byte2& other) const { return !(*this == other); }
284 };
285
286 struct byte3
287 {
288 byte x = 0, y = 0, z = 0;
289
290 inline byte& operator[](int index) { assert(index >= 0 && index < 3); return (&x)[index]; }
291 inline const byte& operator[](int index) const { assert(index >= 0 && index < 3); return (&x)[index]; }
292
293 inline bool operator==(const byte3& other) const { return x == other.x && y == other.y && z == other.z; }
294 inline bool operator!=(const byte3& other) const { return !(*this == other); }
295 };
296
297 struct byte4
298 {
299 byte x = 0, y = 0, z = 0, w = 0;
300
301 inline byte& operator[](int index) { assert(index >= 0 && index < 4); return (&x)[index]; }
302 inline const byte& operator[](int index) const { assert(index >= 0 && index < 4); return (&x)[index]; }
303
304 inline bool operator==(const byte4& other) const { return x == other.x && y == other.y && z == other.z && w == other.w; }
305 inline bool operator!=(const byte4& other) const { return !(*this == other); }
306 };
307
308
309
310
311 struct short2
312 {
313 short x = 0, y = 0;
314
315 inline short& operator[](int index) { assert(index >= 0 && index < 2); return (&x)[index]; }
316 inline const short& operator[](int index) const { assert(index >= 0 && index < 2); return (&x)[index]; }
317
318 inline bool operator==(const short2& other) const { return x == other.x && y == other.y; }
319 inline bool operator!=(const short2& other) const { return !(*this == other); }
320 };
321
322 struct short3
323 {
324 short x = 0, y = 0, z = 0;
325
326 inline short& operator[](int index) { assert(index >= 0 && index < 3); return (&x)[index]; }
327 inline const short& operator[](int index) const { assert(index >= 0 && index < 3); return (&x)[index]; }
328
329 inline bool operator==(const short3& other) const { return x == other.x && y == other.y && z == other.z; }
330 inline bool operator!=(const short3& other) const { return !(*this == other); }
331 };
332
333 struct short4
334 {
335 short x = 0, y = 0, z = 0, w = 0;
336
337 inline short& operator[](int index) { assert(index >= 0 && index < 4); return (&x)[index]; }
338 inline const short& operator[](int index) const { assert(index >= 0 && index < 4); return (&x)[index]; }
339
340 inline bool operator==(const short4& other) const { return x == other.x && y == other.y && z == other.z && w == other.w; }
341 inline bool operator!=(const short4& other) const { return !(*this == other); }
342 };
343
344
345
346 using ushort = unsigned short;
347
348 struct ushort2
349 {
350 ushort x = 0, y = 0;
351
352 inline ushort& operator[](int index) { assert(index >= 0 && index < 2); return (&x)[index]; }
353 inline const ushort& operator[](int index) const { assert(index >= 0 && index < 2); return (&x)[index]; }
354
355 inline bool operator==(const ushort2& other) const { return x == other.x && y == other.y; }
356 inline bool operator!=(const ushort2& other) const { return !(*this == other); }
357 };
358
359 struct ushort3
360 {
361 ushort x = 0, y = 0, z = 0;
362
363 inline ushort& operator[](int index) { assert(index >= 0 && index < 3); return (&x)[index]; }
364 inline const ushort& operator[](int index) const { assert(index >= 0 && index < 3); return (&x)[index]; }
365
366 inline bool operator==(const ushort3& other) const { return x == other.x && y == other.y && z == other.z; }
367 inline bool operator!=(const ushort3& other) const { return !(*this == other); }
368 };
369
370 struct ushort4
371 {
372 ushort x = 0, y = 0, z = 0, w = 0;
373
374 inline ushort& operator[](int index) { assert(index >= 0 && index < 4); return (&x)[index]; }
375 inline const ushort& operator[](int index) const { assert(index >= 0 && index < 4); return (&x)[index]; }
376
377 inline bool operator==(const ushort4& other) const { return x == other.x && y == other.y && z == other.z && w == other.w; }
378 inline bool operator!=(const ushort4& other) const { return !(*this == other); }
379 };
380
381
382 struct color4b
383 {
384 byte r = 0, g = 0, b = 0, a = 0;
385
386 inline byte& operator[](int index) { assert(index >= 0 && index < 4); return (&r)[index]; }
387 inline const byte& operator[](int index) const { assert(index >= 0 && index < 4); return (&r)[index]; }
388
389 inline bool operator==(const color4b& other) const { return r == other.r && g == other.g && b == other.b && a == other.a; }
390 inline bool operator!=(const color4b& other) const { return !(*this == other); }
391 };
392
393 struct color4f
394 {
395 float r = 0, g = 0, b = 0, a = 0;
396
397 inline float& operator[](int index) { assert(index >= 0 && index < 4); return (&r)[index]; }
398 inline const float& operator[](int index) const { assert(index >= 0 && index < 4); return (&r)[index]; }
399
400 inline bool operator==(const color4f& other) const { return r == other.r && g == other.g && b == other.b && a == other.a; }
401 inline bool operator!=(const color4f& other) const { return !(*this == other); }
402 };
403
404
405 struct IntRect
406 {
407 union
408 {
409 struct { int32_t x, y, w, h; };
410 struct { int2 position, size; };
411 };
412
413 bool Contains(int2 p) const { return p.x >= x && p.y >= y && p.x < x + w && p.y < y + h; }
414
415 inline int32_t Min(int axis) const { return position[axis]; }
416 inline int32_t Max(int axis) const { return position[axis] + size[axis]; }
417
418 inline int2 Min() const { return position; }
419 inline int2 Max() const { return position + size; }
420
421 inline int2 Center() const { return { x + w / 2, y + h / 2 }; }
422 inline int2 TopLeft() const { return { x, y }; }
423 inline int2 TopCenter() const { return { x + w / 2, y }; }
424 inline int2 TopRight() const { return { x + w, y }; }
425 inline int2 MiddleLeft() const { return { x, y + h / 2 }; }
426 inline int2 MiddleRight() const { return { x + w, y + h / 2 }; }
427 inline int2 BottomLeft() const { return { x, y + h }; }
428 inline int2 BottomCenter()const { return { x + w / 2, y + h }; }
429 inline int2 BottomRight() const { return { x + w, y + h }; }
430
431 inline bool operator==(const IntRect& other) const { return x == other.x && y == other.y && w == other.w && h == other.h; }
432 inline bool operator!=(const IntRect& other) const { return !(*this == other); }
433
434 inline IntRect operator+ (const int2& other) const { return IntRect { .x = x + other.x, .y = y + other.y, .w = w, .h = h }; }
435 inline IntRect operator- (const int2& other) const { return IntRect { .x = x - other.x, .y = y - other.y, .w = w, .h = h }; }
436
437 inline IntRect& operator+=(const int2& other) { x += other.x; y += other.y; return *this; }
438 inline IntRect& operator-=(const int2& other) { x -= other.x; y -= other.y; return *this; }
439
440 static IntRect Inflate(IntRect a, int32_t t, int32_t r, int32_t b, int32_t l);
441 inline IntRect Inflate(int32_t t, int32_t r, int32_t b, int32_t l) const { return Inflate(*this, t, r, b, l); }
442
443 static IntRect Inflate(IntRect a, int32_t n);
444 inline IntRect Inflate(int32_t n) const { return Inflate(*this, n); }
445
446 static IntRect Deflate(IntRect a, int32_t t, int32_t r, int32_t b, int32_t l);
447 inline IntRect Deflate(int32_t t, int32_t r, int32_t b, int32_t l) const { return Deflate(*this, t, r, b, l); }
448
449 static IntRect Deflate(IntRect a, int32_t n);
450 inline IntRect Deflate(int32_t n) const { return Deflate(*this, n); }
451
452 // Inline: layout and drawing intersect and unite rects for every element.
454 {
455 const int32_t ax2 = a.x + (a.w > 0 ? a.w : 0), ay2 = a.y + (a.h > 0 ? a.h : 0);
456 const int32_t bx2 = b.x + (b.w > 0 ? b.w : 0), by2 = b.y + (b.h > 0 ? b.h : 0);
457 const int32_t x = a.x > b.x ? a.x : b.x, y = a.y > b.y ? a.y : b.y;
458 const int32_t w = (ax2 < bx2 ? ax2 : bx2) - x, h = (ay2 < by2 ? ay2 : by2) - y;
459 return IntRect{ x, y, w > 0 ? w : 0, h > 0 ? h : 0 };
460 }
461 inline IntRect Intersection(IntRect b) const { return Intersection(*this, b); }
462
464 {
465 const int32_t ax2 = a.x + (a.w > 0 ? a.w : 0), ay2 = a.y + (a.h > 0 ? a.h : 0);
466 const int32_t bx2 = b.x + (b.w > 0 ? b.w : 0), by2 = b.y + (b.h > 0 ? b.h : 0);
467 const int32_t x = a.x < b.x ? a.x : b.x, y = a.y < b.y ? a.y : b.y;
468 const int32_t w = (ax2 > bx2 ? ax2 : bx2) - x, h = (ay2 > by2 ? ay2 : by2) - y;
469 return IntRect{ x, y, w > 0 ? w : 0, h > 0 ? h : 0 };
470 }
471 inline IntRect Union(IntRect b) const { return Union(*this, b); }
472
473 inline bool IsEmpty() const { return *this == IntRect{ 0,0,0,0 }; }
474
476 IntRect Transform(const float3x2& m) const;
477 IntRect Transform(int2 offset, const float3x2& m) const;
478 IntRect Transform(IntRect parentRect, const float3x2& m) const;
479 };
480
481 uint16_t FloatToHalf(float value);
482 float HalfToFloat(uint16_t value);
483
488
490 using SteadyClockSource = int64_t (*)();
494
496}// namespace tachyon
void SetSteadyClockSource(SteadyClockSource source)
Makes SteadyClockNowNanos read source, e.g.
unsigned short ushort
Definition gui_base_types.h:346
float HalfToFloat(uint16_t value)
unsigned char byte
Definition gui_base_types.h:273
std::function< void()> OnGuiFunc
Definition gui_base_types.h:13
int64_t(*)() SteadyClockSource
Where SteadyClockNowNanos reads the time; must never go backwards.
Definition gui_base_types.h:490
int64_t SteadyClockNowNanos()
Monotonic steady_clock time in nanoseconds; a plain int64_t keeps <chrono> out of widely-included hea...
uint16_t FloatToHalf(float value)
Definition gui_logging.h:24
Definition gui_base_types.h:406
IntRect operator-(const int2 &other) const
Definition gui_base_types.h:435
int2 Min() const
Definition gui_base_types.h:418
IntRect Transform(const float3x2 &m) const
The axis-aligned bounding rect of this rect transformed by m.
int2 MiddleLeft() const
Definition gui_base_types.h:425
IntRect Transform(int2 offset, const float3x2 &m) const
IntRect Inflate(int32_t t, int32_t r, int32_t b, int32_t l) const
Definition gui_base_types.h:441
IntRect Union(IntRect b) const
Definition gui_base_types.h:471
int32_t Min(int axis) const
Definition gui_base_types.h:415
IntRect Deflate(int32_t n) const
Definition gui_base_types.h:450
int32_t Max(int axis) const
Definition gui_base_types.h:416
static IntRect Union(IntRect a, IntRect b)
Definition gui_base_types.h:463
static IntRect Inflate(IntRect a, int32_t n)
bool Contains(int2 p) const
Definition gui_base_types.h:413
int2 Max() const
Definition gui_base_types.h:419
int2 Center() const
Definition gui_base_types.h:421
int2 BottomCenter() const
Definition gui_base_types.h:428
int2 TopCenter() const
Definition gui_base_types.h:423
IntRect Transform(IntRect parentRect, const float3x2 &m) const
IntRect Inflate(int32_t n) const
Definition gui_base_types.h:444
IntRect & operator+=(const int2 &other)
Definition gui_base_types.h:437
static IntRect Deflate(IntRect a, int32_t n)
bool operator==(const IntRect &other) const
Definition gui_base_types.h:431
IntRect Deflate(int32_t t, int32_t r, int32_t b, int32_t l) const
Definition gui_base_types.h:447
static IntRect Intersection(IntRect a, IntRect b)
Definition gui_base_types.h:453
static IntRect Deflate(IntRect a, int32_t t, int32_t r, int32_t b, int32_t l)
static IntRect Inflate(IntRect a, int32_t t, int32_t r, int32_t b, int32_t l)
int2 BottomRight() const
Definition gui_base_types.h:429
int2 MiddleRight() const
Definition gui_base_types.h:426
int2 TopLeft() const
Definition gui_base_types.h:422
int2 BottomLeft() const
Definition gui_base_types.h:427
IntRect operator+(const int2 &other) const
Definition gui_base_types.h:434
IntRect Intersection(IntRect b) const
Definition gui_base_types.h:461
IntRect & operator-=(const int2 &other)
Definition gui_base_types.h:438
int2 TopRight() const
Definition gui_base_types.h:424
bool operator!=(const IntRect &other) const
Definition gui_base_types.h:432
bool IsEmpty() const
Definition gui_base_types.h:473
Definition gui_base_types.h:276
byte & operator[](int index)
Definition gui_base_types.h:279
const byte & operator[](int index) const
Definition gui_base_types.h:280
bool operator==(const byte2 &other) const
Definition gui_base_types.h:282
bool operator!=(const byte2 &other) const
Definition gui_base_types.h:283
byte x
Definition gui_base_types.h:277
byte y
Definition gui_base_types.h:277
Definition gui_base_types.h:287
const byte & operator[](int index) const
Definition gui_base_types.h:291
bool operator==(const byte3 &other) const
Definition gui_base_types.h:293
byte & operator[](int index)
Definition gui_base_types.h:290
byte z
Definition gui_base_types.h:288
byte y
Definition gui_base_types.h:288
byte x
Definition gui_base_types.h:288
bool operator!=(const byte3 &other) const
Definition gui_base_types.h:294
Definition gui_base_types.h:298
const byte & operator[](int index) const
Definition gui_base_types.h:302
byte z
Definition gui_base_types.h:299
byte & operator[](int index)
Definition gui_base_types.h:301
bool operator==(const byte4 &other) const
Definition gui_base_types.h:304
byte x
Definition gui_base_types.h:299
byte w
Definition gui_base_types.h:299
bool operator!=(const byte4 &other) const
Definition gui_base_types.h:305
byte y
Definition gui_base_types.h:299
Definition gui_base_types.h:383
bool operator==(const color4b &other) const
Definition gui_base_types.h:389
const byte & operator[](int index) const
Definition gui_base_types.h:387
byte & operator[](int index)
Definition gui_base_types.h:386
byte b
Definition gui_base_types.h:384
byte g
Definition gui_base_types.h:384
byte a
Definition gui_base_types.h:384
bool operator!=(const color4b &other) const
Definition gui_base_types.h:390
byte r
Definition gui_base_types.h:384
Definition gui_base_types.h:394
const float & operator[](int index) const
Definition gui_base_types.h:398
float b
Definition gui_base_types.h:395
float r
Definition gui_base_types.h:395
bool operator!=(const color4f &other) const
Definition gui_base_types.h:401
float & operator[](int index)
Definition gui_base_types.h:397
bool operator==(const color4f &other) const
Definition gui_base_types.h:400
float a
Definition gui_base_types.h:395
float g
Definition gui_base_types.h:395
Definition gui_base_types.h:120
float2 & operator*=(float other)
Definition gui_base_types.h:141
float2 operator-() const
Definition gui_base_types.h:126
float & operator[](int index)
Definition gui_base_types.h:123
float2 & operator+=(const float2 &other)
Definition gui_base_types.h:137
float y
Definition gui_base_types.h:121
float2 & operator-=(const int2 &other)
Definition gui_base_types.h:131
bool operator!=(const float2 &other) const
Definition gui_base_types.h:145
float2 & operator/=(float other)
Definition gui_base_types.h:142
float2 operator/(float other) const
Definition gui_base_types.h:140
bool operator==(const float2 &other) const
Definition gui_base_types.h:144
const float & operator[](int index) const
Definition gui_base_types.h:124
float2 & operator+=(const int2 &other)
Definition gui_base_types.h:132
float2 & operator-=(const float2 &other)
Definition gui_base_types.h:136
float2 operator*(float other) const
Definition gui_base_types.h:139
float2 operator+() const
Definition gui_base_types.h:127
float x
Definition gui_base_types.h:121
Definition gui_base_types.h:202
bool operator==(const float2x2 &other) const
Definition gui_base_types.h:208
const float2 & operator[](int index) const
Definition gui_base_types.h:206
float2 r1
Definition gui_base_types.h:203
float2 r0
Definition gui_base_types.h:203
float2 & operator[](int index)
Definition gui_base_types.h:205
float2x2 operator*(float2x2 const &m2)
bool operator!=(const float2x2 &other) const
Definition gui_base_types.h:209
Definition gui_base_types.h:149
float3 operator/(float other) const
Definition gui_base_types.h:164
float y
Definition gui_base_types.h:150
float x
Definition gui_base_types.h:150
float3 operator+() const
Definition gui_base_types.h:156
bool operator==(const float3 &other) const
Definition gui_base_types.h:168
float3 & operator+=(const float3 &other)
Definition gui_base_types.h:161
float3 operator*(float other) const
Definition gui_base_types.h:163
float3 & operator-=(const float3 &other)
Definition gui_base_types.h:160
bool operator!=(const float3 &other) const
Definition gui_base_types.h:169
float3 & operator*=(float other)
Definition gui_base_types.h:165
float3 & operator/=(float other)
Definition gui_base_types.h:166
float z
Definition gui_base_types.h:150
float & operator[](int index)
Definition gui_base_types.h:152
float3 operator-() const
Definition gui_base_types.h:155
const float & operator[](int index) const
Definition gui_base_types.h:153
2D affine transform matrix (2 rows x 3 columns): x' = r0.x*x + r0.y*y + r0.z y' = r1....
Definition gui_base_types.h:218
float2 TransformVector(float2 p) const
bool operator!=(const float3x2 &other) const
Definition gui_base_types.h:225
float3x2 operator*(const float3x2 &b) const
static float3x2 Translate(float x, float y)
Definition gui_base_types.h:249
float3 & operator[](int index)
Definition gui_base_types.h:221
float3 r1
Definition gui_base_types.h:219
float2 TransformPoint(float2 p) const
const float3 & operator[](int index) const
Definition gui_base_types.h:222
static float3x2 Translate(float2 translation)
Definition gui_base_types.h:248
bool operator==(const float3x2 &other) const
Definition gui_base_types.h:224
static float3x2 Scale(float2 scale)
Definition gui_base_types.h:245
static constexpr float3x2 Identity()
Definition gui_base_types.h:227
static float3x2 Scale(float x, float y)
Definition gui_base_types.h:246
static float3x2 Scale(int s)
Definition gui_base_types.h:241
bool IsIdentity() const
Definition gui_base_types.h:229
static float3x2 Scale(float s)
Definition gui_base_types.h:247
float3x2 Inverse() const
static float3x2 Translate(int2 translation)
Definition gui_base_types.h:242
float3 r0
Definition gui_base_types.h:219
static float3x2 Translate(int x, int y)
Definition gui_base_types.h:243
static float3x2 Scale(int2 scale)
Definition gui_base_types.h:239
static float3x2 Scale(int x, int y)
Definition gui_base_types.h:240
Definition gui_base_types.h:173
float4 & operator*=(float other)
Definition gui_base_types.h:189
float4 operator+() const
Definition gui_base_types.h:180
float4 & operator+=(const float4 &other)
Definition gui_base_types.h:185
float4 operator/(float other) const
Definition gui_base_types.h:188
const float & operator[](int index) const
Definition gui_base_types.h:177
float y
Definition gui_base_types.h:174
float4 operator-() const
Definition gui_base_types.h:179
float x
Definition gui_base_types.h:174
float z
Definition gui_base_types.h:174
float4 & operator/=(float other)
Definition gui_base_types.h:190
float & operator[](int index)
Definition gui_base_types.h:176
float4 operator*(float other) const
Definition gui_base_types.h:187
float w
Definition gui_base_types.h:174
float4 & operator-=(const float4 &other)
Definition gui_base_types.h:184
float4 operator*(float const scale)
Definition gui_base_types.h:195
bool operator==(const float4 &other) const
Definition gui_base_types.h:192
bool operator!=(const float4 &other) const
Definition gui_base_types.h:193
Definition gui_base_types.h:258
float4 r3
Definition gui_base_types.h:259
bool operator!=(const float4x4 &other) const
Definition gui_base_types.h:265
float4 & operator[](int index)
Definition gui_base_types.h:261
float4 r1
Definition gui_base_types.h:259
float4 r2
Definition gui_base_types.h:259
float4 r0
Definition gui_base_types.h:259
float4x4 operator*(float4x4 const &m2) const
bool operator==(const float4x4 &other) const
Definition gui_base_types.h:264
const float4 & operator[](int index) const
Definition gui_base_types.h:262
Integer 2D vector.
Definition gui_base_types.h:18
int32_t x
Definition gui_base_types.h:19
int32_t & operator[](int index)
Definition gui_base_types.h:21
int2 & operator-=(const int2 &other)
Definition gui_base_types.h:31
bool operator==(const int2 &other) const
Definition gui_base_types.h:23
int2 operator+() const
Definition gui_base_types.h:27
int32_t y
Definition gui_base_types.h:19
bool operator!=(const int2 &other) const
Definition gui_base_types.h:24
int2 & operator+=(const int2 &other)
Definition gui_base_types.h:32
const int32_t & operator[](int index) const
Definition gui_base_types.h:22
int2 operator-() const
Definition gui_base_types.h:26
Definition gui_base_types.h:36
int32_t y
Definition gui_base_types.h:37
int3 & operator+=(const int3 &other)
Definition gui_base_types.h:50
int3 operator+() const
Definition gui_base_types.h:45
int3 & operator-=(const int3 &other)
Definition gui_base_types.h:49
int32_t & operator[](int index)
Definition gui_base_types.h:39
int3 operator-() const
Definition gui_base_types.h:44
int32_t x
Definition gui_base_types.h:37
bool operator!=(const int3 &other) const
Definition gui_base_types.h:42
int32_t z
Definition gui_base_types.h:37
bool operator==(const int3 &other) const
Definition gui_base_types.h:41
const int32_t & operator[](int index) const
Definition gui_base_types.h:40
Definition gui_base_types.h:54
bool operator==(const int4 &other) const
Definition gui_base_types.h:59
int32_t w
Definition gui_base_types.h:55
int4 operator+() const
Definition gui_base_types.h:63
int32_t x
Definition gui_base_types.h:55
int32_t y
Definition gui_base_types.h:55
int4 operator-() const
Definition gui_base_types.h:62
int32_t & operator[](int index)
Definition gui_base_types.h:57
bool operator!=(const int4 &other) const
Definition gui_base_types.h:60
const int32_t & operator[](int index) const
Definition gui_base_types.h:58
int32_t z
Definition gui_base_types.h:55
int4 & operator+=(const int4 &other)
Definition gui_base_types.h:68
int4 & operator-=(const int4 &other)
Definition gui_base_types.h:67
Definition gui_base_types.h:312
short x
Definition gui_base_types.h:313
bool operator!=(const short2 &other) const
Definition gui_base_types.h:319
short y
Definition gui_base_types.h:313
bool operator==(const short2 &other) const
Definition gui_base_types.h:318
short & operator[](int index)
Definition gui_base_types.h:315
const short & operator[](int index) const
Definition gui_base_types.h:316
Definition gui_base_types.h:323
short & operator[](int index)
Definition gui_base_types.h:326
const short & operator[](int index) const
Definition gui_base_types.h:327
short z
Definition gui_base_types.h:324
short x
Definition gui_base_types.h:324
short y
Definition gui_base_types.h:324
bool operator!=(const short3 &other) const
Definition gui_base_types.h:330
bool operator==(const short3 &other) const
Definition gui_base_types.h:329
Definition gui_base_types.h:334
short x
Definition gui_base_types.h:335
bool operator==(const short4 &other) const
Definition gui_base_types.h:340
short z
Definition gui_base_types.h:335
short w
Definition gui_base_types.h:335
short y
Definition gui_base_types.h:335
bool operator!=(const short4 &other) const
Definition gui_base_types.h:341
const short & operator[](int index) const
Definition gui_base_types.h:338
short & operator[](int index)
Definition gui_base_types.h:337
Definition gui_base_types.h:74
uint2 operator-(const uint2 &other) const
Definition gui_base_types.h:82
uint2 & operator-=(const uint2 &other)
Definition gui_base_types.h:84
uint32_t x
Definition gui_base_types.h:75
uint32_t y
Definition gui_base_types.h:75
uint2 operator+(const uint2 &other) const
Definition gui_base_types.h:83
bool operator==(const uint2 &other) const
Definition gui_base_types.h:79
uint32_t & operator[](int index)
Definition gui_base_types.h:77
const uint32_t & operator[](int index) const
Definition gui_base_types.h:78
bool operator!=(const uint2 &other) const
Definition gui_base_types.h:80
uint2 & operator+=(const uint2 &other)
Definition gui_base_types.h:85
Definition gui_base_types.h:89
bool operator!=(const uint3 &other) const
Definition gui_base_types.h:95
const uint32_t & operator[](int index) const
Definition gui_base_types.h:93
bool operator==(const uint3 &other) const
Definition gui_base_types.h:94
uint32_t z
Definition gui_base_types.h:90
uint32_t y
Definition gui_base_types.h:90
uint32_t x
Definition gui_base_types.h:90
uint3 operator-(const uint3 &other) const
Definition gui_base_types.h:97
uint3 & operator-=(const uint3 &other)
Definition gui_base_types.h:99
uint3 operator+(const uint3 &other) const
Definition gui_base_types.h:98
uint32_t & operator[](int index)
Definition gui_base_types.h:92
uint3 & operator+=(const uint3 &other)
Definition gui_base_types.h:100
Definition gui_base_types.h:104
uint4 & operator+=(const uint4 &other)
Definition gui_base_types.h:115
uint4 operator+(const uint4 &other) const
Definition gui_base_types.h:113
const uint32_t & operator[](int index) const
Definition gui_base_types.h:108
uint32_t y
Definition gui_base_types.h:105
bool operator!=(const uint4 &other) const
Definition gui_base_types.h:110
uint32_t z
Definition gui_base_types.h:105
uint4 & operator-=(const uint4 &other)
Definition gui_base_types.h:114
uint32_t & operator[](int index)
Definition gui_base_types.h:107
bool operator==(const uint4 &other) const
Definition gui_base_types.h:109
uint32_t x
Definition gui_base_types.h:105
uint4 operator-(const uint4 &other) const
Definition gui_base_types.h:112
uint32_t w
Definition gui_base_types.h:105
Definition gui_base_types.h:349
ushort & operator[](int index)
Definition gui_base_types.h:352
ushort x
Definition gui_base_types.h:350
const ushort & operator[](int index) const
Definition gui_base_types.h:353
ushort y
Definition gui_base_types.h:350
bool operator==(const ushort2 &other) const
Definition gui_base_types.h:355
bool operator!=(const ushort2 &other) const
Definition gui_base_types.h:356
Definition gui_base_types.h:360
ushort y
Definition gui_base_types.h:361
const ushort & operator[](int index) const
Definition gui_base_types.h:364
ushort x
Definition gui_base_types.h:361
bool operator!=(const ushort3 &other) const
Definition gui_base_types.h:367
ushort z
Definition gui_base_types.h:361
bool operator==(const ushort3 &other) const
Definition gui_base_types.h:366
ushort & operator[](int index)
Definition gui_base_types.h:363
Definition gui_base_types.h:371
ushort y
Definition gui_base_types.h:372
bool operator!=(const ushort4 &other) const
Definition gui_base_types.h:378
const ushort & operator[](int index) const
Definition gui_base_types.h:375
ushort & operator[](int index)
Definition gui_base_types.h:374
ushort x
Definition gui_base_types.h:372
ushort w
Definition gui_base_types.h:372
bool operator==(const ushort4 &other) const
Definition gui_base_types.h:377
ushort z
Definition gui_base_types.h:372