]> git.lizzy.rs Git - dragonblocks_alpha.git/blob - src/client/gui.h
ea4b15e559fab2fbc35a170c595d424cbad0a440
[dragonblocks_alpha.git] / src / client / gui.h
1 #ifndef _GUI_H_
2 #define _GUI_H_
3
4 #include <dragonstd/array.h>
5 #include <linmath.h/linmath.h>
6 #include <stdbool.h>
7 #include "client/font.h"
8 #include "client/texture.h"
9 #include "types.h"
10
11 typedef enum {
12         SCALE_IMAGE,
13         SCALE_TEXT,
14         SCALE_PARENT,
15         SCALE_CHILDREN,
16         SCALE_NONE,
17 } GUIScaleType;
18
19 typedef struct {
20         v2f32 pos;
21         f32 z_index;
22         v2s32 offset;
23         v2s32 margin;
24         v2f32 align;
25         v2f32 scale;
26         GUIScaleType scale_type;
27         bool affect_parent_scale;
28         char *text;
29         Texture *image;
30         v4f32 text_color;
31         v4f32 bg_color;
32 } GUIElementDefinition;
33
34 typedef struct GUIElement {
35         GUIElementDefinition def;
36         bool visible;
37         v2f32 pos;
38         v2f32 scale;
39         mat4x4 transform;
40         mat4x4 text_transform;
41         Font *text;
42         struct GUIElement *parent;
43         Array children;
44 } GUIElement;
45
46 bool gui_init();
47 void gui_deinit();
48 void gui_update_projection();
49 void gui_render();
50 GUIElement *gui_add(GUIElement *parent, GUIElementDefinition def);
51 void gui_text(GUIElement *element, const char *text);
52 void gui_transform(GUIElement *element);
53
54 #endif // _GUI_H_