diff --git a/Readme.md b/Readme.md index fbd2fbe..c6ae0ff 100644 --- a/Readme.md +++ b/Readme.md @@ -38,7 +38,7 @@ have to be either executed or optionally converted into a vertex buffer to draw the GUI. ## Gallery -![gui demo](https://cloud.githubusercontent.com/assets/8057201/9937241/24f55e7e-5d60-11e5-9957-c010cf763f15.png) +![demo](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png) ![gui explorer](https://cloud.githubusercontent.com/assets/8057201/9937240/24f509ce-5d60-11e5-894a-e7e9e228de30.png) ![node](https://cloud.githubusercontent.com/assets/8057201/9976995/e81ac04a-5ef7-11e5-872b-acd54fbeee03.gif) @@ -62,8 +62,7 @@ zr_window_init(&window, 50, 50, 220, 180, /* setup widget data */ enum {EASY, HARD}; zr_size option = EASY; -zr_size item = 0; -zr_state active = 0; +zr_float value = 0.6f; struct zr_input input = {0}; while (1) { @@ -84,8 +83,14 @@ while (1) { zr_layout_row_dynamic(&context, 30, 2); if (zr_option(&context, "easy", option == EASY)) option = EASY; if (zr_option(&context, "hard", option == HARD)) option = HARD; - zr_label(&context, "Weapon:", ZR_TEXT_LEFT); - zr_combo(&context, items, LEN(items), &item, 20, &active); + zr_layout_row_begin(&context, ZR_STATIC, 30, 2); + { + zr_layout_row_push(&context, 50); + zr_label(&context, "Volume:", ZR_TEXT_LEFT); + zr_layout_row_push(&context, 110); + value = zr_slider(&context, 0, value, 1.0f, 0.1f); + } + zr_layout_row_end(&context); } zr_end(&context, &window); diff --git a/demo/demo.c b/demo/demo.c index 38f1215..835c97b 100644 --- a/demo/demo.c +++ b/demo/demo.c @@ -307,7 +307,7 @@ color_picker(struct zr_context *panel, struct color_picker* control, ret = zr_false; } } - zr_popup_end(panel, &popup); + zr_popup_end(panel, &popup, NULL); control->active = (zr_state)ret; return ret; } @@ -356,14 +356,16 @@ combo_box(struct zr_context *panel, struct combobox *combo, zr_size i = 0; struct zr_context layout; zr_combo_begin(panel, &layout, values[combo->selected], &combo->active); - zr_layout_row_dynamic(&layout, 25, 1); - for (i = 0; i < count; ++i) { - if (combo->selected == i) continue; - if (zr_combo_item(&layout, ZR_TEXT_LEFT, values[i])) { - combo->selected = i; + { + zr_layout_row_dynamic(&layout, 25, 1); + for (i = 0; i < count; ++i) { + if (combo->selected == i) continue; + if (zr_combo_item(&layout, ZR_TEXT_LEFT, values[i])) { + combo->selected = i; + } } } - combo->active = zr_combo_end(panel, &layout); + zr_combo_end(panel, &layout, &combo->active); } static void @@ -385,7 +387,7 @@ prog_combo_box(struct zr_context *panel, zr_size *values, zr_size count, for (i = 0; i < count; ++i) values[i] = zr_progress(&combo, values[i], 100, zr_true); } - zr_combo_end(panel, &combo); + zr_combo_end(panel, &combo, NULL); } static void @@ -411,7 +413,7 @@ color_combo_box(struct zr_context *panel, struct color_combo_box *demo) *iter = (zr_byte)t; } } - zr_combo_end(panel, &combo); + zr_combo_end(panel, &combo, NULL); } static void @@ -434,7 +436,7 @@ check_combo_box(struct zr_context *panel, zr_bool *values, zr_size count, for (i = 0; i < count; ++i) values[i] = zr_check(&combo, weapons[i], values[i]); } - zr_combo_end(panel, &combo); + zr_combo_end(panel, &combo, NULL); } /* ----------------------------------------------------------------- @@ -509,6 +511,7 @@ struct state { zr_state popup; zr_size cur; zr_size op; + zr_float value; /* subpanels */ struct zr_vec2 shelf; @@ -794,6 +797,7 @@ init_demo(struct demo_gui *gui) win->slider = 2.0f; win->progressbar = 50; win->spinner = 100; + win->value = 0.6f; } /* ----------------------------------------------------------------- @@ -894,7 +898,7 @@ run_demo(struct demo_gui *gui) state->popup = zr_false; } } - zr_popup_end(&layout, &tab); + zr_popup_end(&layout, &tab, NULL); } { @@ -915,7 +919,7 @@ run_demo(struct demo_gui *gui) default: break; } } - state->shelf = zr_shelf_end(&layout, &tab); + zr_shelf_end(&layout, &tab, &state->shelf); } { @@ -924,7 +928,7 @@ run_demo(struct demo_gui *gui) zr_layout_row_dynamic(&layout, 250, 1); zr_tree_begin(&layout, &tree, "Tree", 20, state->tree); upload_tree(&state->test, &tree, &state->test.root); - state->tree = zr_tree_end(&layout, &tree); + zr_tree_end(&layout, &tree, &state->tree); } } zr_end(&layout, &gui->panel); @@ -941,6 +945,14 @@ run_demo(struct demo_gui *gui) zr_layout_row_dynamic(&layout, 30, 2); if (zr_option(&layout, "easy", state->op == EASY)) state->op = EASY; if (zr_option(&layout, "hard", state->op == HARD)) state->op = HARD; + zr_layout_row_begin(&layout, ZR_STATIC, 30, 2); + { + zr_layout_row_push(&layout, 50); + zr_label(&layout, "Volume:", ZR_TEXT_LEFT); + zr_layout_row_push(&layout, 110); + state->value = zr_slider(&layout, 0, state->value, 1.0f, 0.1f); + } + zr_layout_row_end(&layout); } zr_end(&layout, &gui->sub); } diff --git a/demo/nanovg/nanovg.c b/demo/nanovg/nanovg.c index 4fb1ca5..5c7a48c 100644 --- a/demo/nanovg/nanovg.c +++ b/demo/nanovg/nanovg.c @@ -254,7 +254,6 @@ main(int argc, char *argv[]) /* GUI */ struct demo_gui gui; - if (argc < 2) { fprintf(stdout,"Missing TTF Font file argument: gui \n"); exit(EXIT_FAILURE); diff --git a/example/nodedit/nodedit.c b/example/nodedit/nodedit.c index 5e6a4fb..f219a1c 100644 --- a/example/nodedit/nodedit.c +++ b/example/nodedit/nodedit.c @@ -200,6 +200,7 @@ node_editor_draw(struct zr_context *layout, struct node_editor *nodedit, struct zr_command_buffer *canvas = zr_canvas(layout); struct node *updated = 0; + /* allocate complete window space */ total_space = zr_space(layout); zr_layout_row_space_begin(layout, ZR_STATIC, total_space.h, (zr_size)nodedit->node_count); { @@ -218,7 +219,7 @@ node_editor_draw(struct zr_context *layout, struct node_editor *nodedit, zr_command_buffer_push_line(canvas, size.x, y+size.y, size.x+size.w, y+size.y, grid_color); } - /* execute each node */ + /* execute each node as a moveable group */ zr_style_push_color(config, ZR_COLOR_WINDOW, zr_rgb(48, 48, 48)); while (it) { /* draw node */ @@ -347,30 +348,29 @@ node_editor_draw(struct zr_context *layout, struct node_editor *nodedit, node_editor_push(nodedit, updated); } - { - /* right click popup context menu activation */ - if (nodedit->menu == ZR_INACTIVE && - zr_input_mouse_clicked(in, ZR_BUTTON_RIGHT, zr_layout_row_space_bounds(layout))) { - it = nodedit->begin; - nodedit->selected = NULL; - nodedit->menu = ZR_ACTIVE; - nodedit->bounds = zr_rect(in->mouse.pos.x, in->mouse.pos.y, 100, 200); - while (it) { - struct zr_rect b = zr_layout_row_space_rect_to_screen(layout, it->bounds); - b.x -= nodedit->scrolling.x; - b.y -= nodedit->scrolling.y; - if (zr_input_is_mouse_hovering_rect(in, b)) - nodedit->selected = it; - it = it->next; - } + /* node selection + right click popup context menu activation */ + if (nodedit->menu == ZR_INACTIVE && + zr_input_mouse_clicked(in, ZR_BUTTON_RIGHT, zr_layout_row_space_bounds(layout))) { + it = nodedit->begin; + nodedit->selected = NULL; + nodedit->menu = ZR_ACTIVE; + nodedit->bounds = zr_rect(in->mouse.pos.x, in->mouse.pos.y, 100, 200); + while (it) { + struct zr_rect b = zr_layout_row_space_rect_to_screen(layout, it->bounds); + b.x -= nodedit->scrolling.x; + b.y -= nodedit->scrolling.y; + if (zr_input_is_mouse_hovering_rect(in, b)) + nodedit->selected = it; + it = it->next; } + } - /* popup context menu */ - if (nodedit->menu == ZR_ACTIVE) { - struct zr_context menu; - const char *grid_option[] = {"Show Grid", "Hide Grid"}; - zr_contextual_begin(layout, &menu, ZR_WINDOW_NO_SCROLLBAR, &nodedit->menu, - nodedit->bounds); + /* popup context menu */ + if (nodedit->menu == ZR_ACTIVE) { + struct zr_context menu; + const char *grid_option[] = {"Show Grid", "Hide Grid"}; + zr_contextual_begin(layout, &menu, ZR_WINDOW_NO_SCROLLBAR, &nodedit->menu, nodedit->bounds); + { zr_layout_row_dynamic(&menu, 25, 1); if (!nodedit->selected) { /* menu content if no selected node */ @@ -389,8 +389,8 @@ node_editor_draw(struct zr_context *layout, struct node_editor *nodedit, if (zr_contextual_item(&menu, "Copy", ZR_TEXT_CENTERED)) fprintf(stdout, "pressed copy!\n"); } - nodedit->menu = zr_contextual_end(layout, &menu); } + nodedit->menu = zr_contextual_end(layout, &menu); } } zr_layout_row_space_end(layout); diff --git a/zahnrad.c b/zahnrad.c index 18ee237..80b3d85 100644 --- a/zahnrad.c +++ b/zahnrad.c @@ -360,10 +360,10 @@ zr_hsv(zr_float h, zr_float s, zr_float v) zr_uint zr_color32(struct zr_color in) { - zr_uint out = (zr_draw_vertex_color)in.r; - out |= ((zr_draw_vertex_color)in.g << 8); - out |= ((zr_draw_vertex_color)in.b << 16); - out |= ((zr_draw_vertex_color)in.a << 24); + zr_uint out = (zr_uint)in.r; + out |= ((zr_uint)in.g << 8); + out |= ((zr_uint)in.b << 16); + out |= ((zr_uint)in.a << 24); return out; } @@ -2932,7 +2932,7 @@ zr_font_bake_pack(zr_size *image_memory, zr_size *width, zr_size *height, *height = 0; *width = (total_glyph_count > 1000) ? 1024 : 512; - stbtt_PackBegin(&baker->spc, NULL, (zr_int)*width, (int)max_height, 0, 1, 0); + stbtt_PackBegin(&baker->spc, 0, (zr_int)*width, (int)max_height, 0, 1, 0); { zr_size input_i = 0; zr_size range_n = 0, rect_n = 0, char_n = 0; @@ -7521,9 +7521,9 @@ zr_tree_end_node(struct zr_tree *tree) tree->skip = -1; } -struct zr_vec2 -zr_tree_end(struct zr_context *p, struct zr_tree* tree) -{return zr_group_end(p, &tree->group);} +void +zr_tree_end(struct zr_context *p, struct zr_tree* tree, struct zr_vec2 *scrollbar) +{zr_group_end(p, &tree->group, scrollbar);} /* * ------------------------------------------------------------- * @@ -7595,8 +7595,8 @@ failed: g->queue = p->queue; } -struct zr_vec2 -zr_group_end(struct zr_context *p, struct zr_context *g) +void +zr_group_end(struct zr_context *p, struct zr_context *g, struct zr_vec2 *scrollbar) { struct zr_window pan; struct zr_command_buffer *out; @@ -7604,8 +7604,8 @@ zr_group_end(struct zr_context *p, struct zr_context *g) ZR_ASSERT(p); ZR_ASSERT(g); - if (!p || !g) return zr_vec2(0,0); - if (!p->valid) return zr_vec2(0,0); + if (!p || !g) return; + if (!p->valid) return; zr_zero(&pan, sizeof(pan)); out = p->buffer; @@ -7621,7 +7621,8 @@ zr_group_end(struct zr_context *p, struct zr_context *g) zr_command_buffer_push_scissor(out, clip); zr_end(g, &pan); zr_command_buffer_push_scissor(out, p->clip); - return pan.offset; + if (scrollbar) + *scrollbar = pan.offset; } /* * ------------------------------------------------------------- @@ -7765,8 +7766,8 @@ failed: return active; } -struct zr_vec2 -zr_shelf_end(struct zr_context *p, struct zr_context *s) +void +zr_shelf_end(struct zr_context *p, struct zr_context *s, struct zr_vec2 *scrollbar) { struct zr_command_buffer *out; struct zr_rect clip; @@ -7774,8 +7775,8 @@ zr_shelf_end(struct zr_context *p, struct zr_context *s) ZR_ASSERT(p); ZR_ASSERT(s); - if (!p || !s) return zr_vec2(0,0); - if (!p->valid) return zr_vec2(0,0); + if (!p || !s) return; + if (!p->valid) return; zr_zero(&pan, sizeof(pan)); out = p->buffer; @@ -7787,7 +7788,8 @@ zr_shelf_end(struct zr_context *p, struct zr_context *s) zr_command_buffer_push_scissor(out, clip); zr_end(s, &pan); zr_command_buffer_push_scissor(out, p->clip); - return pan.offset; + if (scrollbar) + *scrollbar = pan.offset; } /* * ------------------------------------------------------------- @@ -7848,16 +7850,17 @@ zr_popup_close(struct zr_context *popup) popup->valid = zr_false; } -struct zr_vec2 -zr_popup_end(struct zr_context *parent, struct zr_context *popup) +void +zr_popup_end(struct zr_context *parent, struct zr_context *popup, + struct zr_vec2 *scrollbar) { struct zr_window pan; struct zr_command_buffer *out; ZR_ASSERT(parent); ZR_ASSERT(popup); - if (!parent || !popup) return zr_vec2(0,0); - if (!parent->valid) return zr_vec2(0,0); + if (!parent || !popup) return; + if (!parent->valid) return; zr_zero(&pan, sizeof(pan)); if (popup->flags & ZR_WINDOW_HIDDEN) { @@ -7878,7 +7881,8 @@ zr_popup_end(struct zr_context *parent, struct zr_context *popup) zr_end(popup, &pan); zr_command_queue_finish_child(parent->queue, parent->buffer); zr_command_buffer_push_scissor(out, parent->clip); - return pan.offset; + if (scrollbar) + *scrollbar = pan.offset; } /* * ------------------------------------------------------------- @@ -7890,7 +7894,7 @@ zr_popup_end(struct zr_context *parent, struct zr_context *popup) static zr_bool zr_popup_nonblocking_begin(struct zr_context *parent, struct zr_context *popup, zr_flags flags, zr_state *active, zr_state is_active, - struct zr_rect body) + struct zr_rect body, struct zr_vec2 scrollbar) { /* deactivate popup if user clicked outside the popup*/ const struct zr_input *in = parent->input; @@ -7907,7 +7911,7 @@ zr_popup_nonblocking_begin(struct zr_context *parent, /* if active create popup otherwise deactive the panel layout */ if (!is_active && *active) { - zr_popup_begin(parent, popup, ZR_POPUP_DYNAMIC, flags, body, zr_vec2(0,0)); + zr_popup_begin(parent, popup, ZR_POPUP_DYNAMIC, flags, body, scrollbar); zr_popup_close(popup); popup->flags &= ~(zr_flags)ZR_WINDOW_MINIMIZED; parent->flags &= ~(zr_flags)ZR_WINDOW_ROM; @@ -7925,14 +7929,14 @@ zr_popup_nonblocking_begin(struct zr_context *parent, static void zr_popup_nonblocking_end(struct zr_context *parent, - struct zr_context *popup) + struct zr_context *popup, struct zr_vec2 *scrollbar) { ZR_ASSERT(parent); ZR_ASSERT(popup); if (!parent || !popup) return; if (!parent->valid) return; if (!(popup->flags & ZR_WINDOW_MINIMIZED)) - zr_popup_end(parent, popup); + zr_popup_end(parent, popup, scrollbar); } void @@ -7943,7 +7947,7 @@ zr_contextual_begin(struct zr_context *parent, struct zr_context *popup, ZR_ASSERT(popup); ZR_ASSERT(active); if (!parent || !popup || !active) return; - zr_popup_nonblocking_begin(parent, popup, flags, active, *active, body); + zr_popup_nonblocking_begin(parent, popup, flags, active, *active, body, zr_vec2(0,0)); } static zr_bool @@ -8066,19 +8070,24 @@ zr_contextual_close(struct zr_context *popup) popup->flags |= ZR_WINDOW_HIDDEN; } -zr_state -zr_contextual_end(struct zr_context *parent, struct zr_context *menu) +void +zr_contextual_end(struct zr_context *parent, struct zr_context *menu, zr_state *state) { ZR_ASSERT(parent); ZR_ASSERT(menu); - if (!parent || !menu) return zr_false; - if (!parent->valid) return zr_false; + if (!parent || !menu) + goto failed; + if (!parent->valid) + goto failed; if ((!parent->valid) || (!menu->valid && !(menu->flags & ZR_WINDOW_HIDDEN))) - return zr_false; - zr_popup_nonblocking_end(parent, menu); + goto failed; + zr_popup_nonblocking_end(parent, menu, 0); if (menu->flags & ZR_WINDOW_HIDDEN) - return zr_false; - return zr_true; + goto failed; + if (state) *state = zr_true; + return; +failed: + if (state) *state = zr_false; } /* * ------------------------------------------------------------- @@ -8170,7 +8179,7 @@ zr_combo_begin(struct zr_context *parent, struct zr_context *combo, body.y = header.y + header.h; body.h = zr_null_rect.h; if (!zr_popup_nonblocking_begin(parent, combo, ZR_WINDOW_NO_SCROLLBAR, - active, is_active, body)) goto failed; + active, is_active, body, zr_vec2(0,0))) goto failed; combo->flags |= ZR_WINDOW_COMBO_MENU; } return; @@ -8195,8 +8204,8 @@ zr_bool zr_combo_item_symbol(struct zr_context *menu, enum zr_symbol symbol, const char *title, enum zr_text_align align) {return zr_contextual_item_symbol(menu, symbol, title, align);} -zr_state zr_combo_end(struct zr_context *parent, struct zr_context *menu) -{return zr_contextual_end(parent, menu);} +void zr_combo_end(struct zr_context *parent, struct zr_context *menu, zr_state *state) +{zr_contextual_end(parent, menu, state);} void zr_combo_close(struct zr_context *combo) {zr_contextual_close(combo);} @@ -8253,7 +8262,7 @@ zr_menu_begin(struct zr_context *parent, struct zr_context *menu, body.y = header.y + header.h; body.h = (parent->bounds.y + parent->bounds.h) - body.y; if (!zr_popup_nonblocking_begin(parent, menu, ZR_WINDOW_NO_SCROLLBAR, active, - is_active, body)) goto failed; + is_active, body, zr_vec2(0,0))) goto failed; menu->flags |= ZR_WINDOW_COMBO_MENU; } return; @@ -8288,7 +8297,7 @@ zr_menu_end(struct zr_context *parent, struct zr_context *menu) ZR_ASSERT(menu); if (!parent || !menu) return; if (!parent->valid) return; - zr_popup_nonblocking_end(parent, menu); + zr_popup_nonblocking_end(parent, menu, 0); } /* * ------------------------------------------------------------- @@ -8308,11 +8317,10 @@ zr_tooltip_begin(struct zr_context *parent, struct zr_context *tip, zr_float wid return; in = parent->input; - bounds.w = width; bounds.h = zr_null_rect.h; - bounds.x = in->mouse.pos.x - parent->clip.x; - bounds.y = in->mouse.pos.y - parent->clip.y; + bounds.x = (in->mouse.pos.x + 1) - parent->clip.x; + bounds.y = (in->mouse.pos.y + 1) - parent->clip.y; zr_popup_begin(parent, tip, ZR_POPUP_DYNAMIC, ZR_WINDOW_NO_SCROLLBAR, bounds, zr_vec2(0,0)); } @@ -8320,7 +8328,7 @@ void zr_tooltip_end(struct zr_context *parent, struct zr_context *tip) { zr_popup_close(tip); - zr_popup_end(parent, tip); + zr_popup_end(parent, tip, 0); } void diff --git a/zahnrad.h b/zahnrad.h index 1b78222..937457e 100644 --- a/zahnrad.h +++ b/zahnrad.h @@ -2448,16 +2448,14 @@ struct zr_color zr_style_color(const struct zr_style*, enum zr_style_colors); Output: - color value that has been asked for */ -void zr_style_push_property(struct zr_style*, enum zr_style_properties, - struct zr_vec2); +void zr_style_push_property(struct zr_style*, enum zr_style_properties, struct zr_vec2); /* this function temporarily changes a property in a stack to be reseted later Input: - Configuration structure to push the change to - Property idenfifier to change - new value of the property */ -void zr_style_push_color(struct zr_style*, enum zr_style_colors, - struct zr_color); +void zr_style_push_color(struct zr_style*, enum zr_style_colors, struct zr_color); /* this function temporarily changes a color in a stack like fashion to be reseted later Input: - Configuration structure to push the change to @@ -2743,9 +2741,9 @@ struct zr_window { /* input state for updating the window and all its widgets */ }; -void zr_window_init(struct zr_window*, struct zr_rect bounds, - zr_flags flags, struct zr_command_queue*, - const struct zr_style*, const struct zr_input *in); +void zr_window_init(struct zr_window*, struct zr_rect bounds, zr_flags flags, + struct zr_command_queue*, const struct zr_style*, + const struct zr_input *in); /* this function initilizes and setups the window Input: - bounds of the window with x,y position and width and height @@ -2995,8 +2993,8 @@ enum zr_header_align { /* header elements are added at the right side of the header */ }; -zr_flags zr_header(struct zr_context*, const char *title, - zr_flags show, zr_flags notify, enum zr_header_align); +zr_flags zr_header(struct zr_context*, const char *title, zr_flags show, + zr_flags notify, enum zr_header_align); /* this function is a shorthand for the header build up process flag by the user Input: @@ -3137,8 +3135,7 @@ void zr_layout_row_static(struct zr_context*, zr_float row_height, - number of widget inside the row that will divide the space */ /* ------------------------------ Custom ----------------------------------- */ -void zr_layout_row_begin(struct zr_context*, - enum zr_layout_format, +void zr_layout_row_begin(struct zr_context*, enum zr_layout_format, zr_float row_height, zr_size cols); /* this function start a new scaleable row that can be filled with different sized widget @@ -3155,8 +3152,8 @@ void zr_layout_row_push(struct zr_context*, zr_float value); */ void zr_layout_row_end(struct zr_context*); /* this function ends the previously started scaleable row */ -void zr_layout_row(struct zr_context*, enum zr_layout_format, - zr_float height, zr_size cols, const zr_float *ratio); +void zr_layout_row(struct zr_context*, enum zr_layout_format, zr_float height, + zr_size cols, const zr_float *ratio); /* this function sets the row layout as an array of ratios/width for every widget that will be inserted into that row Input: @@ -3166,8 +3163,7 @@ void zr_layout_row(struct zr_context*, enum zr_layout_format, - window ratio/pixel width array for each widget */ /* ------------------------------ User ----------------------------------- */ -void zr_layout_row_space_begin(struct zr_context*, - enum zr_layout_format, +void zr_layout_row_space_begin(struct zr_context*, enum zr_layout_format, zr_float height, zr_size widget_count); /* this functions starts a space where widgets can be added at any given position and the user has to make sure no overlap occures @@ -3311,8 +3307,7 @@ void zr_spacing(struct zr_context*, zr_size cols); */ void zr_seperator(struct zr_context*); /* this function creates a seperator line */ -void zr_text(struct zr_context*, const char*, zr_size, - enum zr_text_align); +void zr_text(struct zr_context*, const char*, zr_size, enum zr_text_align); /* this function creates a bounded non terminated text widget with either left, centered or right alignment Input: @@ -3320,8 +3315,8 @@ void zr_text(struct zr_context*, const char*, zr_size, - number of bytes the text is long - text alignment with either left, centered or right alignment */ -void zr_text_colored(struct zr_context*, const char*, zr_size, - enum zr_text_align, struct zr_color); +void zr_text_colored(struct zr_context*, const char*, zr_size, enum zr_text_align, + struct zr_color); /* this function creates a bounded non terminated color text widget with either left, centered or right alignment Input: @@ -3337,8 +3332,7 @@ void zr_label(struct zr_context*, const char*, enum zr_text_align); - string pointer to text that should be drawn - text alignment with either left, centered or right alignment */ -void zr_label_colored(struct zr_context*, const char*, - enum zr_text_align, struct zr_color); +void zr_label_colored(struct zr_context*, const char*, enum zr_text_align, struct zr_color); /* this function creates a zero terminated colored text widget with either left, centered or right alignment Input: @@ -3367,8 +3361,7 @@ zr_bool zr_option(struct zr_context*, const char*, zr_bool active); Output: - from user input updated state of the radiobutton */ -zr_size zr_option_group(struct zr_context*, const char**, - zr_size cnt, zr_size cur); +zr_size zr_option_group(struct zr_context*, const char**, zr_size cnt, zr_size cur); /* this function creates a radiobutton group widget with only one active radiobutton Input: - radiobutton label array describing the content of each radiobutton @@ -3377,8 +3370,7 @@ zr_size zr_option_group(struct zr_context*, const char**, Output: - the from user input updated index of the active radiobutton */ -zr_bool zr_button_text(struct zr_context*, const char*, - enum zr_button_behavior); +zr_bool zr_button_text(struct zr_context*, const char*, enum zr_button_behavior); /* this function creates a text button Input: - button label describing the button @@ -3388,8 +3380,7 @@ zr_bool zr_button_text(struct zr_context*, const char*, - zr_true if the button was transistioned from unpressed to pressed with default button behavior or pressed if repeater behavior. */ -zr_bool zr_button_color(struct zr_context*, struct zr_color, - enum zr_button_behavior); +zr_bool zr_button_color(struct zr_context*, struct zr_color, enum zr_button_behavior); /* this function creates a colored button without content Input: - color the button should be drawn with @@ -3407,8 +3398,7 @@ zr_bool zr_button_symbol(struct zr_context*, enum zr_symbol, enum zr_button_beha - zr_true if the button was transistioned from unpressed to pressed with default button behavior or pressed if repeater behavior. */ -zr_bool zr_button_image(struct zr_context*, struct zr_image img, - enum zr_button_behavior); +zr_bool zr_button_image(struct zr_context*, struct zr_image img, enum zr_button_behavior); /* this function creates a button with an icon as content Input: - icon image handle to draw into the button @@ -3417,9 +3407,8 @@ zr_bool zr_button_image(struct zr_context*, struct zr_image img, - zr_true if the button was transistioned from unpressed to pressed with default button behavior or pressed if repeater behavior. */ -zr_bool zr_button_text_symbol(struct zr_context*, enum zr_symbol, - const char*, enum zr_text_align, - enum zr_button_behavior); +zr_bool zr_button_text_symbol(struct zr_context*, enum zr_symbol, const char*, + enum zr_text_align, enum zr_button_behavior); /* this function creates a button with a triangle and text Input: - symbol to draw with the text @@ -3431,8 +3420,8 @@ zr_bool zr_button_text_symbol(struct zr_context*, enum zr_symbol, default button behavior or pressed if repeater behavior. */ zr_bool zr_button_text_image(struct zr_context *layout, struct zr_image img, - const char *text, enum zr_text_align align, - enum zr_button_behavior behavior); + const char *text, enum zr_text_align align, + enum zr_button_behavior behavior); /* this function creates a button with an icon and text Input: - image or subimage to use as an icon @@ -3459,8 +3448,8 @@ zr_bool zr_button_toggle_fitting(struct zr_context*, const char*,zr_bool value); Output: - from user input updated toggle state */ -zr_float zr_slider(struct zr_context*, zr_float min, zr_float val, - zr_float max, zr_float step); +zr_float zr_slider(struct zr_context*, zr_float min, zr_float val, zr_float max, + zr_float step); /* this function creates a slider for value manipulation Input: - minimal slider value that will not be underflown @@ -3470,8 +3459,7 @@ zr_float zr_slider(struct zr_context*, zr_float min, zr_float val, Output: - the from user input updated slider value */ -zr_size zr_progress(struct zr_context*, zr_size cur, zr_size max, - zr_bool modifyable); +zr_size zr_progress(struct zr_context*, zr_size cur, zr_size max, zr_bool modifyable); /* this function creates an either user or program controlled progressbar Input: - current progressbar value @@ -3482,9 +3470,8 @@ zr_size zr_progress(struct zr_context*, zr_size cur, zr_size max, */ void zr_editbox(struct zr_context*, struct zr_edit_box*); /* this function creates an editbox with copy & paste functionality and text buffering */ -zr_size zr_edit(struct zr_context*, zr_char *buffer, zr_size len, - zr_size max, zr_state *active, zr_size *cursor, - enum zr_input_filter); +zr_size zr_edit(struct zr_context*, zr_char *buffer, zr_size len, zr_size max, + zr_state *active, zr_size *cursor, enum zr_input_filter); /* this function creates an editbox to updated/insert user text input Input: - buffer to fill with user input @@ -3496,9 +3483,8 @@ zr_size zr_edit(struct zr_context*, zr_char *buffer, zr_size len, - length of the buffer after user input update - current state of the editbox with active(zr_true) or inactive(zr_false) */ -zr_size zr_edit_filtered(struct zr_context*, zr_char *buffer, - zr_size len, zr_size max, zr_state *active, - zr_size *cursor, zr_filter); +zr_size zr_edit_filtered(struct zr_context*, zr_char *buffer, zr_size len, + zr_size max, zr_state *active, zr_size *cursor, zr_filter); /* this function creates an editbox to updated/insert filtered user text input Input: - buffer to fill with user input @@ -3510,8 +3496,8 @@ zr_size zr_edit_filtered(struct zr_context*, zr_char *buffer, - length of the buffer after user input update - current state of the editbox with active(zr_true) or inactive(zr_false) */ -zr_int zr_spinner(struct zr_context*, zr_int min, zr_int value, - zr_int max, zr_int step, zr_state *active); +zr_int zr_spinner(struct zr_context*, zr_int min, zr_int value, zr_int max, + zr_int step, zr_state *active); /* this function creates a integer spinner widget Input: - min value that will not be underflown @@ -3546,9 +3532,8 @@ zr_int zr_spinner(struct zr_context*, zr_int min, zr_int value, zr_combo_close -- closes the previously opened combo box zr_combo_end -- ends the combo box build up process */ -void zr_combo_begin(struct zr_context *parent, - struct zr_context *combo, const char *selected, - zr_state *active); +void zr_combo_begin(struct zr_context *parent, struct zr_context *combo, + const char *selected, zr_state *active); /* this function begins the combobox build up process Input: - parent window layout the combo box will be placed into @@ -3586,7 +3571,7 @@ zr_bool zr_combo_item_symbol(struct zr_context *menu, enum zr_symbol symbol, */ void zr_combo_close(struct zr_context *combo); /* this function closes a opened combobox */ -zr_state zr_combo_end(struct zr_context *parent, struct zr_context *combo); +void zr_combo_end(struct zr_context *parent, struct zr_context *combo, zr_state*); /* this function ends the combobox build up process */ /* -------------------------------------------------------------- * GRAPH @@ -3763,7 +3748,7 @@ enum zr_tree_node_operation zr_tree_leaf_icon(struct zr_tree*, Output: - operation identifier what should be done with this node */ -struct zr_vec2 zr_tree_end(struct zr_context*, struct zr_tree*); +void zr_tree_end(struct zr_context*, struct zr_tree*, struct zr_vec2 *scrollbar); /* this function ends a the tree building process */ /* -------------------------------------------------------------- * POPUP @@ -3816,8 +3801,8 @@ zr_flags zr_popup_begin(struct zr_context *parent, struct zr_context *popup, */ void zr_popup_close(struct zr_context *popup); /* this functions closes a previously opened popup */ -struct zr_vec2 zr_popup_end(struct zr_context *parent, - struct zr_context *popup); +void zr_popup_end(struct zr_context *parent, struct zr_context *popup, + struct zr_vec2 *scrollbar); /* this function finishes the previously started popup layout Output: - The from user input updated popup scrollbar pixel offset @@ -3887,7 +3872,7 @@ void zr_contextual_close(struct zr_context *popup); Output: - update state of the context menu */ -zr_state zr_contextual_end(struct zr_context *parent, struct zr_context *popup); +void zr_contextual_end(struct zr_context *parent, struct zr_context *popup, zr_state*); /* this functions closes a previously opened context menu */ /*---------------------------------------------------------------- * MENU @@ -3936,7 +3921,7 @@ zr_bool zr_menu_item_icon(struct zr_context *menu, struct zr_image, - `zr_true` if has been clicked `zr_false` otherwise */ zr_bool zr_menu_item_symbol(struct zr_context *menu, enum zr_symbol symbol, - const char*, enum zr_text_align align); + const char*, enum zr_text_align align); /* this function execute menu text symbol item Input: - symbol to draw into the menu item @@ -4009,7 +3994,7 @@ void zr_group_begin(struct zr_context*, struct zr_context *tab, Output: - group layout to fill with widgets */ -struct zr_vec2 zr_group_end(struct zr_context*, struct zr_context*); +void zr_group_end(struct zr_context*, struct zr_context*, struct zr_vec2 *scrollbar); /* this function finishes the previously started group layout Output: - The from user input updated group scrollbar pixel offset @@ -4044,7 +4029,7 @@ zr_size zr_shelf_begin(struct zr_context*, struct zr_context*, - group layout to fill with widgets - the from user input updated current shelf tab index */ -struct zr_vec2 zr_shelf_end(struct zr_context*, struct zr_context*); +void zr_shelf_end(struct zr_context *p, struct zr_context *s, struct zr_vec2 *scrollbar); /* this function finishes the previously started shelf layout Input: - previously started group layout