-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.h
58 lines (43 loc) · 1.02 KB
/
ui.h
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
#pragma once
#include "program.h"
#include "texture.h"
#include <SDL2/SDL_ttf.h>
typedef enum {
POSITION_ABSOLUTE = 0,
POSITION_RELATIVE = 1
} EPosition;
typedef enum {
DISPLAY_NONE = 0,
DISPLAY_INLINE = 1,
DISPLAY_BLOCK = 2
} EDisplay;
typedef struct UI UI;
struct UIElement {
GLint top_px, left_px, height_px, width_px;
EPosition position;
EDisplay display;
bool centered;
int children_no;
struct UIElement **children;
struct UIElement *parent;
Texture texture;
UI *ui;
};
typedef struct UIElement UIElement;
struct UI {
UIElement *root;
TTF_Font * main_font;
program_t program;
int width_px;
int height_px;
/* Quad VAO, this is shared by all UI elements */
GLuint vao;
};
UIElement *UIElement_new_image(UI * ui, const char *path);
UIElement *UIElement_load(UI * ui);
void UIElement_delete(UIElement * element);
void UIElement_draw(UIElement * element);
void UIElement_addChild(UIElement * parent, UIElement * child);
void load_UI(UI * ui);
void unload_UI();
void UIElement_center(UIElement * element);