removed a lot of bullshit
This commit is contained in:
parent
80bd0259ae
commit
dc8bba66fb
118
demo/demo.c
118
demo/demo.c
@ -4,7 +4,7 @@
|
||||
#define WINDOW_HEIGHT 600
|
||||
|
||||
struct show_window {
|
||||
struct gui_panel_hook hook;
|
||||
struct gui_panel hook;
|
||||
/* input buffer */
|
||||
gui_char input_buffer[MAX_BUFFER];
|
||||
gui_size input_length;
|
||||
@ -34,7 +34,7 @@ struct show_window {
|
||||
};
|
||||
|
||||
struct control_window {
|
||||
struct gui_panel_hook hook;
|
||||
struct gui_panel hook;
|
||||
gui_flags show_flags;
|
||||
/* tabs */
|
||||
gui_bool flag_tab;
|
||||
@ -52,16 +52,13 @@ struct control_window {
|
||||
|
||||
struct demo_gui {
|
||||
gui_bool running;
|
||||
void *memory;
|
||||
struct show_window show;
|
||||
struct control_window control;
|
||||
struct gui_memory memory;
|
||||
struct gui_command_buffer buffer;
|
||||
struct gui_layout_config conf;
|
||||
struct gui_panel_stack stack;
|
||||
struct gui_panel_layout tab;
|
||||
gui_command_buffer buffer;
|
||||
struct gui_stack stack;
|
||||
struct gui_config config;
|
||||
struct gui_font font;
|
||||
gui_size width, height;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -117,9 +114,9 @@ graph_panel(struct gui_panel_layout *panel, gui_size current)
|
||||
static const gui_float values[] = {8.0f,15.0f,20.0f,12.0f,30.0f,12.0f,35.0f,40.0f,20.0f};
|
||||
gui_panel_row(panel, 100, 1);
|
||||
if (current == COL) {
|
||||
gui_panel_graph(panel, GUI_GRAPH_COLUMN, values, LEN(values));
|
||||
gui_panel_graph(panel, GUI_GRAPH_COLUMN, values, LEN(values), 0);
|
||||
} else {
|
||||
gui_panel_graph(panel, GUI_GRAPH_LINES, values, LEN(values));
|
||||
gui_panel_graph(panel, GUI_GRAPH_LINES, values, LEN(values), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,13 +149,13 @@ table_panel(struct gui_panel_layout *panel)
|
||||
}
|
||||
|
||||
static void
|
||||
init_show(struct show_window *win, struct gui_config *config, struct gui_font *font,
|
||||
struct gui_panel_stack *stack)
|
||||
init_show(struct show_window *win, struct gui_config *config,
|
||||
gui_command_buffer *buffer, struct gui_stack *stack)
|
||||
{
|
||||
gui_panel_hook_init(&win->hook, 20, 20, 300, 550,
|
||||
gui_panel_init(&win->hook, 20, 20, 300, 550,
|
||||
GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE|
|
||||
GUI_PANEL_CLOSEABLE|GUI_PANEL_SCALEABLE|
|
||||
GUI_PANEL_MINIMIZABLE|GUI_PANEL_HIDDEN, config, font);
|
||||
GUI_PANEL_MINIMIZABLE|GUI_PANEL_HIDDEN, buffer, config);
|
||||
gui_stack_push(stack, &win->hook);
|
||||
|
||||
win->widget_tab = GUI_MINIMIZED;
|
||||
@ -169,13 +166,12 @@ init_show(struct show_window *win, struct gui_config *config, struct gui_font *f
|
||||
}
|
||||
|
||||
static void
|
||||
update_show(struct show_window *show, struct gui_panel_stack *stack,
|
||||
struct gui_input *in, struct gui_canvas *canvas)
|
||||
update_show(struct show_window *show, struct gui_stack *stack, struct gui_input *in)
|
||||
{
|
||||
struct gui_panel_layout layout;
|
||||
struct gui_panel_layout tab;
|
||||
struct gui_panel_layout layout;
|
||||
static const char *shelfs[] = {"Histogram", "Lines"};
|
||||
gui_panel_hook_begin_stacked(&layout, &show->hook, stack, "Show", canvas, in);
|
||||
gui_panel_begin_stacked(&layout, &show->hook, stack, "Show", in);
|
||||
|
||||
show->combobox_tab = gui_panel_tab_begin(&layout, &tab, "Combobox", show->combobox_tab);
|
||||
combobox_panel(&tab, show);
|
||||
@ -195,21 +191,16 @@ update_show(struct show_window *show, struct gui_panel_stack *stack,
|
||||
gui_panel_group_begin(&layout, &tab, "Table", show->table_scrollbar);
|
||||
table_panel(&tab);
|
||||
show->table_scrollbar = gui_panel_group_end(&layout, &tab);
|
||||
|
||||
gui_panel_hook_end(&layout, &show->hook);
|
||||
gui_panel_end(&layout, &show->hook);
|
||||
}
|
||||
|
||||
static void
|
||||
update_flags(struct gui_panel_layout *panel, struct control_window *control)
|
||||
{
|
||||
gui_flags i = 0x01;
|
||||
gui_size n = 0;
|
||||
gui_flags res = 0;
|
||||
const char *options[] = {
|
||||
"Hidden", "Border",
|
||||
"Minimizable", "Closeable",
|
||||
"Moveable", "Scaleable"
|
||||
};
|
||||
gui_flags i = 0x01;
|
||||
const char *options[] = {"Hidden", "Border", "Minimizable", "Closeable", "Moveable", "Scaleable"};
|
||||
gui_panel_row(panel, 30, 2);
|
||||
do {
|
||||
if (gui_panel_check(panel, options[n++], (control->show_flags & i) ? gui_true : gui_false))
|
||||
@ -226,32 +217,32 @@ style_tab(struct gui_panel_layout *panel, struct gui_config *config)
|
||||
|
||||
gui_panel_row(panel, 30, 2);
|
||||
gui_panel_label(panel, "scrollbar width:", GUI_TEXT_LEFT);
|
||||
tx = gui_panel_spinner(panel, 0, (gui_int)config->properties[GUI_PROPERTY_SCROLLBAR_WIDTH].x, 20, 1, NULL);
|
||||
tx = gui_panel_spinner(panel,0,(gui_int)config->properties[GUI_PROPERTY_SCROLLBAR_WIDTH].x, 20, 1, NULL);
|
||||
config->properties[GUI_PROPERTY_SCROLLBAR_WIDTH].x = (float)tx;
|
||||
config->properties[GUI_PROPERTY_SCROLLBAR_WIDTH].y = (float)tx;
|
||||
|
||||
gui_panel_row(panel, 30, 3);
|
||||
gui_panel_label(panel, "panel padding:", GUI_TEXT_LEFT);
|
||||
tx = gui_panel_spinner(panel, 0, (gui_int)config->properties[GUI_PROPERTY_PADDING].x, 20, 1, NULL);
|
||||
ty = gui_panel_spinner(panel, 0, (gui_int)config->properties[GUI_PROPERTY_PADDING].y, 20, 1, NULL);
|
||||
tx = gui_panel_spinner(panel,0,(gui_int)config->properties[GUI_PROPERTY_PADDING].x,20,1,NULL);
|
||||
ty = gui_panel_spinner(panel,0,(gui_int)config->properties[GUI_PROPERTY_PADDING].y,20,1,NULL);
|
||||
config->properties[GUI_PROPERTY_PADDING].x = (float)tx;
|
||||
config->properties[GUI_PROPERTY_PADDING].y = (float)ty;
|
||||
|
||||
gui_panel_label(panel, "item spacing:", GUI_TEXT_LEFT);
|
||||
tx = gui_panel_spinner(panel, 0, (gui_int)config->properties[GUI_PROPERTY_ITEM_SPACING].x, 20, 1, NULL);
|
||||
ty = gui_panel_spinner(panel, 0, (gui_int)config->properties[GUI_PROPERTY_ITEM_SPACING].y, 20, 1, NULL);
|
||||
tx = gui_panel_spinner(panel,0,(gui_int)config->properties[GUI_PROPERTY_ITEM_SPACING].x,20,1,NULL);
|
||||
ty = gui_panel_spinner(panel,0,(gui_int)config->properties[GUI_PROPERTY_ITEM_SPACING].y,20,1,NULL);
|
||||
config->properties[GUI_PROPERTY_ITEM_SPACING].x = (float)tx;
|
||||
config->properties[GUI_PROPERTY_ITEM_SPACING].y = (float)ty;
|
||||
|
||||
gui_panel_label(panel, "item padding:", GUI_TEXT_LEFT);
|
||||
tx = gui_panel_spinner(panel, 0, (gui_int)config->properties[GUI_PROPERTY_ITEM_PADDING].x, 20, 1, NULL);
|
||||
ty = gui_panel_spinner(panel, 0, (gui_int)config->properties[GUI_PROPERTY_ITEM_PADDING].y, 20, 1, NULL);
|
||||
tx = gui_panel_spinner(panel,0,(gui_int)config->properties[GUI_PROPERTY_ITEM_PADDING].x,20,1,NULL);
|
||||
ty = gui_panel_spinner(panel,0,(gui_int)config->properties[GUI_PROPERTY_ITEM_PADDING].y,20,1,NULL);
|
||||
config->properties[GUI_PROPERTY_ITEM_PADDING].x = (float)tx;
|
||||
config->properties[GUI_PROPERTY_ITEM_PADDING].y = (float)ty;
|
||||
|
||||
gui_panel_label(panel, "scaler size:", GUI_TEXT_LEFT);
|
||||
tx = gui_panel_spinner(panel, 0, (gui_int)config->properties[GUI_PROPERTY_SCALER_SIZE].x, 20, 1, NULL);
|
||||
ty = gui_panel_spinner(panel, 0, (gui_int)config->properties[GUI_PROPERTY_SCALER_SIZE].y, 20, 1, NULL);
|
||||
tx = gui_panel_spinner(panel,0,(gui_int)config->properties[GUI_PROPERTY_SCALER_SIZE].x,20,1,NULL);
|
||||
ty = gui_panel_spinner(panel,0,(gui_int)config->properties[GUI_PROPERTY_SCALER_SIZE].y,20,1,NULL);
|
||||
config->properties[GUI_PROPERTY_SCALER_SIZE].x = (float)tx;
|
||||
config->properties[GUI_PROPERTY_SCALER_SIZE].y = (float)ty;
|
||||
}
|
||||
@ -303,7 +294,7 @@ color_tab(struct gui_panel_layout *panel, struct control_window *control, struct
|
||||
if (control->picker_active) {
|
||||
control->color = color_picker(panel,control,labels[control->current_color], control->color);
|
||||
gui_panel_row(panel, 30, 3);
|
||||
gui_panel_seperator(panel, 1);
|
||||
gui_panel_spacing(panel, 1);
|
||||
if (gui_panel_button_text(panel, "ok", GUI_BUTTON_DEFAULT)) {
|
||||
config->colors[control->current_color] = control->color;
|
||||
control->picker_active = gui_false;
|
||||
@ -326,25 +317,26 @@ color_tab(struct gui_panel_layout *panel, struct control_window *control, struct
|
||||
}
|
||||
|
||||
static void
|
||||
init_control(struct control_window *win, struct gui_config *config, struct gui_font *font,
|
||||
struct gui_panel_stack *stack)
|
||||
init_control(struct control_window *win, struct gui_config *config,
|
||||
gui_command_buffer *buffer, struct gui_stack *stack)
|
||||
{
|
||||
gui_panel_hook_init(&win->hook, 380, 20, 350, 500,
|
||||
GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE|GUI_PANEL_CLOSEABLE|GUI_PANEL_SCALEABLE, config, font);
|
||||
gui_panel_init(&win->hook, 380, 20, 350, 500,
|
||||
GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE|GUI_PANEL_CLOSEABLE|GUI_PANEL_SCALEABLE,
|
||||
buffer, config);
|
||||
gui_stack_push(stack, &win->hook);
|
||||
win->show_flags = gui_hook_panel(&win->hook)->flags;
|
||||
win->show_flags = win->hook.flags;
|
||||
win->color_tab = GUI_MINIMIZED;
|
||||
}
|
||||
|
||||
static gui_bool
|
||||
update_control(struct control_window *control, struct gui_panel_stack *stack,
|
||||
struct gui_input *in, struct gui_canvas *canvas, struct gui_config *config)
|
||||
update_control(struct control_window *control, struct gui_stack *stack,
|
||||
struct gui_input *in, struct gui_config *config)
|
||||
{
|
||||
gui_bool running;
|
||||
struct gui_panel_layout layout;
|
||||
struct gui_panel_layout tab;
|
||||
|
||||
running = gui_panel_hook_begin_stacked(&layout, &control->hook, stack, "Control", canvas, in);
|
||||
running = gui_panel_begin_stacked(&layout, &control->hook, stack, "Control", in);
|
||||
control->flag_tab = gui_panel_tab_begin(&layout, &tab, "Options", control->flag_tab);
|
||||
update_flags(&tab, control);
|
||||
gui_panel_tab_end(&layout, &tab);
|
||||
@ -357,52 +349,36 @@ update_control(struct control_window *control, struct gui_panel_stack *stack,
|
||||
color_tab(&tab, control, config);
|
||||
gui_panel_tab_end(&layout, &tab);
|
||||
|
||||
gui_panel_hook_end(&layout, &control->hook);
|
||||
gui_panel_end(&layout, &control->hook);
|
||||
return running;
|
||||
}
|
||||
|
||||
static void
|
||||
init_demo(struct demo_gui *gui, struct gui_font *font)
|
||||
{
|
||||
struct gui_command_buffer *buffer = &gui->buffer;
|
||||
struct gui_memory *memory = &gui->memory;
|
||||
struct gui_config *config = &gui->config;
|
||||
|
||||
gui->font = *font;
|
||||
gui->running = gui_true;
|
||||
memory->memory = calloc(MAX_MEMORY, 1);
|
||||
memory->size = MAX_MEMORY;
|
||||
gui_buffer_init_fixed(buffer, memory, GUI_BUFFER_CLIPPING);
|
||||
gui_config_default(config);
|
||||
gui_command_buffer_init_fixed(&gui->buffer, gui->memory, MAX_MEMORY);
|
||||
gui_config_default(config, font);
|
||||
|
||||
/* floating windows */
|
||||
gui_stack_clear(&gui->stack);
|
||||
init_show(&gui->show, config, font, &gui->stack);
|
||||
init_control(&gui->control, config, font, &gui->stack);
|
||||
/*init_show(&gui->show, config, &gui->buffer, &gui->stack);*/
|
||||
init_control(&gui->control, config, &gui->buffer, &gui->stack);
|
||||
}
|
||||
|
||||
static void
|
||||
run_demo(struct demo_gui *gui, struct gui_input *input)
|
||||
{
|
||||
struct gui_command_buffer *buffer = &gui->buffer;
|
||||
struct show_window *show = &gui->show;
|
||||
struct control_window *control = &gui->control;
|
||||
struct gui_command_buffer sub;
|
||||
struct gui_canvas canvas;
|
||||
|
||||
/* control window */
|
||||
gui_buffer_begin(NULL, buffer, gui->width, gui->height);
|
||||
gui_buffer_lock(&canvas, buffer, &sub, 0, gui->width, gui->height);
|
||||
gui->running = update_control(control, &gui->stack, input, &canvas, &gui->config);
|
||||
gui_buffer_unlock(gui_hook_output(&control->hook), buffer, &sub, &canvas, NULL);
|
||||
gui->running = update_control(control, &gui->stack, input, &gui->config);
|
||||
|
||||
/* Show window */
|
||||
gui_hook_panel(&show->hook)->flags = control->show_flags;
|
||||
gui_buffer_lock(&canvas, buffer, &sub, 0, gui->width, gui->height);
|
||||
update_show(show, &gui->stack, input, &canvas);
|
||||
if (gui_hook_panel(&show->hook)->flags & GUI_PANEL_HIDDEN)
|
||||
/*
|
||||
show->hook.panel.flags = control->show_flags;
|
||||
update_show(show, &gui->stack, input);
|
||||
if (show->hook.panel.flags & GUI_PANEL_HIDDEN)
|
||||
control->show_flags |= GUI_PANEL_HIDDEN;
|
||||
gui_buffer_unlock(gui_hook_output(&show->hook), buffer, &sub, &canvas, NULL);
|
||||
gui_buffer_end(NULL, buffer, NULL, NULL);
|
||||
*/
|
||||
}
|
||||
|
||||
|
29
demo/xlib.c
29
demo/xlib.c
@ -301,36 +301,36 @@ surface_del(XSurface *surf)
|
||||
}
|
||||
|
||||
static void
|
||||
execute(XSurface *surf, struct gui_command_list *list)
|
||||
execute(XSurface *surf, gui_command_buffer *buffer)
|
||||
{
|
||||
const struct gui_command *cmd;
|
||||
gui_list_for_each(cmd, list) {
|
||||
gui_foreach_command(cmd, buffer) {
|
||||
switch (cmd->type) {
|
||||
case GUI_COMMAND_NOP: break;
|
||||
case GUI_COMMAND_SCISSOR: {
|
||||
const struct gui_command_scissor *s = GUI_FETCH(scissor, cmd);
|
||||
const struct gui_command_scissor *s = gui_command(scissor, cmd);
|
||||
surface_scissor(surf, s->x, s->y, s->w, s->h);
|
||||
} break;
|
||||
case GUI_COMMAND_LINE: {
|
||||
const struct gui_command_line *l = GUI_FETCH(line, cmd);
|
||||
const struct gui_command_line *l = gui_command(line, cmd);
|
||||
surface_draw_line(surf, l->begin[0], l->begin[1], l->end[0],
|
||||
l->end[1], l->color);
|
||||
} break;
|
||||
case GUI_COMMAND_RECT: {
|
||||
const struct gui_command_rect *r = GUI_FETCH(rect, cmd);
|
||||
const struct gui_command_rect *r = gui_command(rect, cmd);
|
||||
surface_draw_rect(surf, r->x, r->y, r->w, r->h, r->color);
|
||||
} break;
|
||||
case GUI_COMMAND_CIRCLE: {
|
||||
const struct gui_command_circle *c = GUI_FETCH(circle, cmd);
|
||||
const struct gui_command_circle *c = gui_command(circle, cmd);
|
||||
surface_draw_circle(surf, c->x, c->y, c->w, c->h, c->color);
|
||||
} break;
|
||||
case GUI_COMMAND_TRIANGLE: {
|
||||
const struct gui_command_triangle *t = GUI_FETCH(triangle, cmd);
|
||||
const struct gui_command_triangle *t = gui_command(triangle, cmd);
|
||||
surface_draw_triangle(surf, t->a[0], t->a[1], t->b[0], t->b[1],
|
||||
t->c[0], t->c[1], t->color);
|
||||
} break;
|
||||
case GUI_COMMAND_TEXT: {
|
||||
const struct gui_command_text *t = GUI_FETCH(text, cmd);
|
||||
const struct gui_command_text *t = gui_command(text, cmd);
|
||||
surface_draw_text(surf, t->x, t->y, t->w, t->h, (const char*)t->string,
|
||||
t->length, t->font, t->bg, t->fg);
|
||||
} break;
|
||||
@ -342,11 +342,11 @@ execute(XSurface *surf, struct gui_command_list *list)
|
||||
}
|
||||
|
||||
static void
|
||||
draw(XSurface *surf, struct gui_panel_stack *stack)
|
||||
draw(XSurface *surf, struct gui_stack *stack)
|
||||
{
|
||||
struct gui_panel_hook *iter;
|
||||
gui_stack_for_each(iter, stack)
|
||||
execute(surf, gui_hook_output(iter));
|
||||
struct gui_panel *iter;
|
||||
gui_foreach_panel(iter, stack)
|
||||
execute(surf, iter->buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -440,6 +440,7 @@ main(int argc, char *argv[])
|
||||
font.userdata = xw.font;
|
||||
font.height = (gui_float)xw.font->height;
|
||||
font.width = font_get_text_width;
|
||||
gui.memory = calloc(MAX_MEMORY, 1);
|
||||
init_demo(&gui, &font);
|
||||
|
||||
while (gui.running) {
|
||||
@ -459,8 +460,6 @@ main(int argc, char *argv[])
|
||||
gui_input_end(&in);
|
||||
|
||||
/* GUI */
|
||||
gui.width = xw.width;
|
||||
gui.height = xw.height;
|
||||
run_demo(&gui, &in);
|
||||
|
||||
/* Draw */
|
||||
@ -477,7 +476,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
cleanup:
|
||||
free(gui.memory.memory);
|
||||
free(gui.memory);
|
||||
font_del(xw.dpy, xw.font);
|
||||
surface_del(xw.surf);
|
||||
XUnmapWindow(xw.dpy, xw.win);
|
||||
|
750
gui.h
750
gui.h
@ -13,13 +13,11 @@ extern "C" {
|
||||
/* Constants */
|
||||
#define GUI_UTF_SIZE 4
|
||||
#define GUI_INPUT_MAX 16
|
||||
#define GUI_MAX_COLOR_STACK 8
|
||||
#define GUI_MAX_ATTRIB_STACK 8
|
||||
#define GUI_MAX_COLOR_STACK 32
|
||||
#define GUI_MAX_ATTRIB_STACK 32
|
||||
#define GUI_UTF_INVALID 0xFFFD
|
||||
#define GUI_HOOK_PANEL_NAME panel
|
||||
#define GUI_HOOK_OUTPUT_NAME list
|
||||
#define GUI_HOOK_ATTR(T, name) struct T name
|
||||
#define GUI_HOOK_OUTPUT gui_command_list
|
||||
#define GUI_PTR_ADD(t, p, i) ((t*)((void*)((gui_size)(p) + (i))))
|
||||
#define GUI_PTR_SUB(t, p, i) ((t*)((void*)((gui_size)(p) - (i))))
|
||||
|
||||
/* Types */
|
||||
#ifdef GUI_USE_FIXED_TYPES
|
||||
@ -66,19 +64,15 @@ struct gui_font;
|
||||
typedef void* gui_image;
|
||||
typedef gui_char gui_glyph[GUI_UTF_SIZE];
|
||||
typedef gui_bool(*gui_filter)(gui_long unicode);
|
||||
typedef gui_size(*gui_text_width_f)(void*,const gui_char*, gui_size);
|
||||
typedef void(*gui_scissor)(void*, gui_float, gui_float, gui_float, gui_float);
|
||||
typedef void(*gui_draw_line)(void*, gui_float, gui_float, gui_float, gui_float, struct gui_color);
|
||||
typedef void(*gui_draw_rect)(void*, gui_float, gui_float, gui_float, gui_float, struct gui_color);
|
||||
typedef void(*gui_draw_image)(void*, gui_float, gui_float, gui_float, gui_float, gui_image);
|
||||
typedef void(*gui_draw_circle)(void*, gui_float, gui_float, gui_float, gui_float, struct gui_color);
|
||||
typedef void(*gui_draw_triangle)(void*, gui_float, gui_float, gui_float, gui_float,
|
||||
gui_float, gui_float, struct gui_color);
|
||||
typedef void(*gui_draw_text)(void*, gui_float, gui_float, gui_float, gui_float,
|
||||
const gui_char*, gui_size, const struct gui_font*,
|
||||
struct gui_color, struct gui_color);
|
||||
typedef gui_size(*gui_text_width_f)(void*, const gui_char*, gui_size);
|
||||
|
||||
/* Input */
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
* Input
|
||||
*
|
||||
* ===============================================================
|
||||
*/
|
||||
enum gui_keys {
|
||||
GUI_KEY_SHIFT,
|
||||
GUI_KEY_CTRL,
|
||||
@ -102,8 +96,195 @@ struct gui_input {
|
||||
struct gui_vec2 mouse_clicked_pos;
|
||||
};
|
||||
|
||||
/* UTF8 */
|
||||
gui_size gui_utf_decode(const gui_char*, gui_long*, gui_size);
|
||||
gui_size gui_utf_encode(gui_long, gui_char*, gui_size);
|
||||
|
||||
/* Input */
|
||||
void gui_input_begin(struct gui_input*);
|
||||
void gui_input_motion(struct gui_input*, gui_int x, gui_int y);
|
||||
void gui_input_key(struct gui_input*, enum gui_keys, gui_bool down);
|
||||
void gui_input_button(struct gui_input*, gui_int x, gui_int y, gui_bool down);
|
||||
void gui_input_char(struct gui_input*, const gui_glyph);
|
||||
void gui_input_end(struct gui_input*);
|
||||
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
* Buffer
|
||||
*
|
||||
* ===============================================================
|
||||
*/
|
||||
struct gui_memory_status {
|
||||
void *memory;
|
||||
gui_uint type;
|
||||
gui_size size;
|
||||
gui_size allocated;
|
||||
gui_size needed;
|
||||
gui_size calls;
|
||||
};
|
||||
|
||||
struct gui_allocator {
|
||||
void *userdata;
|
||||
void*(*alloc)(void *usr, gui_size);
|
||||
void*(*realloc)(void *usr, void*, gui_size);
|
||||
void(*free)(void *usr, void*);
|
||||
};
|
||||
|
||||
struct gui_memory {
|
||||
void *ptr;
|
||||
gui_size size;
|
||||
};
|
||||
|
||||
enum gui_buffer_type {
|
||||
GUI_BUFFER_FIXED,
|
||||
GUI_BUFFER_DYNAMIC
|
||||
};
|
||||
|
||||
struct gui_buffer {
|
||||
struct gui_allocator pool;
|
||||
enum gui_buffer_type type;
|
||||
struct gui_memory memory;
|
||||
gui_float grow_factor;
|
||||
gui_size allocated;
|
||||
gui_size needed;
|
||||
gui_size calls;
|
||||
};
|
||||
|
||||
|
||||
/* General purpose buffer */
|
||||
void gui_buffer_init(struct gui_buffer*, const struct gui_allocator*,
|
||||
gui_size initial_size, gui_float grow_factor);
|
||||
void gui_buffer_init_fixed(struct gui_buffer*, void *memory, gui_size size);
|
||||
void gui_buffer_info(struct gui_memory_status*, struct gui_buffer*);
|
||||
void* gui_buffer_alloc(struct gui_buffer*, gui_size size, gui_size align);
|
||||
void gui_buffer_reset(struct gui_buffer*);
|
||||
void gui_buffer_clear(struct gui_buffer*);
|
||||
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
* Commands
|
||||
*
|
||||
* ===============================================================
|
||||
*/
|
||||
enum gui_command_type {
|
||||
GUI_COMMAND_NOP,
|
||||
GUI_COMMAND_SCISSOR,
|
||||
GUI_COMMAND_LINE,
|
||||
GUI_COMMAND_RECT,
|
||||
GUI_COMMAND_CIRCLE,
|
||||
GUI_COMMAND_TRIANGLE,
|
||||
GUI_COMMAND_TEXT,
|
||||
GUI_COMMAND_IMAGE,
|
||||
GUI_COMMAND_MAX
|
||||
};
|
||||
|
||||
struct gui_command {
|
||||
enum gui_command_type type;
|
||||
gui_size offset;
|
||||
};
|
||||
|
||||
struct gui_command_scissor {
|
||||
struct gui_command header;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
};
|
||||
|
||||
struct gui_command_line {
|
||||
struct gui_command header;
|
||||
gui_short begin[2];
|
||||
gui_short end[2];
|
||||
struct gui_color color;
|
||||
};
|
||||
|
||||
struct gui_command_rect {
|
||||
struct gui_command header;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
struct gui_color color;
|
||||
};
|
||||
|
||||
struct gui_command_circle {
|
||||
struct gui_command header;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
struct gui_color color;
|
||||
};
|
||||
|
||||
struct gui_command_image {
|
||||
struct gui_command header;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
gui_image img;
|
||||
};
|
||||
|
||||
struct gui_command_triangle {
|
||||
struct gui_command header;
|
||||
gui_short a[2];
|
||||
gui_short b[2];
|
||||
gui_short c[2];
|
||||
struct gui_color color;
|
||||
};
|
||||
|
||||
struct gui_command_text {
|
||||
struct gui_command header;
|
||||
void *font;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
struct gui_color bg;
|
||||
struct gui_color fg;
|
||||
gui_size length;
|
||||
gui_char string[1];
|
||||
};
|
||||
|
||||
typedef struct gui_buffer gui_command_buffer;
|
||||
#define gui_command_buffer_init(b, a, i, g) gui_buffer_init(b, a, i, g);
|
||||
#define gui_command_buffer_init_fixed(b, m, s) gui_buffer_init_fixed(b, m ,s)
|
||||
#define gui_command_buffer_reset(b) gui_buffer_reset(b)
|
||||
#define gui_command_buffer_clear(b) gui_buffer_clear(b)
|
||||
void *gui_command_buffer_push(gui_command_buffer*, gui_uint type, gui_size size);
|
||||
void gui_command_buffer_push_scissor(gui_command_buffer*, gui_float,
|
||||
gui_float, gui_float, gui_float);
|
||||
void gui_command_buffer_push_line(gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float, struct gui_color);
|
||||
void gui_command_buffer_push_rect(gui_command_buffer *buffer, gui_float x,
|
||||
gui_float y, gui_float w, gui_float h, struct gui_color c);
|
||||
void gui_command_buffer_push_circle(gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float, struct gui_color);
|
||||
void gui_command_buffer_push_triangle(gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float, gui_float, gui_float, struct gui_color);
|
||||
void gui_command_buffer_push_image(gui_command_buffer*, gui_float,
|
||||
gui_float, gui_float, gui_float, gui_image);
|
||||
void gui_command_buffer_push_text(gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float, const gui_char*, gui_size,
|
||||
const struct gui_font*, struct gui_color, struct gui_color);
|
||||
|
||||
|
||||
#define gui_command(t, c) ((const struct gui_command_##t*)c)
|
||||
#define gui_command_buffer_begin(b)\
|
||||
((const struct gui_command*)(b)->memory.ptr)
|
||||
#define gui_command_buffer_end(b)\
|
||||
(GUI_PTR_ADD(const struct gui_command, (b)->memory.ptr, (b)->allocated))
|
||||
#define gui_command_buffer_next(b, c)\
|
||||
((GUI_PTR_ADD(const struct gui_command, c, c->offset) < gui_command_buffer_end(b)) ?\
|
||||
GUI_PTR_ADD(const struct gui_command, c, c->offset) : NULL)
|
||||
#define gui_foreach_command(i, b)\
|
||||
for((i) = gui_command_buffer_begin(b); (i) != NULL; (i) = gui_command_buffer_next(b,i))
|
||||
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
* Widgets
|
||||
*
|
||||
* ===============================================================
|
||||
*/
|
||||
struct gui_font {
|
||||
void *userdata;
|
||||
gui_float height;
|
||||
gui_text_width_f width;
|
||||
};
|
||||
|
||||
/* Widgets */
|
||||
enum gui_text_align {
|
||||
GUI_TEXT_LEFT,
|
||||
GUI_TEXT_CENTERED,
|
||||
@ -200,158 +381,47 @@ struct gui_graph {
|
||||
gui_size count;
|
||||
};
|
||||
|
||||
enum gui_table_lines {
|
||||
GUI_TABLE_HHEADER = 0x01,
|
||||
GUI_TABLE_VHEADER = 0x02,
|
||||
GUI_TABLE_HBODY = 0x04,
|
||||
GUI_TABLE_VBODY = 0x08
|
||||
};
|
||||
void gui_text(gui_command_buffer*, gui_float x, gui_float y, gui_float w, gui_float h,
|
||||
const char *text, gui_size len, const struct gui_text*, enum gui_text_align,
|
||||
const struct gui_font*);
|
||||
gui_bool gui_button_text(gui_command_buffer*, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, const char*, enum gui_button_behavior,
|
||||
const struct gui_button*, const struct gui_input*, const struct gui_font*);
|
||||
gui_bool gui_button_image(gui_command_buffer*, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, gui_image, enum gui_button_behavior,
|
||||
const struct gui_button*, const struct gui_input*);
|
||||
gui_bool gui_button_triangle(gui_command_buffer*, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, enum gui_heading, enum gui_button_behavior,
|
||||
const struct gui_button*, const struct gui_input*);
|
||||
gui_bool gui_toggle(gui_command_buffer*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_bool, const char*, enum gui_toggle_type,
|
||||
const struct gui_toggle*, const struct gui_input*, const struct gui_font*);
|
||||
gui_float gui_slider(gui_command_buffer*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_float min, gui_float val, gui_float max, gui_float step,
|
||||
const struct gui_slider*, const struct gui_input*);
|
||||
gui_size gui_progress(gui_command_buffer*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_size value, gui_size max, gui_bool modifyable,
|
||||
const struct gui_progress*, const struct gui_input*);
|
||||
gui_size gui_edit(gui_command_buffer*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_char*, gui_size, gui_size max, gui_bool*,
|
||||
const struct gui_edit*, enum gui_input_filter filter,
|
||||
const struct gui_input*, const struct gui_font*);
|
||||
gui_size gui_edit_filtered(gui_command_buffer*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_char*, gui_size, gui_size max, gui_bool*,
|
||||
const struct gui_edit*, gui_filter filter, const struct gui_input*,
|
||||
const struct gui_font*);
|
||||
gui_float gui_scroll(gui_command_buffer*, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, gui_float offset, gui_float target,
|
||||
gui_float step, const struct gui_scroll*, const struct gui_input*);
|
||||
|
||||
struct gui_font {
|
||||
void *userdata;
|
||||
gui_float height;
|
||||
gui_text_width_f width;
|
||||
};
|
||||
|
||||
struct gui_canvas {
|
||||
void *userdata;
|
||||
gui_size width;
|
||||
gui_size height;
|
||||
gui_scissor scissor;
|
||||
gui_draw_line draw_line;
|
||||
gui_draw_rect draw_rect;
|
||||
gui_draw_circle draw_circle;
|
||||
gui_draw_triangle draw_triangle;
|
||||
gui_draw_image draw_image;
|
||||
gui_draw_text draw_text;
|
||||
};
|
||||
|
||||
|
||||
/* Buffer */
|
||||
struct gui_memory {
|
||||
void *memory;
|
||||
gui_size size;
|
||||
};
|
||||
|
||||
struct gui_memory_status {
|
||||
gui_size size;
|
||||
gui_size allocated;
|
||||
gui_size needed;
|
||||
gui_size clipped_commands;
|
||||
gui_size clipped_memory;
|
||||
};
|
||||
|
||||
struct gui_allocator {
|
||||
void *userdata;
|
||||
void*(*alloc)(void *usr, gui_size);
|
||||
void*(*realloc)(void *usr, void*, gui_size);
|
||||
void(*free)(void *usr, void*);
|
||||
};
|
||||
|
||||
enum gui_command_type {
|
||||
GUI_COMMAND_NOP,
|
||||
GUI_COMMAND_SCISSOR,
|
||||
GUI_COMMAND_LINE,
|
||||
GUI_COMMAND_RECT,
|
||||
GUI_COMMAND_CIRCLE,
|
||||
GUI_COMMAND_TRIANGLE,
|
||||
GUI_COMMAND_TEXT,
|
||||
GUI_COMMAND_IMAGE,
|
||||
GUI_COMMAND_MAX
|
||||
};
|
||||
|
||||
struct gui_command {
|
||||
enum gui_command_type type;
|
||||
gui_size offset;
|
||||
};
|
||||
|
||||
struct gui_command_scissor {
|
||||
struct gui_command header;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
};
|
||||
|
||||
struct gui_command_line {
|
||||
struct gui_command header;
|
||||
gui_short begin[2];
|
||||
gui_short end[2];
|
||||
struct gui_color color;
|
||||
};
|
||||
|
||||
struct gui_command_rect {
|
||||
struct gui_command header;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
struct gui_color color;
|
||||
};
|
||||
|
||||
struct gui_command_circle {
|
||||
struct gui_command header;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
struct gui_color color;
|
||||
};
|
||||
|
||||
struct gui_command_image {
|
||||
struct gui_command header;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
gui_image img;
|
||||
};
|
||||
|
||||
struct gui_command_triangle {
|
||||
struct gui_command header;
|
||||
gui_short a[2];
|
||||
gui_short b[2];
|
||||
gui_short c[2];
|
||||
struct gui_color color;
|
||||
};
|
||||
|
||||
struct gui_command_text {
|
||||
struct gui_command header;
|
||||
void *font;
|
||||
gui_short x, y;
|
||||
gui_ushort w, h;
|
||||
struct gui_color bg;
|
||||
struct gui_color fg;
|
||||
gui_size length;
|
||||
gui_char string[1];
|
||||
};
|
||||
|
||||
enum gui_buffer_flags {
|
||||
GUI_BUFFER_DEFAULT = 0,
|
||||
GUI_BUFFER_CLIPPING = 0x01,
|
||||
GUI_BUFFER_OWNER = 0x02,
|
||||
GUI_BUFFER_LOCKED = 0x04
|
||||
};
|
||||
|
||||
struct gui_command_buffer {
|
||||
void *memory;
|
||||
gui_flags flags;
|
||||
struct gui_allocator allocator;
|
||||
struct gui_command *begin;
|
||||
struct gui_command *end;
|
||||
struct gui_rect clip;
|
||||
gui_size clipped_cmds;
|
||||
gui_size clipped_memory;
|
||||
gui_float grow_factor;
|
||||
gui_size sub_size;
|
||||
gui_size sub_cap;
|
||||
gui_size allocated;
|
||||
gui_size capacity;
|
||||
gui_size needed;
|
||||
gui_size count;
|
||||
};
|
||||
|
||||
struct gui_command_list {
|
||||
struct gui_command_list *next;
|
||||
struct gui_command *begin;
|
||||
struct gui_command *end;
|
||||
gui_size count;
|
||||
};
|
||||
|
||||
/* Configuration */
|
||||
enum gui_panel_colors {
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
* Config
|
||||
*
|
||||
* ===============================================================
|
||||
*/
|
||||
enum gui_config_colors {
|
||||
GUI_COLOR_TEXT,
|
||||
GUI_COLOR_PANEL,
|
||||
GUI_COLOR_HEADER,
|
||||
@ -401,7 +471,7 @@ enum gui_panel_colors {
|
||||
GUI_COLOR_COUNT
|
||||
};
|
||||
|
||||
enum gui_panel_properties {
|
||||
enum gui_config_properties {
|
||||
GUI_PROPERTY_ITEM_SPACING,
|
||||
GUI_PROPERTY_ITEM_PADDING,
|
||||
GUI_PROPERTY_PADDING,
|
||||
@ -412,26 +482,50 @@ enum gui_panel_properties {
|
||||
};
|
||||
|
||||
struct gui_saved_property {
|
||||
enum gui_panel_properties type;
|
||||
enum gui_config_properties type;
|
||||
struct gui_vec2 value;
|
||||
};
|
||||
|
||||
struct gui_saved_color {
|
||||
enum gui_panel_colors type;
|
||||
enum gui_config_colors type;
|
||||
struct gui_color value;
|
||||
};
|
||||
|
||||
struct gui_config {
|
||||
struct gui_font font;
|
||||
struct gui_vec2 properties[GUI_PROPERTY_MAX];
|
||||
struct gui_color colors[GUI_COLOR_COUNT];
|
||||
/* internal */
|
||||
struct gui_saved_property property_stack[GUI_MAX_ATTRIB_STACK];
|
||||
struct gui_saved_color color_stack[GUI_MAX_COLOR_STACK];
|
||||
gui_size color, property;
|
||||
};
|
||||
|
||||
void gui_config_default(struct gui_config*, const struct gui_font*);
|
||||
struct gui_vec2 gui_config_property(const struct gui_config*, enum gui_config_properties);
|
||||
struct gui_color gui_config_color(const struct gui_config*, enum gui_config_colors);
|
||||
void gui_config_push_property(struct gui_config*, enum gui_config_properties, gui_float, gui_float);
|
||||
void gui_config_push_color(struct gui_config*, enum gui_config_colors,
|
||||
gui_byte, gui_byte, gui_byte, gui_byte);
|
||||
void gui_config_pop_color(struct gui_config*);
|
||||
void gui_config_pop_property(struct gui_config*);
|
||||
void gui_config_reset_colors(struct gui_config*);
|
||||
void gui_config_reset_properties(struct gui_config*);
|
||||
void gui_config_reset(struct gui_config*);
|
||||
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
* Panel
|
||||
*
|
||||
* ===============================================================
|
||||
*/
|
||||
enum gui_table_lines {
|
||||
GUI_TABLE_HHEADER = 0x01,
|
||||
GUI_TABLE_VHEADER = 0x02,
|
||||
GUI_TABLE_HBODY = 0x04,
|
||||
GUI_TABLE_VBODY = 0x08
|
||||
};
|
||||
|
||||
/* Panel */
|
||||
enum gui_panel_tab {
|
||||
GUI_MAXIMIZED = gui_false,
|
||||
GUI_MINIMIZED = gui_true
|
||||
@ -452,14 +546,18 @@ enum gui_panel_flags {
|
||||
GUI_PANEL_TAB = 0x400
|
||||
};
|
||||
|
||||
struct gui_layout;
|
||||
struct gui_stack;
|
||||
struct gui_panel {
|
||||
gui_float x, y;
|
||||
gui_float w, h;
|
||||
gui_flags flags;
|
||||
gui_float offset;
|
||||
gui_bool minimized;
|
||||
struct gui_font font;
|
||||
const struct gui_config *config;
|
||||
gui_command_buffer *buffer;
|
||||
struct gui_panel* next;
|
||||
struct gui_panel* prev;
|
||||
};
|
||||
|
||||
struct gui_panel_layout {
|
||||
@ -476,27 +574,105 @@ struct gui_panel_layout {
|
||||
gui_float row_height;
|
||||
gui_size row_columns;
|
||||
struct gui_rect clip;
|
||||
struct gui_font font;
|
||||
const struct gui_config *config;
|
||||
const struct gui_input *input;
|
||||
const struct gui_canvas *canvas;
|
||||
gui_command_buffer *buffer;
|
||||
};
|
||||
|
||||
struct gui_panel_hook {
|
||||
GUI_HOOK_ATTR(gui_panel, GUI_HOOK_PANEL_NAME);
|
||||
GUI_HOOK_ATTR(GUI_HOOK_OUTPUT, GUI_HOOK_OUTPUT_NAME);
|
||||
struct gui_panel_hook *next;
|
||||
struct gui_panel_hook *prev;
|
||||
};
|
||||
/* Panel */
|
||||
void gui_panel_init(struct gui_panel*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_flags, gui_command_buffer*, const struct gui_config*);
|
||||
gui_bool gui_panel_begin(struct gui_panel_layout *layout, struct gui_panel*,
|
||||
const char *title, const struct gui_input*);
|
||||
gui_bool gui_panel_begin_stacked(struct gui_panel_layout*, struct gui_panel*,
|
||||
struct gui_stack*, const char*, const struct gui_input*);
|
||||
gui_bool gui_panel_begin_tiled(struct gui_panel_layout*, struct gui_panel*,
|
||||
struct gui_layout*, gui_uint slot, gui_size index,
|
||||
const char*, const struct gui_input*);
|
||||
gui_size gui_panel_row_columns(const struct gui_panel_layout *layout, gui_size widget_size);
|
||||
void gui_panel_row(struct gui_panel_layout*, gui_float height, gui_size cols);
|
||||
gui_bool gui_panel_widget(struct gui_rect*, struct gui_panel_layout*);
|
||||
void gui_panel_spacing(struct gui_panel_layout*, gui_size cols);
|
||||
void gui_panel_text(struct gui_panel_layout*, const char*, gui_size, enum gui_text_align);
|
||||
void gui_panel_text_colored(struct gui_panel_layout*, const char*, gui_size, enum gui_text_align,
|
||||
struct gui_color color);
|
||||
void gui_panel_label(struct gui_panel_layout*, const char*, enum gui_text_align);
|
||||
void gui_panel_label_colored(struct gui_panel_layout*, const char*, enum gui_text_align,
|
||||
struct gui_color color);
|
||||
gui_bool gui_panel_check(struct gui_panel_layout*, const char*, gui_bool active);
|
||||
gui_bool gui_panel_option(struct gui_panel_layout*, const char*, gui_bool active);
|
||||
gui_size gui_panel_option_group(struct gui_panel_layout*, const char**, gui_size cnt, gui_size cur);
|
||||
gui_bool gui_panel_button_text(struct gui_panel_layout*, const char*, enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_color(struct gui_panel_layout*, const struct gui_color,
|
||||
enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_triangle(struct gui_panel_layout*, enum gui_heading,
|
||||
enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_image(struct gui_panel_layout*, gui_image image,
|
||||
enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_toggle(struct gui_panel_layout*, const char*, gui_bool value);
|
||||
gui_float gui_panel_slider(struct gui_panel_layout*, gui_float min, gui_float val,
|
||||
gui_float max, gui_float step);
|
||||
gui_size gui_panel_progress(struct gui_panel_layout*, gui_size cur, gui_size max,
|
||||
gui_bool modifyable);
|
||||
gui_size gui_panel_edit(struct gui_panel_layout*, gui_char *buffer, gui_size len,
|
||||
gui_size max, gui_bool *active, enum gui_input_filter);
|
||||
gui_size gui_panel_edit_filtered(struct gui_panel_layout*, gui_char *buffer, gui_size len,
|
||||
gui_size max, gui_bool *active, gui_filter);
|
||||
gui_bool gui_panel_shell(struct gui_panel_layout*, gui_char *buffer, gui_size *len,
|
||||
gui_size max, gui_bool *active);
|
||||
gui_int gui_panel_spinner(struct gui_panel_layout*, gui_int min, gui_int value,
|
||||
gui_int max, gui_int step, gui_bool *active);
|
||||
gui_size gui_panel_selector(struct gui_panel_layout*, const char *items[],
|
||||
gui_size item_count, gui_size item_current);
|
||||
void gui_panel_graph_begin(struct gui_panel_layout*, struct gui_graph*, enum gui_graph_type,
|
||||
gui_size count, gui_float min_value, gui_float max_value);
|
||||
gui_bool gui_panel_graph_push(struct gui_panel_layout *layout, struct gui_graph*, gui_float);
|
||||
void gui_panel_graph_end(struct gui_panel_layout *layout, struct gui_graph*);
|
||||
gui_int gui_panel_graph(struct gui_panel_layout*, enum gui_graph_type,
|
||||
const gui_float *values, gui_size count, gui_size offset);
|
||||
gui_int gui_panel_graph_ex(struct gui_panel_layout*, enum gui_graph_type, gui_size count,
|
||||
gui_float(*get_value)(void*, gui_size), void *userdata);
|
||||
void gui_panel_table_begin(struct gui_panel_layout*, gui_flags flags,
|
||||
gui_size row_height, gui_size cols);
|
||||
void gui_panel_table_row(struct gui_panel_layout*);
|
||||
void gui_panel_table_end(struct gui_panel_layout*);
|
||||
gui_bool gui_panel_tab_begin(struct gui_panel_layout*, struct gui_panel_layout *tab,
|
||||
const char*, gui_bool);
|
||||
void gui_panel_tab_end(struct gui_panel_layout*, struct gui_panel_layout *tab);
|
||||
void gui_panel_group_begin(struct gui_panel_layout*, struct gui_panel_layout *tab,
|
||||
const char*,gui_float offset);
|
||||
gui_float gui_panel_group_end(struct gui_panel_layout*, struct gui_panel_layout* tab);
|
||||
gui_size gui_panel_shelf_begin(struct gui_panel_layout*, struct gui_panel_layout *shelf,
|
||||
const char *tabs[], gui_size size, gui_size active, gui_float offset);
|
||||
gui_float gui_panel_shelf_end(struct gui_panel_layout*, struct gui_panel_layout *shelf);
|
||||
void gui_panel_end(struct gui_panel_layout*, struct gui_panel*);
|
||||
|
||||
struct gui_panel_stack {
|
||||
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
* Stack
|
||||
*
|
||||
* ===============================================================
|
||||
*/
|
||||
struct gui_stack {
|
||||
gui_size count;
|
||||
struct gui_panel_hook *begin;
|
||||
struct gui_panel_hook *end;
|
||||
struct gui_panel *begin;
|
||||
struct gui_panel *end;
|
||||
};
|
||||
|
||||
void gui_stack_clear(struct gui_stack*);
|
||||
void gui_stack_push(struct gui_stack*, struct gui_panel*);
|
||||
void gui_stack_pop(struct gui_stack*, struct gui_panel*);
|
||||
#define gui_foreach_panel(i, s) for (i = (s)->begin; i != NULL; i = (i)->next)
|
||||
|
||||
/* Layout */
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
* Border Layout
|
||||
*
|
||||
* ===============================================================
|
||||
*/
|
||||
enum gui_layout_state {
|
||||
GUI_LAYOUT_INACTIVE,
|
||||
GUI_LAYOUT_ACTIVE
|
||||
@ -536,206 +712,12 @@ struct gui_layout {
|
||||
gui_flags flags;
|
||||
gui_size width, height;
|
||||
enum gui_layout_state state;
|
||||
struct gui_panel_stack stack;
|
||||
struct gui_stack stack;
|
||||
struct gui_layout_slot slots[GUI_SLOT_MAX];
|
||||
};
|
||||
|
||||
|
||||
/* Input */
|
||||
gui_size gui_utf_decode(const gui_char*, gui_long*, gui_size);
|
||||
gui_size gui_utf_encode(gui_long, gui_char*, gui_size);
|
||||
void gui_input_begin(struct gui_input*);
|
||||
void gui_input_motion(struct gui_input*, gui_int x, gui_int y);
|
||||
void gui_input_key(struct gui_input*, enum gui_keys, gui_bool down);
|
||||
void gui_input_button(struct gui_input*, gui_int x, gui_int y, gui_bool down);
|
||||
void gui_input_char(struct gui_input*, const gui_glyph);
|
||||
void gui_input_end(struct gui_input*);
|
||||
|
||||
|
||||
/* Buffer */
|
||||
void gui_buffer_init(struct gui_command_buffer*, const struct gui_allocator*,
|
||||
gui_size initial_size, gui_float grow_factor, gui_flag clipping);
|
||||
void gui_buffer_init_fixed(struct gui_command_buffer*, const struct gui_memory*,
|
||||
gui_flag clipping);
|
||||
void gui_buffer_begin(struct gui_canvas *canvas, struct gui_command_buffer *buffer,
|
||||
gui_size width, gui_size height);
|
||||
void gui_buffer_lock(struct gui_canvas*, struct gui_command_buffer *buffer,
|
||||
struct gui_command_buffer *sub, gui_flag clipping,
|
||||
gui_size width, gui_size height);
|
||||
void gui_buffer_unlock(struct gui_command_list*, struct gui_command_buffer *buf,
|
||||
struct gui_command_buffer *sub, struct gui_canvas*,
|
||||
struct gui_memory_status*);
|
||||
void *gui_buffer_push(struct gui_command_buffer*,
|
||||
enum gui_command_type, gui_size size);
|
||||
void gui_buffer_push_scissor(struct gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float);
|
||||
void gui_buffer_push_line(struct gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float, struct gui_color);
|
||||
void gui_buffer_push_rect(struct gui_command_buffer *buffer, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, struct gui_color c);
|
||||
void gui_buffer_push_circle(struct gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float, struct gui_color);
|
||||
void gui_buffer_push_triangle(struct gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float, gui_float, gui_float, struct gui_color);
|
||||
void gui_buffer_push_image(struct gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float, gui_image);
|
||||
void gui_buffer_push_text(struct gui_command_buffer*, gui_float, gui_float,
|
||||
gui_float, gui_float, const gui_char*, gui_size,
|
||||
const struct gui_font*, struct gui_color, struct gui_color);
|
||||
void gui_buffer_clear(struct gui_command_buffer*);
|
||||
void gui_buffer_end(struct gui_command_list*, struct gui_command_buffer*,
|
||||
struct gui_canvas*, struct gui_memory_status*);
|
||||
|
||||
|
||||
/* List */
|
||||
#define GUI_FETCH(t,c) (const struct gui_command_##t*)c
|
||||
#define gui_list_for_each(i, l) for (i = gui_list_begin(l); i != NULL; i = gui_list_next(l, i))
|
||||
const struct gui_command* gui_list_begin(const struct gui_command_list*);
|
||||
const struct gui_command* gui_list_next(const struct gui_command_list*,
|
||||
const struct gui_command*);
|
||||
|
||||
|
||||
/* Widgets */
|
||||
void gui_text(const struct gui_canvas*, gui_float x, gui_float y, gui_float w, gui_float h,
|
||||
const char *text, gui_size len, const struct gui_text*, enum gui_text_align,
|
||||
const struct gui_font*);
|
||||
gui_bool gui_button_text(const struct gui_canvas*, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, const char*, enum gui_button_behavior,
|
||||
const struct gui_button*, const struct gui_input*, const struct gui_font*);
|
||||
gui_bool gui_button_image(const struct gui_canvas*, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, gui_image, enum gui_button_behavior,
|
||||
const struct gui_button*, const struct gui_input*);
|
||||
gui_bool gui_button_triangle(const struct gui_canvas*, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, enum gui_heading, enum gui_button_behavior,
|
||||
const struct gui_button*, const struct gui_input*);
|
||||
gui_bool gui_toggle(const struct gui_canvas*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_bool, const char*, enum gui_toggle_type,
|
||||
const struct gui_toggle*, const struct gui_input*, const struct gui_font*);
|
||||
gui_float gui_slider(const struct gui_canvas*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_float min, gui_float val, gui_float max, gui_float step,
|
||||
const struct gui_slider*, const struct gui_input*);
|
||||
gui_size gui_progress(const struct gui_canvas*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_size value, gui_size max, gui_bool modifyable,
|
||||
const struct gui_progress*, const struct gui_input*);
|
||||
gui_size gui_edit(const struct gui_canvas*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_char*, gui_size, gui_size max, gui_bool*,
|
||||
const struct gui_edit*, enum gui_input_filter filter,
|
||||
const struct gui_input*, const struct gui_font*);
|
||||
gui_size gui_edit_filtered(const struct gui_canvas*, gui_float x, gui_float y, gui_float w,
|
||||
gui_float h, gui_char*, gui_size, gui_size max, gui_bool*,
|
||||
const struct gui_edit*, gui_filter filter, const struct gui_input*,
|
||||
const struct gui_font*);
|
||||
gui_float gui_scroll(const struct gui_canvas*, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, gui_float offset, gui_float target,
|
||||
gui_float step, const struct gui_scroll*, const struct gui_input*);
|
||||
|
||||
|
||||
/* Config */
|
||||
void gui_config_default(struct gui_config*);
|
||||
struct gui_vec2 gui_config_property(const struct gui_config*, enum gui_panel_properties);
|
||||
struct gui_color gui_config_color(const struct gui_config*, enum gui_panel_colors);
|
||||
void gui_config_push_property(struct gui_config*, enum gui_panel_properties, gui_float, gui_float);
|
||||
void gui_config_push_color(struct gui_config*, enum gui_panel_colors,
|
||||
gui_byte, gui_byte, gui_byte, gui_byte);
|
||||
void gui_config_pop_color(struct gui_config*);
|
||||
void gui_config_pop_property(struct gui_config*);
|
||||
void gui_config_reset_colors(struct gui_config*);
|
||||
void gui_config_reset_properties(struct gui_config*);
|
||||
void gui_config_reset(struct gui_config*);
|
||||
|
||||
|
||||
/* Panel */
|
||||
void gui_panel_init(struct gui_panel*, gui_float x, gui_float y, gui_float w, gui_float h,
|
||||
gui_flags, const struct gui_config *config, const struct gui_font*);
|
||||
gui_bool gui_panel_begin(struct gui_panel_layout *layout, struct gui_panel*,
|
||||
const char *title, const struct gui_canvas*, const struct gui_input*);
|
||||
gui_size gui_panel_row_columns(const struct gui_panel_layout *layout, gui_size widget_size);
|
||||
void gui_panel_row(struct gui_panel_layout*, gui_float height, gui_size cols);
|
||||
gui_bool gui_panel_widget(struct gui_rect*, struct gui_panel_layout*);
|
||||
void gui_panel_seperator(struct gui_panel_layout*, gui_size cols);
|
||||
void gui_panel_text(struct gui_panel_layout*, const char*, gui_size, enum gui_text_align);
|
||||
void gui_panel_text_colored(struct gui_panel_layout*, const char*, gui_size, enum gui_text_align,
|
||||
struct gui_color color);
|
||||
void gui_panel_label(struct gui_panel_layout*, const char*, enum gui_text_align);
|
||||
void gui_panel_label_colored(struct gui_panel_layout*, const char*, enum gui_text_align,
|
||||
struct gui_color color);
|
||||
gui_bool gui_panel_check(struct gui_panel_layout*, const char*, gui_bool active);
|
||||
gui_bool gui_panel_option(struct gui_panel_layout*, const char*, gui_bool active);
|
||||
gui_size gui_panel_option_group(struct gui_panel_layout*, const char**, gui_size cnt, gui_size cur);
|
||||
gui_bool gui_panel_button_text(struct gui_panel_layout*, const char*, enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_color(struct gui_panel_layout*, const struct gui_color,
|
||||
enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_triangle(struct gui_panel_layout*, enum gui_heading,
|
||||
enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_image(struct gui_panel_layout*, gui_image image,
|
||||
enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_toggle(struct gui_panel_layout*, const char*, gui_bool value);
|
||||
gui_float gui_panel_slider(struct gui_panel_layout*, gui_float min, gui_float val,
|
||||
gui_float max, gui_float step);
|
||||
gui_size gui_panel_progress(struct gui_panel_layout*, gui_size cur, gui_size max,
|
||||
gui_bool modifyable);
|
||||
gui_size gui_panel_edit(struct gui_panel_layout*, gui_char *buffer, gui_size len,
|
||||
gui_size max, gui_bool *active, enum gui_input_filter);
|
||||
gui_size gui_panel_edit_filtered(struct gui_panel_layout*, gui_char *buffer, gui_size len,
|
||||
gui_size max, gui_bool *active, gui_filter);
|
||||
gui_bool gui_panel_shell(struct gui_panel_layout*, gui_char *buffer, gui_size *len,
|
||||
gui_size max, gui_bool *active);
|
||||
gui_int gui_panel_spinner(struct gui_panel_layout*, gui_int min, gui_int value,
|
||||
gui_int max, gui_int step, gui_bool *active);
|
||||
gui_size gui_panel_selector(struct gui_panel_layout*, const char *items[],
|
||||
gui_size item_count, gui_size item_current);
|
||||
void gui_panel_graph_begin(struct gui_panel_layout*, struct gui_graph*, enum gui_graph_type,
|
||||
gui_size count, gui_float min_value, gui_float max_value);
|
||||
gui_bool gui_panel_graph_push(struct gui_panel_layout *layout, struct gui_graph*, gui_float);
|
||||
void gui_panel_graph_end(struct gui_panel_layout *layout, struct gui_graph*);
|
||||
gui_int gui_panel_graph(struct gui_panel_layout*, enum gui_graph_type,
|
||||
const gui_float *values, gui_size count);
|
||||
gui_int gui_panel_graph_ex(struct gui_panel_layout*, enum gui_graph_type, gui_size count,
|
||||
gui_float(*get_value)(void*, gui_size), void *userdata);
|
||||
void gui_panel_table_begin(struct gui_panel_layout*, gui_flags flags,
|
||||
gui_size row_height, gui_size cols);
|
||||
void gui_panel_table_row(struct gui_panel_layout*);
|
||||
void gui_panel_table_end(struct gui_panel_layout*);
|
||||
gui_bool gui_panel_tab_begin(struct gui_panel_layout*, struct gui_panel_layout *tab,
|
||||
const char*, gui_bool);
|
||||
void gui_panel_tab_end(struct gui_panel_layout*, struct gui_panel_layout *tab);
|
||||
void gui_panel_group_begin(struct gui_panel_layout*, struct gui_panel_layout *tab,
|
||||
const char*,gui_float offset);
|
||||
gui_float gui_panel_group_end(struct gui_panel_layout*, struct gui_panel_layout* tab);
|
||||
gui_size gui_panel_shelf_begin(struct gui_panel_layout*, struct gui_panel_layout *shelf,
|
||||
const char *tabs[], gui_size size, gui_size active, gui_float offset);
|
||||
gui_float gui_panel_shelf_end(struct gui_panel_layout*, struct gui_panel_layout *shelf);
|
||||
void gui_panel_end(struct gui_panel_layout*, struct gui_panel*);
|
||||
|
||||
|
||||
/* Hook */
|
||||
#define gui_hook_panel(h) (&((h)->GUI_HOOK_PANEL_NAME))
|
||||
#define gui_hook_output(h) (&((h)->GUI_HOOK_OUTPUT_NAME))
|
||||
#define gui_panel_hook_init(hook, x, y, w, h, flags, config, font)\
|
||||
gui_panel_init(gui_hook_panel(hook), x, y, w, h, flags, config, font)
|
||||
gui_bool gui_panel_hook_begin_stacked(struct gui_panel_layout*, struct gui_panel_hook*,
|
||||
struct gui_panel_stack*, const char*, const struct gui_canvas*,
|
||||
const struct gui_input*);
|
||||
gui_bool gui_panel_hook_begin_tiled(struct gui_panel_layout*, struct gui_panel_hook*,
|
||||
struct gui_layout*, enum gui_layout_slot_index, gui_size index, const char*,
|
||||
const struct gui_canvas*, const struct gui_input*);
|
||||
#define gui_panel_hook_end(layout, hook)\
|
||||
gui_panel_end((layout), gui_hook_panel(hook))
|
||||
|
||||
|
||||
/* Stack */
|
||||
#define gui_stack_begin(s) ((s)->begin)
|
||||
#define gui_stack_end(s) ((s)->end)
|
||||
void gui_stack_clear(struct gui_panel_stack*);
|
||||
void gui_stack_push(struct gui_panel_stack*, struct gui_panel_hook*);
|
||||
void gui_stack_pop(struct gui_panel_stack*, struct gui_panel_hook*);
|
||||
#define gui_stack_for_each(i, s) for (i = gui_stack_begin(s); i != NULL; i = (i)->next)
|
||||
|
||||
|
||||
/* Layout */
|
||||
void gui_layout_init(struct gui_layout*, const struct gui_layout_config*);
|
||||
void gui_layout_begin(struct gui_layout*, gui_size width, gui_size height, enum gui_layout_state);
|
||||
void gui_layout_end(struct gui_panel_stack*, struct gui_layout*);
|
||||
gui_size gui_layout_space(struct gui_layout*, enum gui_layout_slot_index, gui_size index);
|
||||
void gui_layout_slot(struct gui_layout*, enum gui_layout_slot_index,
|
||||
enum gui_layout_format, gui_size panel_count);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user