]> git.lizzy.rs Git - dragonblocks_alpha.git/blob - src/client/gui.h
7fd1844820405dba9814f366cffcd5a3de541ed0
[dragonblocks_alpha.git] / src / client / gui.h
1 #ifndef _GUI_H_
2 #define _GUI_H_
3
4 #include <stdbool.h>
5 #include <linmath.h/linmath.h>
6 #include <dragonstd/bintree.h>
7 #include <dragonstd/list.h>
8 #include "client/font.h"
9 #include "client/texture.h"
10 #include "types.h"
11
12 typedef enum
13 {
14         GST_IMAGE,
15         GST_TEXT,
16         GST_PARENT,
17         GST_CHILDREN,
18         GST_NONE,
19 } GUIScaleType;
20
21 typedef struct
22 {
23         v2f32 pos;
24         f32 z_index;
25         v2s32 offset;
26         v2s32 margin;
27         v2f32 align;
28         v2f32 scale;
29         GUIScaleType scale_type;
30         bool affect_parent_scale;
31         char *text;
32         Texture *image;
33         v4f32 text_color;
34         v4f32 bg_color;
35 } GUIElementDefinition;
36
37 typedef struct GUIElement
38 {
39         GUIElementDefinition def;
40         bool visible;
41         v2f32 pos;
42         v2f32 scale;
43         mat4x4 transform;
44         mat4x4 text_transform;
45         Font *text;
46         struct GUIElement *parent;
47         Bintree children;
48 } GUIElement;
49
50 bool gui_init();
51 void gui_deinit();
52 void gui_on_resize(int width, int height);
53 void gui_render();
54 GUIElement *gui_add(GUIElement *parent, GUIElementDefinition def);
55 void gui_set_text(GUIElement *element, char *text);
56 void gui_update_transform(GUIElement *element);
57
58 extern GUIElement gui_root;
59
60 #endif