aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy_ui.h
blob: 802ec842072f5fc94adce5e37d0de3dc8ab166b2 (plain)
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
#ifndef TEENSY_UI_H_
#define TEENSY_UI_H_

#include "teensy_common.h"
#include "teensy.h"

#define TYUI_MAX_LAYOUT_SIZE (16)

#define TYUI_WIN_NORESIZE  (1 << 0)
#define TYUI_WIN_NOCLOSE   (1 << 1)
#define TYUI_WIN_NOMOVE    (1 << 2)
#define TYUI_WIN_INVISIBLE (1 << 3)

#define tyui_begin_window(title, rect, id) \
    tyui_begin_window_ex(title, rect, id, 0, NULL)
#define tyui_text(...) tyui_text_ex(TYUI_ALIGN_LEFT, __VA_ARGS__)

typedef uint8_t tyui_Align;
enum {
    TYUI_ALIGN_LEFT,
    TYUI_ALIGN_RIGHT,
    TYUI_ALIGN_CENTER,
};

typedef struct {
    ty_Color fg_normal;
    ty_Color bg_normal;
    ty_Color fg_hover;
    ty_Color bg_hover;
    ty_Color fg_pressed;
    ty_Color bg_pressed;
    ty_Color win_bg;
    ty_Color win_title;
    ty_Color frame;
    int title_bar_height;
    int padding;
    int control_padding;
    int frame_size;
} tyui_Style;

typedef uint8_t tyui_Id;

void tyui_init(const ty_Font *font);
void tyui_deinit(void);

void tyui_push_layout(const float *column_widths);
void tyui_pop_layout(void);

void tyui_draw(void);

bool tyui_begin_window_ex(
    const char *title,
    ty_Recti rect,
    tyui_Id *id,
    uint32_t flags,
    bool *closed
);
void tyui_end_window(void);

bool tyui_button(const char *text);
void tyui_text_ex(tyui_Align align, const char *fmt, ...);

#endif // TEENSY_UI_H_