added panel bound popups

This commit is contained in:
vurtun 2015-08-10 20:34:47 +02:00
parent bb037eae95
commit bfa81e57b1
5 changed files with 582 additions and 357 deletions

View File

@ -8,7 +8,7 @@ application and does not have any direct dependencies.
## Features
- Immediate mode graphical user interface toolkit
- Written in C89 (ANSI C)
- Small codebase (~5kLOC)
- Small codebase (~6kLOC)
- Focus on portability, efficiency, simplicity and minimal internal state
- Suited for embedding into graphical applications
- No global or hidden state
@ -42,26 +42,24 @@ struct gui_command_queue queue;
void *memory = malloc(MEMORY_SIZE);
gui_command_queue_init_fixed(&buffer, memory, MEMORY_SIZE);
/* setup font */
/* setup configuration */
struct gui_font font;
struct gui_config config;
font.userdata.ptr = your_font_data;
font.height = your_font_data.height;
font.width = your_font_string_width_callback_function;
/* setup configuration */
struct gui_config config;
gui_config_default(&config, GUI_DEFAULT_ALL, &font);
/* initialize panel */
struct gui_panel panel;
gui_panel_init(&panel, 50, 50, 220, 170,
GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE|GUI_PANEL_SCALEABLE,
&buffer, &config);
&queue, &config, &input);
/* setup widget data */
enum {EASY, HARD};
gui_size option = 0;
gui_size item;
gui_size option = EASY;
gui_size item = 0;
struct gui_input input = {0};
while (1) {
@ -71,7 +69,7 @@ while (1) {
/* GUI */
struct gui_panel_layout layout;
gui_panel_begin(&layout, &panel, &input);
gui_panel_begin(&layout, &panel);
{
const char *items[] = {"Fist", "Pistol", "Railgun", "BFG"};
gui_panel_header(&layout, "Demo", GUI_CLOSEABLE, 0, GUI_HEADER_LEFT);
@ -104,6 +102,8 @@ while (1) {
/*...*/
case GUI_COMMAND_TEXT:
/*...*/
case GUI_COMMAND_IMAGE:
/*...*/
}
}
gui_command_queue_clear(&queue);
@ -228,14 +228,14 @@ added. It contains information about the allocated amount of data in the current
frame as well as the needed amount if not enough memory was provided.
```c
/* fixed size buffer */
/* fixed size queue */
void *memory = malloc(size);
gui_command_queue buffer;
gui_command_queue_init_fixed(&buffer, memory, MEMORY_SIZE, GUI_CLIP);
gui_command_queue queue;
gui_command_queue_init_fixed(&queue, memory, MEMORY_SIZE, GUI_CLIP);
```
```c
/* dynamically growing buffer */
/* dynamically growing queue */
struct gui_allocator alloc;
alloc.userdata = your_allocator;
alloc.alloc = your_allocation_callback;
@ -272,12 +272,12 @@ gui_layout_slot(&tiled, GUI_SLOT_CENTER, 0.5f, GUI_LAYOUT_VERTICAL, 1);
gui_layout_end(&tiled);
/* setup panels */
struct gui_input input = {0};
struct gui_panel left;
struct gui_panel center;
gui_panel_init(&left, 0, 0, 0, 0, 0, &buffer, &queue);
gui_panel_init(&center, 0, 0, 0, 0, 0, &buffer, &queue);
gui_panel_init(&left, 0, 0, 0, 0, 0, &config, &queue, &input);
gui_panel_init(&center, 0, 0, 0, 0, 0, &config, &queue, &input);
struct gui_input input = {0};
while (1) {
gui_input_begin(&input);
/* record input */
@ -285,13 +285,13 @@ while (1) {
/* GUI */
struct gui_panel_layout layout;
gui_panel_begin_tiled(&layout, &left, &tiled, GUI_SLOT_LEFT, 0, &input);
gui_panel_begin_tiled(&layout, &left, &tiled, GUI_SLOT_LEFT, 0);
gui_panel_row_dynamic(&layout, 30, 1);
if (gui_panel_button_text(&layout, "button0", GUI_BUTTON_DEFAULT))
fprintf(stdout, "button pressed!\n");
gui_panel_end(&layout, &left);
gui_panel_begin_tiled(&layout, &center, &tiled, GUI_SLOT_CENTER, 0, &input);
gui_panel_begin_tiled(&layout, &center, &tiled, GUI_SLOT_CENTER, 0);
gui_panel_row_dynamic(&layout, 30, 1);
if (gui_panel_button_text(&layout, "button1", GUI_BUTTON_DEFAULT))
fprintf(stdout, "button pressed!\n");

View File

@ -1,5 +1,5 @@
#define MAX_BUFFER 64
#define MAX_MEMORY (32 * 1024)
#define MAX_MEMORY (64 * 1024)
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600
@ -40,6 +40,9 @@ struct state {
gui_int op;
gui_size cur;
gui_bool popup;
gui_bool combo;
gui_size sel;
/* tree */
struct test_tree tree;
@ -72,6 +75,7 @@ struct state {
struct demo_gui {
gui_bool running;
void *memory;
const struct gui_input *input;
struct gui_command_queue queue;
struct gui_config config;
struct gui_font font;
@ -179,7 +183,7 @@ widget_panel(struct gui_panel_layout *panel, struct state *demo)
/* Buttons */
if (gui_panel_button_text(panel, "button", GUI_BUTTON_DEFAULT))
fprintf(stdout, "button pressed!\n");
demo->popup = gui_true;
if (gui_panel_button_text_triangle(panel, GUI_RIGHT, "next", GUI_TEXT_LEFT, GUI_BUTTON_DEFAULT))
fprintf(stdout, "right triangle button pressed!\n");
if (gui_panel_button_text_triangle(panel,GUI_LEFT,"previous",GUI_TEXT_RIGHT,GUI_BUTTON_DEFAULT))
@ -189,7 +193,7 @@ widget_panel(struct gui_panel_layout *panel, struct state *demo)
demo->checkbox = gui_panel_check(panel, "checkbox", demo->checkbox);
if (!demo->scaleable)
gui_panel_row_static(panel, 30, 75, 1);
gui_panel_row_static(panel, 30, 75, 2);
else gui_panel_row_dynamic(panel, 30, 2);
if (gui_panel_option(panel, "option 0", demo->option == 0)) demo->option = 0;
@ -285,127 +289,19 @@ table_panel(struct gui_panel_layout *panel)
gui_panel_table_end(panel);
}
static void
update_menu(struct gui_panel_layout *layout, struct state *win, struct gui_config *config)
{
int i = 0;
enum level_id {LEVEL_MENU,LEVEL_FILE,LEVEL_OPEN,LEVEL_EDIT};
enum item_id {ITEM_FILE, ITEM_EDIT,
ITEM_FILE_BACK, ITEM_FILE_OPEN, ITEM_FILE_CLOSE, ITEM_FILE_QUIT,
ITEM_FILE_OPEN_BACK, ITEM_FILE_OPEN_EXE, ITEM_FILE_OPEN_SRC,
ITEM_EDIT_BACK, ITEM_EDIT_COPY, ITEM_EDIT_CUT, ITEM_EDIT_PASTE, ITEM_EDIT_DELETE};
enum combi_id {MENU_FILE, MENU_EDIT,
FILE_BACK, FILE_OPEN, FILE_CLOSE, FILE_QUIT,
OPEN_BACK, OPEN_EXE, OPEN_SRC,
EDIT_BACK, EDIT_COPY, EDIT_CUT, EDIT_PASTE, EDIT_DELETE};
struct level {const enum level_id id; const int items; enum combi_id list;};
struct item {const enum item_id id; const char *name; const enum level_id lvl, next;};
struct combi {const enum combi_id id; const enum level_id level; const enum item_id item;};
static const struct level levels[] = {
{LEVEL_MENU, 2, MENU_FILE},
{LEVEL_FILE, 4, FILE_BACK},
{LEVEL_OPEN, 3, OPEN_BACK},
{LEVEL_EDIT, 5, EDIT_BACK},
};
static const struct item items[] = {
{ITEM_FILE, "FILE", LEVEL_MENU, LEVEL_FILE},
{ITEM_EDIT, "EDIT", LEVEL_MENU, LEVEL_EDIT},
{ITEM_FILE_BACK, "BACK", LEVEL_FILE, LEVEL_MENU},
{ITEM_FILE_OPEN, "OPEN", LEVEL_FILE, LEVEL_OPEN},
{ITEM_FILE_CLOSE, "CLOSE", LEVEL_FILE, LEVEL_MENU},
{ITEM_FILE_QUIT, "QUIT", LEVEL_FILE, LEVEL_MENU},
{ITEM_FILE_OPEN_BACK, "BACK", LEVEL_OPEN, LEVEL_FILE},
{ITEM_FILE_OPEN_EXE, "IMAGE", LEVEL_OPEN, LEVEL_MENU},
{ITEM_FILE_OPEN_SRC, "TEXT", LEVEL_OPEN, LEVEL_MENU},
{ITEM_EDIT_BACK, "BACK", LEVEL_EDIT, LEVEL_MENU},
{ITEM_EDIT_COPY, "COPY", LEVEL_EDIT, LEVEL_MENU},
{ITEM_EDIT_CUT, "CUT", LEVEL_EDIT, LEVEL_MENU},
{ITEM_EDIT_PASTE, "PASTE", LEVEL_EDIT, LEVEL_MENU},
{ITEM_EDIT_DELETE, "DEL", LEVEL_EDIT, LEVEL_MENU}
};
static const struct combi combis[] = {
/* main menu level */
{MENU_FILE, LEVEL_MENU, ITEM_FILE},
{MENU_EDIT, LEVEL_MENU, ITEM_EDIT},
/* file menu level */
{FILE_BACK, LEVEL_FILE, ITEM_FILE_BACK},
{FILE_OPEN, LEVEL_FILE, ITEM_FILE_OPEN},
{FILE_CLOSE, LEVEL_FILE, ITEM_FILE_CLOSE},
{FILE_QUIT, LEVEL_FILE, ITEM_FILE_QUIT},
/* open file options menu level */
{OPEN_BACK, LEVEL_OPEN, ITEM_FILE_OPEN_BACK},
{OPEN_EXE, LEVEL_OPEN, ITEM_FILE_OPEN_EXE},
{OPEN_SRC, LEVEL_OPEN, ITEM_FILE_OPEN_SRC},
/* edit main level*/
{EDIT_BACK, LEVEL_EDIT, ITEM_EDIT_BACK},
{EDIT_COPY, LEVEL_EDIT, ITEM_EDIT_COPY},
{EDIT_CUT, LEVEL_EDIT, ITEM_EDIT_CUT},
{EDIT_PASTE, LEVEL_EDIT, ITEM_EDIT_PASTE},
{EDIT_DELETE, LEVEL_EDIT, ITEM_EDIT_DELETE}
};
{
/* calculate column row count to fit largets menu item */
gui_int max = 0;
for (i = 0; i < (int)LEN(levels); ++i) {
if (levels[0].items > max)
max = levels[0].items;
}
gui_panel_row_dynamic(layout, 18, 5);
}
/* output current menu level entries */
gui_panel_menu_begin(layout);
{
const struct level *lvl = &levels[win->menu_item];
const struct combi *iter = &combis[lvl->list];
gui_config_push_color(config, GUI_COLOR_BUTTON_BORDER, 45, 45, 45, 250);
gui_config_push_property(config, GUI_PROPERTY_ITEM_SPACING, 0, 4.0f);
for (i = 0; i < lvl->items; ++i) {
const struct item *item = &items[iter->item];
if (gui_panel_button_text(layout, item->name, GUI_BUTTON_DEFAULT)) {
if (item->id == ITEM_FILE_OPEN_EXE) {
fprintf(stdout, "open program file button pressed!\n");
} else if (item->id == ITEM_FILE_OPEN_SRC) {
fprintf(stdout, "open source file button pressed!\n");
} else if (item->id == ITEM_FILE_CLOSE) {
fprintf(stdout, "close button pressed!\n");
} else if (item->id == ITEM_FILE_QUIT) {
fprintf(stdout, "quit button pressed!\n");
} else if (item->id == ITEM_EDIT_COPY) {
fprintf(stdout, "copy button pressed!\n");
} else if (item->id == ITEM_EDIT_CUT) {
fprintf(stdout, "cut button pressed!\n");
} else if (item->id == ITEM_EDIT_PASTE) {
fprintf(stdout, "paste button pressed!\n");
} else if (item->id == ITEM_EDIT_DELETE) {
fprintf(stdout, "delete button pressed!\n");
}
win->menu_item = item->next;
}
iter++;
}
gui_config_pop_color(config);
gui_config_pop_property(config);
}
gui_panel_menu_end(layout);
}
static void
update_flags(struct gui_panel_layout *panel)
{
gui_size n = 0;
gui_flags res = 0;
gui_flags i = 0x01;
const char *options[]={"Hidden","Border","Header Border", "Moveable","Scaleable", "Minimized"};
const char *options[]={"Hidden","Border","Header Border", "Moveable","Scaleable", "Minimized", "ROM"};
gui_panel_row_dynamic(panel, 30, 2);
do {
if (gui_panel_check(panel,options[n++],(panel->flags & i)?gui_true:gui_false))
res |= i;
i = i << 1;
} while (i <= GUI_PANEL_MINIMIZED);
} while (i <= GUI_PANEL_ROM);
panel->flags = res;
}
@ -547,22 +443,23 @@ init_demo(struct demo_gui *gui, struct gui_font *font)
gui->font = *font;
gui->running = gui_true;
clip.userdata.ptr = NULL,
clip.copy = copy;
clip.paste = paste;
gui_command_queue_init_fixed(&gui->queue, gui->memory, MAX_MEMORY);
gui_config_default(config, GUI_DEFAULT_ALL, font);
/* panel */
gui_panel_init(&gui->panel, 30, 30, 280, 530,
GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE|GUI_PANEL_SCALEABLE, &gui->queue, config);
GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE|GUI_PANEL_SCALEABLE,
&gui->queue, config, gui->input);
gui_panel_init(&gui->sub, 400, 50, 220, 180,
GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE|GUI_PANEL_SCALEABLE,
&gui->queue, config);
&gui->queue, config, gui->input);
/* widget state */
clip.userdata.ptr = NULL,
clip.copy = copy;
clip.paste = paste;
gui_edit_box_init_fixed(&win->input, win->input_buffer, MAX_BUFFER, &clip, NULL);
win->config_tab = GUI_MINIMIZED;
win->widget_tab = GUI_MINIMIZED;
win->style_tab = GUI_MINIMIZED;
@ -621,7 +518,7 @@ init_demo(struct demo_gui *gui, struct gui_font *font)
}
static void
run_demo(struct demo_gui *gui, struct gui_input *input)
run_demo(struct demo_gui *gui)
{
struct gui_panel_layout layout;
struct state *state = &gui->state;
@ -630,12 +527,11 @@ run_demo(struct demo_gui *gui, struct gui_input *input)
static const char *shelfs[] = {"Histogram", "Lines"};
enum {EASY, HARD};
gui_panel_begin(&layout, &gui->panel, input);
gui_panel_begin(&layout, &gui->panel);
{
/* Header + Menubar */
/* Header */
gui->running = !gui_panel_header(&layout, "Demo",
GUI_CLOSEABLE|GUI_MINIMIZABLE, GUI_CLOSEABLE, GUI_HEADER_RIGHT);
update_menu(&layout, state, config);
/* Panel style configuration */
if (gui_panel_layout_push(&layout, GUI_LAYOUT_TAB, "Style", &state->config_tab))
@ -665,6 +561,30 @@ run_demo(struct demo_gui *gui, struct gui_input *input)
gui_panel_layout_pop(&layout);
}
/* popup panel */
if (state->popup) {
gui_panel_popup_begin(&layout, &tab, gui_rect(20, 10, 220, 150), gui_vec2(0,0));
{
if (gui_panel_header(&tab, "Popup", GUI_CLOSEABLE, GUI_CLOSEABLE, GUI_HEADER_LEFT)) {
gui_panel_popup_close(&tab);
state->popup = gui_false;
}
gui_panel_row_dynamic(&tab, 30, 1);
gui_panel_label(&tab, "Are you sure you want to exit?", GUI_TEXT_LEFT);
gui_panel_row_dynamic(&tab, 30, 4);
gui_panel_spacing(&tab, 1);
if (gui_panel_button_text(&tab, "Yes", GUI_BUTTON_DEFAULT)) {
gui_panel_popup_close(&tab);
state->popup = gui_false;
}
if (gui_panel_button_text(&tab, "No", GUI_BUTTON_DEFAULT)) {
gui_panel_popup_close(&tab);
state->popup = gui_false;
}
}
gui_panel_popup_end(&layout, &tab);
}
/* Shelf + Graphes */
gui_panel_row_dynamic(&layout, 180, 1);
state->shelf_selection = gui_panel_shelf_begin(&layout, &tab, shelfs,
@ -689,7 +609,7 @@ run_demo(struct demo_gui *gui, struct gui_input *input)
}
gui_panel_end(&layout, &gui->panel);
gui_panel_begin(&layout, &gui->sub, input);
gui_panel_begin(&layout, &gui->sub);
{
const char *items[] = {"Fist", "Pistol", "Railgun", "BFG"};
gui_panel_header(&layout, "Demo", GUI_CLOSEABLE, 0, GUI_HEADER_LEFT);

View File

@ -584,6 +584,7 @@ main(int argc, char *argv[])
memset(&in, 0, sizeof in);
memset(&gui, 0, sizeof gui);
gui.memory = malloc(MAX_MEMORY);
gui.input = &in;
font.userdata.ptr = glfont;
font.height = glfont->height;
font.width = font_get_text_width;
@ -611,7 +612,7 @@ main(int argc, char *argv[])
SDL_GetWindowSize(win, &width, &height);
gui.w = (gui_size)width;
gui.h = (gui_size)height;
run_demo(&gui, &in);
run_demo(&gui);
/* Draw */
glClearColor(0.4f, 0.4f, 0.4f, 1.0f);

623
gui.c

File diff suppressed because it is too large Load Diff

109
gui.h
View File

@ -68,7 +68,7 @@ typedef long gui_long;
typedef float gui_float;
typedef double gui_double;
typedef unsigned short gui_ushort;
typedef unsigned int gui_uint;
ypedef unsigned int gui_uint;
typedef unsigned long gui_ulong;
typedef unsigned int gui_flags;
typedef unsigned char gui_byte;
@ -648,7 +648,13 @@ const struct gui_command *gui_command_buffer_next(struct gui_command_buffer*,
more than one command buffer on one memory buffer and still only need
to iterate over one command list. Therefore it is possible to have mutliple
panels without having to manage each panels individual memory. This greatly
simplifies and reduces the amount of code needed with just using memory buffers.
simplifies and reduces the amount of code needed with just using command buffers.
Internally the command queue has a list of command buffers which can be
modified to create a certain sequence, for example the `gui_panel_begin`
function changes the list to create overlapping panels, while the
`gui_panel_begin_tiled` function makes sure that its command buffers will
always be drawn first since panel in tiled layouts are always in the background.
USAGE
----------------------------
@ -667,17 +673,20 @@ const struct gui_command *gui_command_buffer_next(struct gui_command_buffer*,
gui_command_queue_init -- initializes a dynamic command queue
gui_command_queue_init_fixed -- initializes a static command queue
gui_command_queue_clear -- frees all memory if the command queue is dynamic
gui_command_queue_add -- adds a command buffer into the queue
gui_command_queue_insert_font -- adds a command buffer in the front of the queue
gui_command_queue_insert_back -- adds a command buffer in the back of the queue
gui_command_queue_remove -- removes a command buffer from the queue
gui_command_queue_start -- begins the command buffer filling process
gui_command_queue_finish -- ends the command buffer filling process
gui_command_queue_start_child -- begins the child command buffer filling process
gui_command_queue_finish_child -- ends the child command buffer filling process
command iterator function API
gui_command_queue_begin -- returns the first command in a queue
gui_command_queue_next -- returns the next command in a queue
gui_foreach_command -- iterates over all commands in a queue
*/
struct gui_command_buffer_stack {
struct gui_command_buffer_list {
gui_size count;
/* number of panels inside the stack */
struct gui_command_buffer *begin;
@ -686,11 +695,36 @@ struct gui_command_buffer_stack {
/* currently active panel which will be drawn last */
};
struct gui_command_sub_buffer {
gui_size begin;
/* begin of the subbuffer */
gui_size parent_last;
/* last entry before the sub buffer*/
gui_size last;
/* last entry in the sub buffer*/
gui_size end;
/* end of the subbuffer */
gui_size next;
};
struct gui_command_sub_buffer_stack {
gui_size count;
/* number of subbuffers */
gui_size begin;
/* buffer offset of the first subbuffer*/
gui_size end;
/* buffer offset of the last subbuffer*/
gui_size size;
/* real size of the buffer */
};
struct gui_command_queue {
struct gui_buffer buffer;
/* memory buffer the hold all commands */
struct gui_command_buffer_stack stack;
/* stack of each memory buffer inside the queue */
struct gui_command_buffer_list list;
/* list of each memory buffer inside the queue */
struct gui_command_sub_buffer_stack stack;
/* subbuffer stack for overlapping child panels in panels */
gui_bool build;
/* flag indicating if a complete command list was build inside the queue*/
};
@ -734,6 +768,18 @@ void gui_command_queue_finish(struct gui_command_queue*, struct gui_command_buff
Input:
- the now filled command buffer
*/
gui_bool gui_command_queue_start_child(struct gui_command_queue*, struct gui_command_buffer*);
/* this function sets up the command buffer to be filled up
Input:
- command buffer to fill begin the child buffer in
Output:
- gui_true if successful gui_false otherwise
*/
void gui_command_queue_finish_child(struct gui_command_queue*, struct gui_command_buffer*);
/* this function finishes the command buffer fill up process
Input:
- the now filled command buffer
*/
void gui_command_queue_free(struct gui_command_queue*);
/* this function clears the internal buffer if it is a dynamic buffer */
void gui_command_queue_clear(struct gui_command_queue*);
@ -1616,24 +1662,20 @@ struct gui_color gui_config_color(const struct gui_config*, enum gui_config_colo
- color value that has been asked for
*/
void gui_config_push_property(struct gui_config*, enum gui_config_properties,
gui_float, gui_float);
struct gui_vec2);
/* this function temporarily changes a property in a stack like fashion to be reseted later
Input:
- Configuration structure to push the change to
- Property idenfifier to change
- first value of the property most of the time the x position
- second value of the property most of the time the y position
- new value of the property
*/
void gui_config_push_color(struct gui_config*, enum gui_config_colors,
gui_byte, gui_byte, gui_byte, gui_byte);
struct gui_color);
/* this function temporarily changes a color in a stack like fashion to be reseted later
Input:
- Configuration structure to push the change to
- color idenfifier to change
- red color component
- green color component
- blue color component
- alpha color component
- new color
*/
void gui_config_pop_color(struct gui_config*);
/* this function reverts back a previously pushed temporary color change
@ -1733,9 +1775,11 @@ enum gui_panel_flags {
* by dragging a scaler icon at the button of the panel */
GUI_PANEL_MINIMIZED = 0x20,
/* marks the panel as minimized */
GUI_PANEL_ACTIVE = 0x40,
GUI_PANEL_ROM = 0x40,
/* sets the panel in to a read only mode and does not allow input changes */
GUI_PANEL_ACTIVE = 0x10000,
/* INTERNAL ONLY!: marks the panel as active, used by the panel stack */
GUI_PANEL_TAB = 0x80
GUI_PANEL_TAB = 0x20000
/* INTERNAL ONLY!: Marks the panel as an subpanel of another panel(Groups/Tabs/Shelf)*/
};
@ -1754,6 +1798,8 @@ struct gui_panel {
/* output command buffer queuing all drawing calls */
struct gui_command_queue *queue;
/* output command queue which hold the command buffer */
const struct gui_input *input;
/* input state for updating the panel and all its widgets */
};
enum gui_panel_row_layout_type {
@ -1858,6 +1904,8 @@ struct gui_panel_layout {
/* current input state for updating the panel and all its widgets */
struct gui_command_buffer *buffer;
/* command draw call output command buffer */
struct gui_command_queue *queue;
/* command draw call output command buffer */
};
/*
@ -1899,7 +1947,7 @@ struct gui_panel_layout {
struct gui_layout;
void gui_panel_init(struct gui_panel *panel, gui_float x, gui_float y, gui_float w,
gui_float h, gui_flags flags, struct gui_command_queue*,
const struct gui_config*);
const struct gui_config*, const struct gui_input *in);
/* this function initilizes and setups the panel
Input:
- bounds of the panel with x,y position and width and height
@ -1930,7 +1978,7 @@ gui_bool gui_panel_has_flag(struct gui_panel*, gui_flags);
*/
gui_bool gui_panel_is_minimized(struct gui_panel*);
/* this function checks if the panel is minimized */
void gui_panel_begin(struct gui_panel_layout*, struct gui_panel*, const struct gui_input*);
void gui_panel_begin(struct gui_panel_layout*, struct gui_panel*);
/* this function begins the panel build up process
Input:
- input structure holding all user generated state changes
@ -2614,7 +2662,7 @@ gui_int gui_panel_graph(struct gui_panel_layout*, enum gui_graph_type,
- number of graph values
- offset into the value array from which to begin drawing
*/
gui_int gui_panel_graph_ex(struct gui_panel_layout*, enum gui_graph_type,
gui_int gui_panel_graph_callback(struct gui_panel_layout*, enum gui_graph_type,
gui_size count, gui_float(*get_value)(void*, gui_size),
void *userdata);
/* this function create a graph with given type from callback providing the
@ -2717,11 +2765,30 @@ struct gui_vec2 gui_panel_tree_end(struct gui_panel_layout*, struct gui_tree*);
a index as well indiciation which tab needs to filled inside the group.
Panel group API
gui_panel_popup_begin -- adds a popup inside a panel
gui_panel_popup_end -- ends the popup building process
gui_panel_group_begin -- adds a scrollable fixed space inside the panel
gui_panel_group_end -- ends the scrollable space
gui_panel_shelf_begin -- begins a shelf with a number of selectable tabs
gui_panel_shelf_end -- ends a previously started shelf build up process
*/
gui_flags gui_panel_popup_begin(struct gui_panel_layout *parent, struct gui_panel_layout *popup,
struct gui_rect bounds, struct gui_vec2 scrollbar);
/* this function adds a grouped subpanel into the parent panel
Input:
- popup position and size of the popup (NOTE: local position)
- scrollbar pixel offsets for the popup
Output:
- popup layout to fill with widgets
*/
void gui_panel_popup_close(struct gui_panel_layout *popup);
/* this functions closes a previously opened popup */
struct gui_vec2 gui_panel_popup_end(struct gui_panel_layout *parent,
struct gui_panel_layout *popup);
/* this function finishes the previously started popup layout
Output:
- The from user input updated popup scrollbar pixel offset
*/
void gui_panel_group_begin(struct gui_panel_layout*, struct gui_panel_layout *tab,
const char *title, struct gui_vec2 offset);
/* this function adds a grouped subpanel into the parent panel
@ -2773,7 +2840,6 @@ struct gui_vec2 gui_panel_shelf_end(struct gui_panel_layout*, struct gui_panel_l
need more than just fixed or overlapping panels. There are five slots
(Top, Left, Center, Right, Bottom) in the layout which are either be
scaleable or static and occupy a certain percentage of the screen.
o TODO dockable panels
USAGE
----------------------------
@ -2868,8 +2934,7 @@ struct gui_layout {
};
void gui_panel_begin_tiled(struct gui_panel_layout*, struct gui_panel*,
struct gui_layout*, enum gui_layout_slot_index, gui_size index,
const struct gui_input*);
struct gui_layout*, enum gui_layout_slot_index, gui_size index);
/* this function begins a tiled panel build up process
Input:
- slot the panel will be placed inside the tiled layout