21const double gf_gui_border_width = 2;
27 gf_gui_t* gui = malloc(
sizeof(*gui));
29 memset(gui, 0,
sizeof(*gui));
36 GF_SET_COLOR(gf_gui_font_color, 256 - 32, 256 - 32, 256 - 32, 255);
46 const int color_diff = 32;
49 int cd = mul * color_diff;
51 col = gf_gui_base_color;
57 col = gf_gui_base_color;
61 gf_graphic_fill_polygon(gui->
draw, col,
GF_GRAPHIC_2D, 5, x + w, y + h, x + w, y, x + w - gf_gui_border_width, y + gf_gui_border_width, x + gf_gui_border_width, y + h - gf_gui_border_width, x, y + h);
63 col = gf_gui_base_color;
64 gf_graphic_fill_rect(gui->
draw, x + gf_gui_border_width, y + gf_gui_border_width, w - gf_gui_border_width * 2, h - gf_gui_border_width * 2, col);
70 if(gui->
area[i].
type == GF_GUI_UNUSED) {
82 c->
type = GF_GUI_BUTTON;
103 double cw = c->
width;
106 case GF_GUI_BUTTON: {
109 }
else if(gui->
pressed == -1) {
120 double cw = c->
width;
123 case GF_GUI_BUTTON: {
127 x += gf_gui_border_width / 1;
128 y += gf_gui_border_width / 1;
#define GF_SET_COLOR(color, red, green, blue, alpha)
Macro to set color safely and shorter.
void gf_graphic_fill_rect(gf_draw_t *draw, double x, double y, double w, double h, gf_graphic_color_t color)
Draw filled rectangle.
void gf_graphic_fill_polygon(gf_draw_t *draw, gf_graphic_color_t color, int dim, int npair,...)
Draw polygon.
void gf_graphic_text(gf_draw_t *draw, double x, double y, double size, const char *text, gf_graphic_color_t color)
Draw text.
double gf_graphic_text_width(gf_draw_t *draw, double size, const char *text)
Calculate text width.
#define GF_GRAPHIC_2D
Dimension parameter for 2D.
#define GF_GUI_INVERT
Draw border inverted.
gf_gui_component_t * gf_gui_first_unused(gf_gui_t *gui, gf_gui_id_t *id)
Get first unused component entry.
void gf_gui_render(gf_gui_t *gui)
Render GUI.
#define GF_GUI_FONT_SIZE
Default GUI font size.
void gf_gui_draw_box(gf_gui_t *gui, int mul, double x, double y, double w, double h)
Render box.
gf_gui_t * gf_gui_create(gf_engine_t *engine, gf_draw_t *draw)
Create GUI.
gf_gui_id_t gf_gui_create_button(gf_gui_t *gui, double x, double y, double w, double h, const char *text)
Create button component.
void gf_gui_set_callback(gf_gui_t *gui, gf_gui_id_t id, gf_gui_callback_t callback)
Set callback.
#define GF_GUI_NORMAL
Draw border normally.
Required headers before anything.
int gf_gui_id_t
Component ID.
#define GF_GUI_MAX_COMPONENTS
Max components GUI can handle.
gf_input_t * input
Input interface.
int pressed
1 if pressed, otherwise 0
double y
X coord of component.
double width
Width of component.
double height
Height of component.
gf_gui_callback_t callback
Event callback.
gf_gui_union_t u
Component union.
double x
X coord of component.
gf_gui_id_t pressed
1 if something is being pressed, otherwise 0
gf_engine_t * engine
Engine instance.
gf_draw_t * draw
Drawing interface.
gf_gui_component_t area[64]
Created components.
gf_gui_button_t button
Button component.