diff --git a/demo/demo.c b/demo/demo.c index 3a89869..75f573e 100644 --- a/demo/demo.c +++ b/demo/demo.c @@ -54,6 +54,16 @@ struct icons { struct zr_image font_file; struct zr_image img_file; struct zr_image movie_file; + + struct zr_image button; + struct zr_image button_hover; + struct zr_image check; + struct zr_image check_cursor; + struct zr_image close; + struct zr_image combo; + struct zr_image slider_cursor; + struct zr_image header; + struct zr_image window; }; enum theme {THEME_BLACK, THEME_WHITE, THEME_RED, THEME_BLUE, THEME_DARK}; @@ -2393,6 +2403,147 @@ node_editor_init(struct node_editor *editor) * CONTROL WINDOW * * ===============================================================*/ +static void +set_style(struct zr_context *ctx, enum theme theme) +{ + struct zr_color table[ZR_COLOR_COUNT]; + if (theme == THEME_WHITE) { + table[ZR_COLOR_TEXT] = zr_rgba(70, 70, 70, 255); + table[ZR_COLOR_WINDOW] = zr_rgba(175, 175, 175, 255); + table[ZR_COLOR_HEADER] = zr_rgba(175, 175, 175, 255); + table[ZR_COLOR_BORDER] = zr_rgba(0, 0, 0, 255); + table[ZR_COLOR_BUTTON] = zr_rgba(185, 185, 185, 255); + table[ZR_COLOR_BUTTON_HOVER] = zr_rgba(170, 170, 170, 255); + table[ZR_COLOR_BUTTON_ACTIVE] = zr_rgba(160, 160, 160, 255); + table[ZR_COLOR_TOGGLE] = zr_rgba(150, 150, 150, 255); + table[ZR_COLOR_TOGGLE_HOVER] = zr_rgba(120, 120, 120, 255); + table[ZR_COLOR_TOGGLE_CURSOR] = zr_rgba(175, 175, 175, 255); + table[ZR_COLOR_SELECTABLE] = zr_rgba(190, 190, 190, 255); + table[ZR_COLOR_SELECTABLE_HOVER] = zr_rgba(150, 150, 150, 255); + table[ZR_COLOR_SELECTABLE_TEXT] = zr_rgba(70, 70, 70, 255); + table[ZR_COLOR_SLIDER] = zr_rgba(190, 190, 190, 255); + table[ZR_COLOR_SLIDER_CURSOR] = zr_rgba(80, 80, 80, 255); + table[ZR_COLOR_SLIDER_CURSOR_HOVER] = zr_rgba(70, 70, 70, 255); + table[ZR_COLOR_SLIDER_CURSOR_ACTIVE] = zr_rgba(60, 60, 60, 255); + table[ZR_COLOR_PROPERTY] = zr_rgba(175, 175, 175, 255); + table[ZR_COLOR_PROPERTY_HOVER] = zr_rgba(160, 160, 160, 255); + table[ZR_COLOR_PROPERTY_ACTIVE] = zr_rgba(165, 165, 165, 255); + table[ZR_COLOR_EDIT] = zr_rgba(150, 150, 150, 255); + table[ZR_COLOR_EDIT_CURSOR] = zr_rgba(0, 0, 0, 255); + table[ZR_COLOR_COMBO] = zr_rgba(175, 175, 175, 255); + table[ZR_COLOR_CHART] = zr_rgba(160, 160, 160, 255); + table[ZR_COLOR_CHART_COLOR] = zr_rgba(45, 45, 45, 255); + table[ZR_COLOR_CHART_COLOR_HIGHLIGHT] = zr_rgba( 255, 0, 0, 255); + table[ZR_COLOR_SCROLLBAR] = zr_rgba(180, 180, 180, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR] = zr_rgba(140, 140, 140, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR_HOVER] = zr_rgba(150, 150, 150, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR_ACTIVE] = zr_rgba(160, 160, 160, 255); + table[ZR_COLOR_TAB_HEADER] = zr_rgba(180, 180, 180, 255); + zr_style_from_table(ctx, table); + } else if (theme == THEME_RED) { + table[ZR_COLOR_TEXT] = zr_rgba(190, 190, 190, 255); + table[ZR_COLOR_WINDOW] = zr_rgba(30, 33, 40, 215); + table[ZR_COLOR_HEADER] = zr_rgba(181, 45, 69, 220); + table[ZR_COLOR_BORDER] = zr_rgba(51, 55, 67, 255); + table[ZR_COLOR_BUTTON] = zr_rgba(181, 45, 69, 255); + table[ZR_COLOR_BUTTON_HOVER] = zr_rgba(190, 50, 70, 255); + table[ZR_COLOR_BUTTON_ACTIVE] = zr_rgba(195, 55, 75, 255); + table[ZR_COLOR_TOGGLE] = zr_rgba(51, 55, 67, 255); + table[ZR_COLOR_TOGGLE_HOVER] = zr_rgba(45, 60, 60, 255); + table[ZR_COLOR_TOGGLE_CURSOR] = zr_rgba(181, 45, 69, 255); + table[ZR_COLOR_SELECTABLE] = zr_rgba(181, 45, 69, 255); + table[ZR_COLOR_SELECTABLE_HOVER] = zr_rgba(181, 45, 69, 255); + table[ZR_COLOR_SELECTABLE_TEXT] = zr_rgba(190, 190, 190, 255); + table[ZR_COLOR_SLIDER] = zr_rgba(51, 55, 67, 255); + table[ZR_COLOR_SLIDER_CURSOR] = zr_rgba(181, 45, 69, 255); + table[ZR_COLOR_SLIDER_CURSOR_HOVER] = zr_rgba(186, 50, 74, 255); + table[ZR_COLOR_SLIDER_CURSOR_ACTIVE] = zr_rgba(191, 55, 79, 255); + table[ZR_COLOR_PROPERTY] = zr_rgba(51, 55, 67, 255); + table[ZR_COLOR_PROPERTY_HOVER] = zr_rgba(55, 60, 72, 255); + table[ZR_COLOR_PROPERTY_ACTIVE] = zr_rgba(60, 65, 77, 255); + table[ZR_COLOR_EDIT] = zr_rgba(51, 55, 67, 225); + table[ZR_COLOR_EDIT_CURSOR] = zr_rgba(190, 190, 190, 255); + table[ZR_COLOR_COMBO] = zr_rgba(51, 55, 67, 255); + table[ZR_COLOR_CHART] = zr_rgba(51, 55, 67, 255); + table[ZR_COLOR_CHART_COLOR] = zr_rgba(170, 40, 60, 255); + table[ZR_COLOR_CHART_COLOR_HIGHLIGHT] = zr_rgba( 255, 0, 0, 255); + table[ZR_COLOR_SCROLLBAR] = zr_rgba(30, 33, 40, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR] = zr_rgba(64, 84, 95, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR_HOVER] = zr_rgba(70, 90, 100, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR_ACTIVE] = zr_rgba(75, 95, 105, 255); + table[ZR_COLOR_TAB_HEADER] = zr_rgba(181, 45, 69, 220); + zr_style_from_table(ctx, table); + } else if (theme == THEME_BLUE) { + table[ZR_COLOR_TEXT] = zr_rgba(20, 20, 20, 255); + table[ZR_COLOR_WINDOW] = zr_rgba(202, 212, 214, 215); + table[ZR_COLOR_HEADER] = zr_rgba(137, 182, 224, 220); + table[ZR_COLOR_BORDER] = zr_rgba(140, 159, 173, 255); + table[ZR_COLOR_BUTTON] = zr_rgba(137, 182, 224, 255); + table[ZR_COLOR_BUTTON_HOVER] = zr_rgba(142, 187, 229, 255); + table[ZR_COLOR_BUTTON_ACTIVE] = zr_rgba(147, 192, 234, 255); + table[ZR_COLOR_TOGGLE] = zr_rgba(177, 210, 210, 255); + table[ZR_COLOR_TOGGLE_HOVER] = zr_rgba(182, 215, 215, 255); + table[ZR_COLOR_TOGGLE_CURSOR] = zr_rgba(137, 182, 224, 255); + table[ZR_COLOR_SELECTABLE] = zr_rgba(147, 192, 234, 255); + table[ZR_COLOR_SELECTABLE_HOVER] = zr_rgba(150, 150, 150, 255); + table[ZR_COLOR_SELECTABLE_TEXT] = zr_rgba(70, 70, 70, 255); + table[ZR_COLOR_SLIDER] = zr_rgba(177, 210, 210, 255); + table[ZR_COLOR_SLIDER_CURSOR] = zr_rgba(137, 182, 224, 245); + table[ZR_COLOR_SLIDER_CURSOR_HOVER] = zr_rgba(142, 188, 229, 255); + table[ZR_COLOR_SLIDER_CURSOR_ACTIVE] = zr_rgba(147, 193, 234, 255); + table[ZR_COLOR_PROPERTY] = zr_rgba(210, 210, 210, 255); + table[ZR_COLOR_PROPERTY_HOVER] = zr_rgba(235, 235, 235, 255); + table[ZR_COLOR_PROPERTY_ACTIVE] = zr_rgba(230, 230, 230, 255); + table[ZR_COLOR_EDIT] = zr_rgba(210, 210, 210, 225); + table[ZR_COLOR_EDIT_CURSOR] = zr_rgba(20, 20, 20, 255); + table[ZR_COLOR_COMBO] = zr_rgba(210, 210, 210, 255); + table[ZR_COLOR_CHART] = zr_rgba(210, 210, 210, 255); + table[ZR_COLOR_CHART_COLOR] = zr_rgba(137, 182, 224, 255); + table[ZR_COLOR_CHART_COLOR_HIGHLIGHT] = zr_rgba( 255, 0, 0, 255); + table[ZR_COLOR_SCROLLBAR] = zr_rgba(190, 200, 200, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR] = zr_rgba(64, 84, 95, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR_HOVER] = zr_rgba(70, 90, 100, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR_ACTIVE] = zr_rgba(75, 95, 105, 255); + table[ZR_COLOR_TAB_HEADER] = zr_rgba(156, 193, 220, 255); + zr_style_from_table(ctx, table); + } else if (theme == THEME_DARK) { + table[ZR_COLOR_TEXT] = zr_rgba(210, 210, 210, 255); + table[ZR_COLOR_WINDOW] = zr_rgba(57, 67, 71, 215); + table[ZR_COLOR_HEADER] = zr_rgba(51, 51, 56, 220); + table[ZR_COLOR_BORDER] = zr_rgba(46, 46, 46, 255); + table[ZR_COLOR_BUTTON] = zr_rgba(48, 83, 111, 255); + table[ZR_COLOR_BUTTON_HOVER] = zr_rgba(58, 93, 121, 255); + table[ZR_COLOR_BUTTON_ACTIVE] = zr_rgba(63, 98, 126, 255); + table[ZR_COLOR_TOGGLE] = zr_rgba(50, 58, 61, 255); + table[ZR_COLOR_TOGGLE_HOVER] = zr_rgba(45, 53, 56, 255); + table[ZR_COLOR_TOGGLE_CURSOR] = zr_rgba(48, 83, 111, 255); + table[ZR_COLOR_SELECTABLE] = zr_rgba(48, 83, 111, 255); + table[ZR_COLOR_SELECTABLE_HOVER] = zr_rgba(48, 83, 111, 255); + table[ZR_COLOR_SELECTABLE_TEXT] = zr_rgba(210, 210, 210, 255); + table[ZR_COLOR_SLIDER] = zr_rgba(50, 58, 61, 255); + table[ZR_COLOR_SLIDER_CURSOR] = zr_rgba(48, 83, 111, 245); + table[ZR_COLOR_SLIDER_CURSOR_HOVER] = zr_rgba(53, 88, 116, 255); + table[ZR_COLOR_SLIDER_CURSOR_ACTIVE] = zr_rgba(58, 93, 121, 255); + table[ZR_COLOR_PROPERTY] = zr_rgba(50, 58, 61, 255); + table[ZR_COLOR_PROPERTY_HOVER] = zr_rgba(55, 63, 66, 255); + table[ZR_COLOR_PROPERTY_ACTIVE] = zr_rgba(60, 68, 71, 255); + table[ZR_COLOR_EDIT] = zr_rgba(50, 58, 61, 225); + table[ZR_COLOR_EDIT_CURSOR] = zr_rgba(210, 210, 210, 255); + table[ZR_COLOR_COMBO] = zr_rgba(50, 58, 61, 255); + table[ZR_COLOR_CHART] = zr_rgba(50, 58, 61, 255); + table[ZR_COLOR_CHART_COLOR] = zr_rgba(48, 83, 111, 255); + table[ZR_COLOR_CHART_COLOR_HIGHLIGHT] = zr_rgba(255, 0, 0, 255); + table[ZR_COLOR_SCROLLBAR] = zr_rgba(50, 58, 61, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR] = zr_rgba(48, 83, 111, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR_HOVER] = zr_rgba(53, 88, 116, 255); + table[ZR_COLOR_SCROLLBAR_CURSOR_ACTIVE] = zr_rgba(58, 93, 121, 255); + table[ZR_COLOR_TAB_HEADER] = zr_rgba(48, 83, 111, 255); + zr_style_from_table(ctx, table); + } else { + zr_style_default(ctx); + } +} + static int control_window(struct zr_context *ctx, struct demo *gui) { @@ -2443,6 +2594,26 @@ control_window(struct zr_context *ctx, struct demo *gui) zr_labelf(ctx, ZR_TEXT_LEFT, "%lu", gui->status.calls); zr_layout_pop(ctx); } + if (zr_layout_push(ctx, ZR_LAYOUT_TAB, "Color", ZR_MINIMIZED)) + { + struct zr_panel tab, combo; + enum theme old = gui->theme; + static const char *themes[] = {"Black", "White", "Red", "Blue", "Dark", "Grey"}; + + zr_layout_row_dynamic(ctx, 25, 2); + zr_label(ctx, "THEME:", ZR_TEXT_LEFT); + if (zr_combo_begin_label(ctx, &combo, themes[gui->theme], 300)) { + zr_layout_row_dynamic(ctx, 25, 1); + gui->theme = zr_combo_item_label(ctx, themes[THEME_BLACK], ZR_TEXT_CENTERED) ? THEME_BLACK : gui->theme; + gui->theme = zr_combo_item_label(ctx, themes[THEME_WHITE], ZR_TEXT_CENTERED) ? THEME_WHITE : gui->theme; + gui->theme = zr_combo_item_label(ctx, themes[THEME_RED], ZR_TEXT_CENTERED) ? THEME_RED : gui->theme; + gui->theme = zr_combo_item_label(ctx, themes[THEME_BLUE], ZR_TEXT_CENTERED) ? THEME_BLUE : gui->theme; + gui->theme = zr_combo_item_label(ctx, themes[THEME_DARK], ZR_TEXT_CENTERED) ? THEME_DARK : gui->theme; + if (old != gui->theme) set_style(ctx, gui->theme); + zr_combo_end(ctx); + } + zr_layout_pop(ctx); + } } zr_end(ctx); return !zr_window_is_closed(ctx, "Control"); @@ -2483,7 +2654,6 @@ run_demo(struct demo *gui) #endif } - ctx->style.font.height = 14; ret = control_window(ctx, gui); if (gui->show_demo) demo_window(gui, ctx); diff --git a/demo/sdl/sdl.c b/demo/sdl/sdl.c index 43bae65..0673d03 100644 --- a/demo/sdl/sdl.c +++ b/demo/sdl/sdl.c @@ -435,8 +435,8 @@ main(int argc, char *argv[]) zr_font_atlas_init_default(&atlas); zr_font_atlas_begin(&atlas); - if (font_path) font = zr_font_atlas_add_from_file(&atlas, font_path, 14.0f, NULL); - else font = zr_font_atlas_add_default(&atlas, 14.0f, NULL); + if (font_path) font = zr_font_atlas_add_from_file(&atlas, font_path, 30.0f, NULL); + else font = zr_font_atlas_add_default(&atlas, 30.0f, NULL); image = zr_font_atlas_bake(&atlas, &width, &height, ZR_FONT_ATLAS_RGBA32); device_upload_atlas(&device, image, width, height); zr_font_atlas_end(&atlas, zr_handle_id((int)device.font_tex), &device.null); @@ -519,7 +519,7 @@ main(int argc, char *argv[]) /* Draw */ glClear(GL_COLOR_BUFFER_BIT); - glClearColor(0.3f, 0.3f, 0.3f, 1.0f); + glClearColor(1.0f, 0.647f, 0.0f, 1.0f); device_draw(&device, &gui.ctx, win_width, win_height, ZR_ANTI_ALIASING_ON); SDL_GL_SwapWindow(win); } diff --git a/zahnrad.c b/zahnrad.c index 9c73d07..6b74c0f 100644 --- a/zahnrad.c +++ b/zahnrad.c @@ -1508,7 +1508,7 @@ zr_utf_len(const char *str, zr_size len) return glyphs; } -static const char* +const char* zr_utf_at(const char *buffer, zr_size length, int index, zr_rune *unicode, zr_size *len) { @@ -1828,7 +1828,7 @@ zr_buffer_alloc(struct zr_buffer *b, enum zr_buffer_allocation_type type, return memory; } -static void +void zr_buffer_push(struct zr_buffer *b, enum zr_buffer_allocation_type type, void *memory, zr_size size, zr_size align) { @@ -1837,7 +1837,7 @@ zr_buffer_push(struct zr_buffer *b, enum zr_buffer_allocation_type type, zr_memcopy(mem, memory, size); } -static void +void zr_buffer_mark(struct zr_buffer *buffer, enum zr_buffer_allocation_type type) { ZR_ASSERT(buffer); @@ -1848,7 +1848,7 @@ zr_buffer_mark(struct zr_buffer *buffer, enum zr_buffer_allocation_type type) else buffer->marker[type].offset = buffer->allocated; } -static void +void zr_buffer_reset(struct zr_buffer *buffer, enum zr_buffer_allocation_type type) { ZR_ASSERT(buffer); @@ -1870,7 +1870,7 @@ zr_buffer_reset(struct zr_buffer *buffer, enum zr_buffer_allocation_type type) } } -static void +void zr_buffer_clear(struct zr_buffer *b) { ZR_ASSERT(b); @@ -2408,15 +2408,8 @@ zr_draw_text(struct zr_command_buffer *b, struct zr_rect r, * * ===============================================================*/ #if ZR_COMPILE_WITH_VERTEX_BUFFER -enum zr_draw_list_stroke { - ZR_STROKE_OPEN = zr_false, - /* build up path has no connection back to the beginning */ - ZR_STROKE_CLOSED = zr_true - /* build up path has a connection back to the beginning */ -}; - -static void -zr_canvas_init(struct zr_canvas *list) +void +zr_draw_list_init(struct zr_draw_list *list) { zr_size i = 0; zr_zero(list, sizeof(*list)); @@ -2427,8 +2420,65 @@ zr_canvas_init(struct zr_canvas *list) } } -static void -zr_canvas_clear(struct zr_canvas *list) +void +zr_draw_list_setup(struct zr_draw_list *canvas, float global_alpha, + enum zr_anti_aliasing line_AA, enum zr_anti_aliasing shape_AA, + struct zr_draw_null_texture null, struct zr_buffer *cmds, + struct zr_buffer *vertices, struct zr_buffer *elements) +{ + canvas->null = null; + canvas->clip_rect = zr_null_rect; + canvas->vertices = vertices; + canvas->elements = elements; + canvas->buffer = cmds; + canvas->line_AA = line_AA; + canvas->shape_AA = shape_AA; + canvas->global_alpha = global_alpha; +} + +const struct zr_draw_command* +zr__draw_list_begin(const struct zr_draw_list *canvas, const struct zr_buffer *buffer) +{ + zr_byte *memory; + zr_size offset; + const struct zr_draw_command *cmd; + + ZR_ASSERT(buffer); + if (!buffer || !buffer->size || !canvas->cmd_count) + return 0; + + memory = (zr_byte*)buffer->memory.ptr; + offset = buffer->memory.size - canvas->cmd_offset; + cmd = zr_ptr_add(const struct zr_draw_command, memory, offset); + return cmd; +} + +const struct zr_draw_command* +zr__draw_list_next(const struct zr_draw_command *cmd, + const struct zr_buffer *buffer, const struct zr_draw_list *canvas) +{ + zr_byte *memory; + zr_size size; + zr_size offset; + const struct zr_draw_command *end; + + ZR_ASSERT(buffer); + ZR_ASSERT(canvas); + if (!cmd || !buffer || !canvas) + return 0; + + memory = (zr_byte*)buffer->memory.ptr; + size = buffer->memory.size; + offset = size - canvas->cmd_offset; + end = zr_ptr_add(const struct zr_draw_command, memory, offset); + end -= (canvas->cmd_count-1); + + if (cmd <= end) return 0; + return (cmd-1); +} + +void +zr_draw_list_clear(struct zr_draw_list *list) { ZR_ASSERT(list); if (!list) return; @@ -2450,7 +2500,7 @@ zr_canvas_clear(struct zr_canvas *list) } static struct zr_vec2* -zr_canvas_alloc_path(struct zr_canvas *list, zr_size count) +zr_draw_list_alloc_path(struct zr_draw_list *list, zr_size count) { struct zr_vec2 *points; static const zr_size point_align = ZR_ALIGNOF(struct zr_vec2); @@ -2469,7 +2519,7 @@ zr_canvas_alloc_path(struct zr_canvas *list, zr_size count) } static struct zr_vec2 -zr_canvas_path_last(struct zr_canvas *list) +zr_draw_list_path_last(struct zr_draw_list *list) { void *memory; struct zr_vec2 *point; @@ -2481,7 +2531,7 @@ zr_canvas_path_last(struct zr_canvas *list) } static struct zr_draw_command* -zr_canvas_push_command(struct zr_canvas *list, struct zr_rect clip, +zr_draw_list_push_command(struct zr_draw_list *list, struct zr_rect clip, zr_handle texture) { static const zr_size cmd_align = ZR_ALIGNOF(struct zr_draw_command); @@ -2510,7 +2560,7 @@ zr_canvas_push_command(struct zr_canvas *list, struct zr_rect clip, } static struct zr_draw_command* -zr_canvas_command_last(struct zr_canvas *list) +zr_draw_list_command_last(struct zr_draw_list *list) { void *memory; zr_size size; @@ -2524,54 +2574,54 @@ zr_canvas_command_last(struct zr_canvas *list) } static void -zr_canvas_add_clip(struct zr_canvas *list, struct zr_rect rect) +zr_draw_list_add_clip(struct zr_draw_list *list, struct zr_rect rect) { ZR_ASSERT(list); if (!list) return; if (!list->cmd_count) { - zr_canvas_push_command(list, rect, list->null.texture); + zr_draw_list_push_command(list, rect, list->null.texture); } else { - struct zr_draw_command *prev = zr_canvas_command_last(list); + struct zr_draw_command *prev = zr_draw_list_command_last(list); if (prev->elem_count == 0) prev->clip_rect = rect; - zr_canvas_push_command(list, rect, prev->texture); + zr_draw_list_push_command(list, rect, prev->texture); } } static void -zr_canvas_push_image(struct zr_canvas *list, zr_handle texture) +zr_draw_list_push_image(struct zr_draw_list *list, zr_handle texture) { ZR_ASSERT(list); if (!list) return; if (!list->cmd_count) { - zr_canvas_push_command(list, zr_null_rect, list->null.texture); + zr_draw_list_push_command(list, zr_null_rect, list->null.texture); } else { - struct zr_draw_command *prev = zr_canvas_command_last(list); + struct zr_draw_command *prev = zr_draw_list_command_last(list); if (prev->elem_count == 0) prev->texture = texture; else if (prev->texture.id != texture.id) - zr_canvas_push_command(list, prev->clip_rect, texture); + zr_draw_list_push_command(list, prev->clip_rect, texture); } } #if ZR_COMPILE_WITH_COMMAND_USERDATA -static void -zr_canvas_push_userdata(struct zr_canvas *list, zr_handle userdata) +void +zr_draw_list_push_userdata(struct zr_draw_list *list, zr_handle userdata) { ZR_ASSERT(list); if (!list) return; if (!list->cmd_count) { struct zr_draw_command *prev; - zr_canvas_push_command(list, zr_null_rect, list->null.texture); - prev = zr_canvas_command_last(list); + zr_draw_list_push_command(list, zr_null_rect, list->null.texture); + prev = zr_draw_list_command_last(list); prev->userdata = userdata; } else { - struct zr_draw_command *prev = zr_canvas_command_last(list); + struct zr_draw_command *prev = zr_draw_list_command_last(list); if (prev->elem_count == 0) { prev->userdata = userdata; } else if (prev->userdata.ptr != userdata.ptr) { - zr_canvas_push_command(list, prev->clip_rect, prev->texture); - prev = zr_canvas_command_last(list); + zr_draw_list_push_command(list, prev->clip_rect, prev->texture); + prev = zr_draw_list_command_last(list); prev->userdata = userdata; } } @@ -2579,7 +2629,7 @@ zr_canvas_push_userdata(struct zr_canvas *list, zr_handle userdata) #endif static struct zr_draw_vertex* -zr_canvas_alloc_vertices(struct zr_canvas *list, zr_size count) +zr_draw_list_alloc_vertices(struct zr_draw_list *list, zr_size count) { struct zr_draw_vertex *vtx; static const zr_size vtx_align = ZR_ALIGNOF(struct zr_draw_vertex); @@ -2595,7 +2645,7 @@ zr_canvas_alloc_vertices(struct zr_canvas *list, zr_size count) } static zr_draw_index* -zr_canvas_alloc_elements(struct zr_canvas *list, zr_size count) +zr_draw_list_alloc_elements(struct zr_draw_list *list, zr_size count) { zr_draw_index *ids; struct zr_draw_command *cmd; @@ -2607,7 +2657,7 @@ zr_canvas_alloc_elements(struct zr_canvas *list, zr_size count) ids = (zr_draw_index*) zr_buffer_alloc(list->elements, ZR_BUFFER_FRONT, elem_size*count, elem_align); if (!ids) return 0; - cmd = zr_canvas_command_last(list); + cmd = zr_draw_list_command_last(list); list->element_count += (unsigned int)count; cmd->elem_count += (unsigned int)count; return ids; @@ -2623,9 +2673,9 @@ zr_draw_vertex(struct zr_vec2 pos, struct zr_vec2 uv, zr_draw_vertex_color col) return out; } -static void -zr_canvas_add_poly_line(struct zr_canvas *list, struct zr_vec2 *points, - const unsigned int points_count, struct zr_color color, int closed, +void +zr_draw_list_stroke_poly_line(struct zr_draw_list *list, const struct zr_vec2 *points, + const unsigned int points_count, struct zr_color color, enum zr_draw_list_stroke closed, float thickness, enum zr_anti_aliasing aliasing) { zr_size count; @@ -2641,7 +2691,7 @@ zr_canvas_add_poly_line(struct zr_canvas *list, struct zr_vec2 *points, thick_line = thickness > 1.0f; #if ZR_COMPILE_WITH_COMMAND_USERDATA - zr_canvas_push_userdata(list, list->userdata); + zr_draw_list_push_userdata(list, list->userdata); #endif if (aliasing == ZR_ANTI_ALIASING_ON) { @@ -2656,8 +2706,8 @@ zr_canvas_add_poly_line(struct zr_canvas *list, struct zr_vec2 *points, zr_size index = list->vertex_count; const zr_size idx_count = (thick_line) ? (count * 18) : (count * 12); const zr_size vtx_count = (thick_line) ? (points_count * 4): (points_count *3); - struct zr_draw_vertex *vtx = zr_canvas_alloc_vertices(list, vtx_count); - zr_draw_index *ids = zr_canvas_alloc_elements(list, idx_count); + struct zr_draw_vertex *vtx = zr_draw_list_alloc_vertices(list, vtx_count); + zr_draw_index *ids = zr_draw_list_alloc_elements(list, idx_count); zr_size size; struct zr_vec2 *normals, *temp; @@ -2818,8 +2868,8 @@ zr_canvas_add_poly_line(struct zr_canvas *list, struct zr_vec2 *points, zr_size idx = list->vertex_count; const zr_size idx_count = count * 6; const zr_size vtx_count = count * 4; - struct zr_draw_vertex *vtx = zr_canvas_alloc_vertices(list, vtx_count); - zr_draw_index *ids = zr_canvas_alloc_elements(list, idx_count); + struct zr_draw_vertex *vtx = zr_draw_list_alloc_vertices(list, vtx_count); + zr_draw_index *ids = zr_draw_list_alloc_elements(list, idx_count); if (!vtx || !ids) return; for (i1 = 0; i1 < count; ++i1) { @@ -2857,10 +2907,10 @@ zr_canvas_add_poly_line(struct zr_canvas *list, struct zr_vec2 *points, } } -static void -zr_canvas_add_poly_convex(struct zr_canvas *list, struct zr_vec2 *points, - const unsigned int points_count, struct zr_color color, - enum zr_anti_aliasing aliasing) +void +zr_draw_list_fill_poly_convex(struct zr_draw_list *list, + const struct zr_vec2 *points, const unsigned int points_count, + struct zr_color color, enum zr_anti_aliasing aliasing) { static const zr_size pnt_align = ZR_ALIGNOF(struct zr_vec2); static const zr_size pnt_size = sizeof(struct zr_vec2); @@ -2869,7 +2919,7 @@ zr_canvas_add_poly_convex(struct zr_canvas *list, struct zr_vec2 *points, if (!list || points_count < 3) return; #if ZR_COMPILE_WITH_COMMAND_USERDATA - zr_canvas_push_userdata(list, list->userdata); + zr_draw_list_push_userdata(list, list->userdata); #endif color.a = (zr_byte)((float)color.a * list->global_alpha); @@ -2884,8 +2934,8 @@ zr_canvas_add_poly_convex(struct zr_canvas *list, struct zr_vec2 *points, zr_size index = list->vertex_count; const zr_size idx_count = (points_count-2)*3 + points_count*6; const zr_size vtx_count = (points_count*2); - struct zr_draw_vertex *vtx = zr_canvas_alloc_vertices(list, vtx_count); - zr_draw_index *ids = zr_canvas_alloc_elements(list, idx_count); + struct zr_draw_vertex *vtx = zr_draw_list_alloc_vertices(list, vtx_count); + zr_draw_index *ids = zr_draw_list_alloc_elements(list, idx_count); unsigned int vtx_inner_idx = (unsigned int)(index + 0); unsigned int vtx_outer_idx = (unsigned int)(index + 1); @@ -2961,8 +3011,8 @@ zr_canvas_add_poly_convex(struct zr_canvas *list, struct zr_vec2 *points, zr_size index = list->vertex_count; const zr_size idx_count = (points_count-2)*3; const zr_size vtx_count = points_count; - struct zr_draw_vertex *vtx = zr_canvas_alloc_vertices(list, vtx_count); - zr_draw_index *ids = zr_canvas_alloc_elements(list, idx_count); + struct zr_draw_vertex *vtx = zr_draw_list_alloc_vertices(list, vtx_count); + zr_draw_index *ids = zr_draw_list_alloc_elements(list, idx_count); if (!vtx || !ids) return; for (i = 0; i < vtx_count; ++i) { vtx[0] = zr_draw_vertex(points[i], list->null.uv, col); @@ -2977,8 +3027,8 @@ zr_canvas_add_poly_convex(struct zr_canvas *list, struct zr_vec2 *points, } } -static void -zr_canvas_path_clear(struct zr_canvas *list) +void +zr_draw_list_path_clear(struct zr_draw_list *list) { ZR_ASSERT(list); if (!list) return; @@ -2987,27 +3037,27 @@ zr_canvas_path_clear(struct zr_canvas *list) list->path_offset = 0; } -static void -zr_canvas_path_line_to(struct zr_canvas *list, struct zr_vec2 pos) +void +zr_draw_list_path_line_to(struct zr_draw_list *list, struct zr_vec2 pos) { struct zr_vec2 *points = 0; struct zr_draw_command *cmd = 0; ZR_ASSERT(list); if (!list) return; if (!list->cmd_count) - zr_canvas_add_clip(list, zr_null_rect); + zr_draw_list_add_clip(list, zr_null_rect); - cmd = zr_canvas_command_last(list); + cmd = zr_draw_list_command_last(list); if (cmd && cmd->texture.ptr != list->null.texture.ptr) - zr_canvas_push_image(list, list->null.texture); + zr_draw_list_push_image(list, list->null.texture); - points = zr_canvas_alloc_path(list, 1); + points = zr_draw_list_alloc_path(list, 1); if (!points) return; points[0] = pos; } -static void -zr_canvas_path_arc_to_fast(struct zr_canvas *list, struct zr_vec2 center, +void +zr_draw_list_path_arc_to_fast(struct zr_draw_list *list, struct zr_vec2 center, float radius, int a_min, int a_max) { ZR_ASSERT(list); @@ -3018,13 +3068,13 @@ zr_canvas_path_arc_to_fast(struct zr_canvas *list, struct zr_vec2 center, const struct zr_vec2 c = list->circle_vtx[(zr_size)a % ZR_LEN(list->circle_vtx)]; const float x = center.x + c.x * radius; const float y = center.y + c.y * radius; - zr_canvas_path_line_to(list, zr_vec2(x, y)); + zr_draw_list_path_line_to(list, zr_vec2(x, y)); } } } -static void -zr_canvas_path_arc_to(struct zr_canvas *list, struct zr_vec2 center, +void +zr_draw_list_path_arc_to(struct zr_draw_list *list, struct zr_vec2 center, float radius, float a_min, float a_max, unsigned int segments) { unsigned int i = 0; @@ -3035,12 +3085,12 @@ zr_canvas_path_arc_to(struct zr_canvas *list, struct zr_vec2 center, const float a = a_min + ((float)i / ((float)segments) * (a_max - a_min)); const float x = center.x + (float)zr_cos(a) * radius; const float y = center.y + (float)zr_sin(a) * radius; - zr_canvas_path_line_to(list, zr_vec2(x, y)); + zr_draw_list_path_line_to(list, zr_vec2(x, y)); } } -static void -zr_canvas_path_rect_to(struct zr_canvas *list, struct zr_vec2 a, +void +zr_draw_list_path_rect_to(struct zr_draw_list *list, struct zr_vec2 a, struct zr_vec2 b, float rounding) { float r; @@ -3051,20 +3101,20 @@ zr_canvas_path_rect_to(struct zr_canvas *list, struct zr_vec2 a, r = ZR_MIN(r, ((b.y-a.y) < 0) ? -(b.y-a.y): (b.y-a.y)); if (r == 0.0f) { - zr_canvas_path_line_to(list, a); - zr_canvas_path_line_to(list, zr_vec2(b.x,a.y)); - zr_canvas_path_line_to(list, b); - zr_canvas_path_line_to(list, zr_vec2(a.x,b.y)); + zr_draw_list_path_line_to(list, a); + zr_draw_list_path_line_to(list, zr_vec2(b.x,a.y)); + zr_draw_list_path_line_to(list, b); + zr_draw_list_path_line_to(list, zr_vec2(a.x,b.y)); } else { - zr_canvas_path_arc_to_fast(list, zr_vec2(a.x + r, a.y + r), r, 6, 9); - zr_canvas_path_arc_to_fast(list, zr_vec2(b.x - r, a.y + r), r, 9, 12); - zr_canvas_path_arc_to_fast(list, zr_vec2(b.x - r, b.y - r), r, 0, 3); - zr_canvas_path_arc_to_fast(list, zr_vec2(a.x + r, b.y - r), r, 3, 6); + zr_draw_list_path_arc_to_fast(list, zr_vec2(a.x + r, a.y + r), r, 6, 9); + zr_draw_list_path_arc_to_fast(list, zr_vec2(b.x - r, a.y + r), r, 9, 12); + zr_draw_list_path_arc_to_fast(list, zr_vec2(b.x - r, b.y - r), r, 0, 3); + zr_draw_list_path_arc_to_fast(list, zr_vec2(a.x + r, b.y - r), r, 3, 6); } } -static void -zr_canvas_path_curve_to(struct zr_canvas *list, struct zr_vec2 p2, +void +zr_draw_list_path_curve_to(struct zr_draw_list *list, struct zr_vec2 p2, struct zr_vec2 p3, struct zr_vec2 p4, unsigned int num_segments) { unsigned int i_step; @@ -3076,7 +3126,7 @@ zr_canvas_path_curve_to(struct zr_canvas *list, struct zr_vec2 p2, if (!list || !list->path_count) return; num_segments = ZR_MAX(num_segments, 1); - p1 = zr_canvas_path_last(list); + p1 = zr_draw_list_path_last(list); t_step = 1.0f/(float)num_segments; for (i_step = 1; i_step <= num_segments; ++i_step) { float t = t_step * (float)i_step; @@ -3087,69 +3137,69 @@ zr_canvas_path_curve_to(struct zr_canvas *list, struct zr_vec2 p2, float w4 = t * t *t; float x = w1 * p1.x + w2 * p2.x + w3 * p3.x + w4 * p4.x; float y = w1 * p1.y + w2 * p2.y + w3 * p3.y + w4 * p4.y; - zr_canvas_path_line_to(list, zr_vec2(x,y)); + zr_draw_list_path_line_to(list, zr_vec2(x,y)); } } -static void -zr_canvas_path_fill(struct zr_canvas *list, struct zr_color color) +void +zr_draw_list_path_fill(struct zr_draw_list *list, struct zr_color color) { struct zr_vec2 *points; ZR_ASSERT(list); if (!list) return; points = (struct zr_vec2*)zr_buffer_memory(list->buffer); - zr_canvas_add_poly_convex(list, points, list->path_count, color, list->shape_AA); - zr_canvas_path_clear(list); + zr_draw_list_fill_poly_convex(list, points, list->path_count, color, list->shape_AA); + zr_draw_list_path_clear(list); } -static void -zr_canvas_path_stroke(struct zr_canvas *list, struct zr_color color, - int closed, float thickness) +void +zr_draw_list_path_stroke(struct zr_draw_list *list, struct zr_color color, + enum zr_draw_list_stroke closed, float thickness) { struct zr_vec2 *points; ZR_ASSERT(list); if (!list) return; points = (struct zr_vec2*)zr_buffer_memory(list->buffer); - zr_canvas_add_poly_line(list, points, list->path_count, color, + zr_draw_list_stroke_poly_line(list, points, list->path_count, color, closed, thickness, list->line_AA); - zr_canvas_path_clear(list); + zr_draw_list_path_clear(list); } -static void -zr_canvas_stroke_line(struct zr_canvas *list, struct zr_vec2 a, +void +zr_draw_list_stroke_line(struct zr_draw_list *list, struct zr_vec2 a, struct zr_vec2 b, struct zr_color col, float thickness) { ZR_ASSERT(list); if (!list || !col.a) return; - zr_canvas_path_line_to(list, zr_vec2_add(a, zr_vec2(0.5f, 0.5f))); - zr_canvas_path_line_to(list, zr_vec2_add(b, zr_vec2(0.5f, 0.5f))); - zr_canvas_path_stroke(list, col, ZR_STROKE_OPEN, thickness); + zr_draw_list_path_line_to(list, zr_vec2_add(a, zr_vec2(0.5f, 0.5f))); + zr_draw_list_path_line_to(list, zr_vec2_add(b, zr_vec2(0.5f, 0.5f))); + zr_draw_list_path_stroke(list, col, ZR_STROKE_OPEN, thickness); } -static void -zr_canvas_fill_rect(struct zr_canvas *list, struct zr_rect rect, +void +zr_draw_list_fill_rect(struct zr_draw_list *list, struct zr_rect rect, struct zr_color col, float rounding) { ZR_ASSERT(list); if (!list || !col.a) return; - zr_canvas_path_rect_to(list, zr_vec2(rect.x + 0.5f, rect.y + 0.5f), + zr_draw_list_path_rect_to(list, zr_vec2(rect.x + 0.5f, rect.y + 0.5f), zr_vec2(rect.x + rect.w + 0.5f, rect.y + rect.h + 0.5f), rounding); - zr_canvas_path_fill(list, col); + zr_draw_list_path_fill(list, col); } -static void -zr_canvas_stroke_rect(struct zr_canvas *list, struct zr_rect rect, +void +zr_draw_list_stroke_rect(struct zr_draw_list *list, struct zr_rect rect, struct zr_color col, float rounding, float thickness) { ZR_ASSERT(list); if (!list || !col.a) return; - zr_canvas_path_rect_to(list, zr_vec2(rect.x + 0.5f, rect.y + 0.5f), + zr_draw_list_path_rect_to(list, zr_vec2(rect.x + 0.5f, rect.y + 0.5f), zr_vec2(rect.x + rect.w + 0.5f, rect.y + rect.h + 0.5f), rounding); - zr_canvas_path_stroke(list, col, ZR_STROKE_CLOSED, thickness); + zr_draw_list_path_stroke(list, col, ZR_STROKE_CLOSED, thickness); } -static void -zr_canvas_add_rect_multi_color(struct zr_canvas *list, struct zr_rect rect, +void +zr_draw_list_fill_rect_multi_color(struct zr_draw_list *list, struct zr_rect rect, struct zr_color left, struct zr_color top, struct zr_color right, struct zr_color bottom) { @@ -3164,10 +3214,10 @@ zr_canvas_add_rect_multi_color(struct zr_canvas *list, struct zr_rect rect, ZR_ASSERT(list); if (!list) return; - zr_canvas_push_image(list, list->null.texture); + zr_draw_list_push_image(list, list->null.texture); index = (zr_draw_index)list->vertex_count; - vtx = zr_canvas_alloc_vertices(list, 4); - idx = zr_canvas_alloc_elements(list, 6); + vtx = zr_draw_list_alloc_vertices(list, 4); + idx = zr_draw_list_alloc_elements(list, 6); if (!vtx || !idx) return; idx[0] = (zr_draw_index)(index+0); idx[1] = (zr_draw_index)(index+1); @@ -3180,68 +3230,68 @@ zr_canvas_add_rect_multi_color(struct zr_canvas *list, struct zr_rect rect, vtx[3] = zr_draw_vertex(zr_vec2(rect.x, rect.y + rect.h), list->null.uv, col_bottom); } -static void -zr_canvas_fill_triangle(struct zr_canvas *list, struct zr_vec2 a, +void +zr_draw_list_fill_triangle(struct zr_draw_list *list, struct zr_vec2 a, struct zr_vec2 b, struct zr_vec2 c, struct zr_color col) { ZR_ASSERT(list); if (!list || !col.a) return; - zr_canvas_path_line_to(list, a); - zr_canvas_path_line_to(list, b); - zr_canvas_path_line_to(list, c); - zr_canvas_path_fill(list, col); + zr_draw_list_path_line_to(list, a); + zr_draw_list_path_line_to(list, b); + zr_draw_list_path_line_to(list, c); + zr_draw_list_path_fill(list, col); } -static void -zr_canvas_stroke_triangle(struct zr_canvas *list, struct zr_vec2 a, +void +zr_draw_list_stroke_triangle(struct zr_draw_list *list, struct zr_vec2 a, struct zr_vec2 b, struct zr_vec2 c, struct zr_color col, float thickness) { ZR_ASSERT(list); if (!list || !col.a) return; - zr_canvas_path_line_to(list, a); - zr_canvas_path_line_to(list, b); - zr_canvas_path_line_to(list, c); - zr_canvas_path_stroke(list, col, ZR_STROKE_CLOSED, thickness); + zr_draw_list_path_line_to(list, a); + zr_draw_list_path_line_to(list, b); + zr_draw_list_path_line_to(list, c); + zr_draw_list_path_stroke(list, col, ZR_STROKE_CLOSED, thickness); } -static void -zr_canvas_fill_circle(struct zr_canvas *list, struct zr_vec2 center, +void +zr_draw_list_fill_circle(struct zr_draw_list *list, struct zr_vec2 center, float radius, struct zr_color col, unsigned int segs) { float a_max; ZR_ASSERT(list); if (!list || !col.a) return; a_max = ZR_PI * 2.0f * ((float)segs - 1.0f) / (float)segs; - zr_canvas_path_arc_to(list, center, radius, 0.0f, a_max, segs); - zr_canvas_path_fill(list, col); + zr_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs); + zr_draw_list_path_fill(list, col); } -static void -zr_canvas_stroke_circle(struct zr_canvas *list, struct zr_vec2 center, +void +zr_draw_list_stroke_circle(struct zr_draw_list *list, struct zr_vec2 center, float radius, struct zr_color col, unsigned int segs, float thickness) { float a_max; ZR_ASSERT(list); if (!list || !col.a) return; a_max = ZR_PI * 2.0f * ((float)segs - 1.0f) / (float)segs; - zr_canvas_path_arc_to(list, center, radius, 0.0f, a_max, segs); - zr_canvas_path_stroke(list, col, ZR_STROKE_CLOSED, thickness); + zr_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs); + zr_draw_list_path_stroke(list, col, ZR_STROKE_CLOSED, thickness); } -static void -zr_canvas_add_curve(struct zr_canvas *list, struct zr_vec2 p0, +void +zr_draw_list_stroke_curve(struct zr_draw_list *list, struct zr_vec2 p0, struct zr_vec2 cp0, struct zr_vec2 cp1, struct zr_vec2 p1, struct zr_color col, unsigned int segments, float thickness) { ZR_ASSERT(list); if (!list || !col.a) return; - zr_canvas_path_line_to(list, p0); - zr_canvas_path_curve_to(list, cp0, cp1, p1, segments); - zr_canvas_path_stroke(list, col, ZR_STROKE_OPEN, thickness); + zr_draw_list_path_line_to(list, p0); + zr_draw_list_path_curve_to(list, cp0, cp1, p1, segments); + zr_draw_list_path_stroke(list, col, ZR_STROKE_OPEN, thickness); } static void -zr_canvas_push_rect_uv(struct zr_canvas *list, struct zr_vec2 a, +zr_draw_list_push_rect_uv(struct zr_draw_list *list, struct zr_vec2 a, struct zr_vec2 c, struct zr_vec2 uva, struct zr_vec2 uvc, struct zr_color color) { @@ -3262,8 +3312,8 @@ zr_canvas_push_rect_uv(struct zr_canvas *list, struct zr_vec2 a, d = zr_vec2(a.x, c.y); index = (zr_draw_index)list->vertex_count; - vtx = zr_canvas_alloc_vertices(list, 4); - idx = zr_canvas_alloc_elements(list, 6); + vtx = zr_draw_list_alloc_vertices(list, 4); + idx = zr_draw_list_alloc_elements(list, 6); if (!vtx || !idx) return; idx[0] = (zr_draw_index)(index+0); idx[1] = (zr_draw_index)(index+1); @@ -3276,14 +3326,14 @@ zr_canvas_push_rect_uv(struct zr_canvas *list, struct zr_vec2 a, vtx[3] = zr_draw_vertex(d, uvd, col); } -static void -zr_canvas_add_image(struct zr_canvas *list, struct zr_image texture, +void +zr_draw_list_add_image(struct zr_draw_list *list, struct zr_image texture, struct zr_rect rect, struct zr_color color) { ZR_ASSERT(list); if (!list) return; /* push new command with given texture */ - zr_canvas_push_image(list, texture.handle); + zr_draw_list_push_image(list, texture.handle); if (zr_image_is_subimage(&texture)) { /* add region inside of the texture */ struct zr_vec2 uv[2]; @@ -3291,15 +3341,15 @@ zr_canvas_add_image(struct zr_canvas *list, struct zr_image texture, uv[0].y = (float)texture.region[1]/(float)texture.h; uv[1].x = (float)(texture.region[0] + texture.region[2])/(float)texture.w; uv[1].y = (float)(texture.region[1] + texture.region[3])/(float)texture.h; - zr_canvas_push_rect_uv(list, zr_vec2(rect.x, rect.y), + zr_draw_list_push_rect_uv(list, zr_vec2(rect.x, rect.y), zr_vec2(rect.x + rect.w, rect.y + rect.h), uv[0], uv[1], color); - } else zr_canvas_push_rect_uv(list, zr_vec2(rect.x, rect.y), + } else zr_draw_list_push_rect_uv(list, zr_vec2(rect.x, rect.y), zr_vec2(rect.x + rect.w, rect.y + rect.h), zr_vec2(0.0f, 0.0f), zr_vec2(1.0f, 1.0f),color); } -static void -zr_canvas_add_text(struct zr_canvas *list, const struct zr_user_font *font, +void +zr_draw_list_add_text(struct zr_draw_list *list, const struct zr_user_font *font, struct zr_rect rect, const char *text, zr_size len, float font_height, struct zr_color fg) { @@ -3318,7 +3368,7 @@ zr_canvas_add_text(struct zr_canvas *list, const struct zr_user_font *font, rect.x < list->clip_rect.x || rect.y < list->clip_rect.y) return; - zr_canvas_push_image(list, font->texture); + zr_draw_list_push_image(list, font->texture); x = rect.x; glyph_len = text_len = zr_utf_decode(text, &unicode, len); if (!glyph_len) return; @@ -3341,7 +3391,7 @@ zr_canvas_add_text(struct zr_canvas *list, const struct zr_user_font *font, gw = g.width; gh = g.height; char_width = g.xadvance; fg.a = (zr_byte)((float)fg.a * list->global_alpha); - zr_canvas_push_rect_uv(list, zr_vec2(gx,gy), zr_vec2(gx + gw, gy+ gh), + zr_draw_list_push_rect_uv(list, zr_vec2(gx,gy), zr_vec2(gx + gw, gy+ gh), g.uv[0], g.uv[1], fg); /* offset next glyph */ @@ -3365,15 +3415,8 @@ zr_convert(struct zr_context *ctx, struct zr_buffer *cmds, if (!ctx || !cmds || !vertices || !elements) return; - ctx->canvas.null = config->null; - ctx->canvas.clip_rect = zr_null_rect; - ctx->canvas.vertices = vertices; - ctx->canvas.elements = elements; - ctx->canvas.buffer = cmds; - ctx->canvas.line_AA = config->line_AA; - ctx->canvas.shape_AA = config->shape_AA; - ctx->canvas.global_alpha = config->global_alpha; - + zr_draw_list_setup(&ctx->draw_list, config->global_alpha, config->line_AA, + config->shape_AA, config->null, cmds, vertices, elements); zr_foreach(cmd, ctx) { #if ZR_COMPILE_WITH_COMMAND_USERDATA @@ -3383,70 +3426,70 @@ zr_convert(struct zr_context *ctx, struct zr_buffer *cmds, case ZR_COMMAND_NOP: break; case ZR_COMMAND_SCISSOR: { const struct zr_command_scissor *s = zr_command(scissor, cmd); - zr_canvas_add_clip(&ctx->canvas, zr_rect(s->x, s->y, s->w, s->h)); + zr_draw_list_add_clip(&ctx->draw_list, zr_rect(s->x, s->y, s->w, s->h)); } break; case ZR_COMMAND_LINE: { const struct zr_command_line *l = zr_command(line, cmd); - zr_canvas_stroke_line(&ctx->canvas, zr_vec2(l->begin.x, l->begin.y), + zr_draw_list_stroke_line(&ctx->draw_list, zr_vec2(l->begin.x, l->begin.y), zr_vec2(l->end.x, l->end.y), l->color, l->line_thickness); } break; case ZR_COMMAND_CURVE: { const struct zr_command_curve *q = zr_command(curve, cmd); - zr_canvas_add_curve(&ctx->canvas, zr_vec2(q->begin.x, q->begin.y), + zr_draw_list_stroke_curve(&ctx->draw_list, zr_vec2(q->begin.x, q->begin.y), zr_vec2(q->ctrl[0].x, q->ctrl[0].y), zr_vec2(q->ctrl[1].x, q->ctrl[1].y), zr_vec2(q->end.x, q->end.y), q->color, config->curve_segment_count, q->line_thickness); } break; case ZR_COMMAND_RECT: { const struct zr_command_rect *r = zr_command(rect, cmd); - zr_canvas_stroke_rect(&ctx->canvas, zr_rect(r->x, r->y, r->w, r->h), + zr_draw_list_stroke_rect(&ctx->draw_list, zr_rect(r->x, r->y, r->w, r->h), r->color, (float)r->rounding, r->line_thickness); } break; case ZR_COMMAND_RECT_FILLED: { const struct zr_command_rect_filled *r = zr_command(rect_filled, cmd); - zr_canvas_fill_rect(&ctx->canvas, zr_rect(r->x, r->y, r->w, r->h), + zr_draw_list_fill_rect(&ctx->draw_list, zr_rect(r->x, r->y, r->w, r->h), r->color, (float)r->rounding); } break; case ZR_COMMAND_RECT_MULTI_COLOR: { const struct zr_command_rect_multi_color *r = zr_command(rect_multi_color, cmd); - zr_canvas_add_rect_multi_color(&ctx->canvas, zr_rect(r->x, r->y, r->w, r->h), + zr_draw_list_fill_rect_multi_color(&ctx->draw_list, zr_rect(r->x, r->y, r->w, r->h), r->left, r->top, r->right, r->bottom); } break; case ZR_COMMAND_CIRCLE: { const struct zr_command_circle *c = zr_command(circle, cmd); - zr_canvas_stroke_circle(&ctx->canvas, zr_vec2((float)c->x + (float)c->w/2, + zr_draw_list_stroke_circle(&ctx->draw_list, zr_vec2((float)c->x + (float)c->w/2, (float)c->y + (float)c->h/2), (float)c->w/2, c->color, config->circle_segment_count, c->line_thickness); } break; case ZR_COMMAND_CIRCLE_FILLED: { const struct zr_command_circle_filled *c = zr_command(circle_filled, cmd); - zr_canvas_fill_circle(&ctx->canvas, zr_vec2((float)c->x + (float)c->w/2, + zr_draw_list_fill_circle(&ctx->draw_list, zr_vec2((float)c->x + (float)c->w/2, (float)c->y + (float)c->h/2), (float)c->w/2, c->color, config->circle_segment_count); } break; case ZR_COMMAND_ARC: { const struct zr_command_arc *c = zr_command(arc, cmd); - zr_canvas_path_line_to(&ctx->canvas, zr_vec2(c->cx, c->cy)); - zr_canvas_path_arc_to(&ctx->canvas, zr_vec2(c->cx, c->cy), c->r, + zr_draw_list_path_line_to(&ctx->draw_list, zr_vec2(c->cx, c->cy)); + zr_draw_list_path_arc_to(&ctx->draw_list, zr_vec2(c->cx, c->cy), c->r, c->a[0], c->a[1], config->arc_segment_count); - zr_canvas_path_stroke(&ctx->canvas, c->color, ZR_STROKE_CLOSED, c->line_thickness); + zr_draw_list_path_stroke(&ctx->draw_list, c->color, ZR_STROKE_CLOSED, c->line_thickness); } break; case ZR_COMMAND_ARC_FILLED: { const struct zr_command_arc_filled *c = zr_command(arc_filled, cmd); - zr_canvas_path_line_to(&ctx->canvas, zr_vec2(c->cx, c->cy)); - zr_canvas_path_arc_to(&ctx->canvas, zr_vec2(c->cx, c->cy), c->r, + zr_draw_list_path_line_to(&ctx->draw_list, zr_vec2(c->cx, c->cy)); + zr_draw_list_path_arc_to(&ctx->draw_list, zr_vec2(c->cx, c->cy), c->r, c->a[0], c->a[1], config->arc_segment_count); - zr_canvas_path_fill(&ctx->canvas, c->color); + zr_draw_list_path_fill(&ctx->draw_list, c->color); } break; case ZR_COMMAND_TRIANGLE: { const struct zr_command_triangle *t = zr_command(triangle, cmd); - zr_canvas_stroke_triangle(&ctx->canvas, zr_vec2(t->a.x, t->a.y), + zr_draw_list_stroke_triangle(&ctx->draw_list, zr_vec2(t->a.x, t->a.y), zr_vec2(t->b.x, t->b.y), zr_vec2(t->c.x, t->c.y), t->color, t->line_thickness); } break; case ZR_COMMAND_TRIANGLE_FILLED: { const struct zr_command_triangle_filled *t = zr_command(triangle_filled, cmd); - zr_canvas_fill_triangle(&ctx->canvas, zr_vec2(t->a.x, t->a.y), + zr_draw_list_fill_triangle(&ctx->draw_list, zr_vec2(t->a.x, t->a.y), zr_vec2(t->b.x, t->b.y), zr_vec2(t->c.x, t->c.y), t->color); } break; case ZR_COMMAND_POLYGON: { @@ -3454,36 +3497,36 @@ zr_convert(struct zr_context *ctx, struct zr_buffer *cmds, const struct zr_command_polygon*p = zr_command(polygon, cmd); for (i = 0; i < p->point_count; ++i) { struct zr_vec2 pnt = zr_vec2((float)p->points[i].x, (float)p->points[i].y); - zr_canvas_path_line_to(&ctx->canvas, pnt); + zr_draw_list_path_line_to(&ctx->draw_list, pnt); } - zr_canvas_path_stroke(&ctx->canvas, p->color, ZR_STROKE_CLOSED, p->line_thickness); + zr_draw_list_path_stroke(&ctx->draw_list, p->color, ZR_STROKE_CLOSED, p->line_thickness); } break; case ZR_COMMAND_POLYGON_FILLED: { int i; const struct zr_command_polygon_filled *p = zr_command(polygon_filled, cmd); for (i = 0; i < p->point_count; ++i) { struct zr_vec2 pnt = zr_vec2((float)p->points[i].x, (float)p->points[i].y); - zr_canvas_path_line_to(&ctx->canvas, pnt); + zr_draw_list_path_line_to(&ctx->draw_list, pnt); } - zr_canvas_path_fill(&ctx->canvas, p->color); + zr_draw_list_path_fill(&ctx->draw_list, p->color); } break; case ZR_COMMAND_POLYLINE: { int i; const struct zr_command_polyline *p = zr_command(polyline, cmd); for (i = 0; i < p->point_count; ++i) { struct zr_vec2 pnt = zr_vec2((float)p->points[i].x, (float)p->points[i].y); - zr_canvas_path_line_to(&ctx->canvas, pnt); + zr_draw_list_path_line_to(&ctx->draw_list, pnt); } - zr_canvas_path_stroke(&ctx->canvas, p->color, ZR_STROKE_OPEN, p->line_thickness); + zr_draw_list_path_stroke(&ctx->draw_list, p->color, ZR_STROKE_OPEN, p->line_thickness); } break; case ZR_COMMAND_TEXT: { const struct zr_command_text *t = zr_command(text, cmd); - zr_canvas_add_text(&ctx->canvas, t->font, zr_rect(t->x, t->y, t->w, t->h), + zr_draw_list_add_text(&ctx->draw_list, t->font, zr_rect(t->x, t->y, t->w, t->h), t->string, t->length, t->height, t->foreground); } break; case ZR_COMMAND_IMAGE: { const struct zr_command_image *i = zr_command(image, cmd); - zr_canvas_add_image(&ctx->canvas, i->img, zr_rect(i->x, i->y, i->w, i->h), + zr_draw_list_add_image(&ctx->draw_list, i->img, zr_rect(i->x, i->y, i->w, i->h), zr_rgb(255, 255, 255)); } break; default: break; @@ -3494,44 +3537,12 @@ zr_convert(struct zr_context *ctx, struct zr_buffer *cmds, const struct zr_draw_command* zr__draw_begin(const struct zr_context *ctx, const struct zr_buffer *buffer) -{ - zr_byte *memory; - zr_size offset; - const struct zr_draw_command *cmd; - - ZR_ASSERT(buffer); - if (!buffer || !buffer->size || !ctx->canvas.cmd_count) - return 0; - - memory = (zr_byte*)buffer->memory.ptr; - offset = buffer->memory.size - ctx->canvas.cmd_offset; - cmd = zr_ptr_add(const struct zr_draw_command, memory, offset); - return cmd; -} +{return zr__draw_list_begin(&ctx->draw_list, buffer);} const struct zr_draw_command* zr__draw_next(const struct zr_draw_command *cmd, const struct zr_buffer *buffer, const struct zr_context *ctx) -{ - zr_byte *memory; - zr_size size; - zr_size offset; - const struct zr_draw_command *end; - - ZR_ASSERT(buffer); - ZR_ASSERT(ctx); - if (!cmd || !buffer || !ctx) - return 0; - - memory = (zr_byte*)buffer->memory.ptr; - size = buffer->memory.size; - offset = size - ctx->canvas.cmd_offset; - end = zr_ptr_add(const struct zr_draw_command, memory, offset); - end -= (ctx->canvas.cmd_count-1); - - if (cmd <= end) return 0; - return (cmd-1); -} +{return zr__draw_list_next(cmd, buffer, &ctx->draw_list);} #endif /* @@ -5926,7 +5937,7 @@ zr_do_button_text_symbol(zr_flags *state, ret = zr_do_button(state, out, bounds, style, in, behavior, &content); tri.y = content.y + (content.h/2) - font->height/2; tri.w = font->height; tri.h = font->height; - if (align & ZR_TEXT_LEFT) { + if (align & ZR_TEXT_ALIGN_LEFT) { tri.x = (content.x + content.w) - (2 * style->padding.x + tri.w); tri.x = ZR_MAX(tri.x, 0); } else tri.x = content.x + 2 * style->padding.x; @@ -7000,13 +7011,13 @@ zr_draw_edit(struct zr_command_buffer *out, zr_flags state, cursor = &style->cursor_hover; text = style->text_hover; selected = style->selected_hover; - sel_text = style->selected_hover; + sel_text = style->selected_text_hover; } else { background = &style->normal; cursor = &style->cursor_normal; text = style->text_normal; selected = style->selected_normal; - sel_text = style->selected_normal; + sel_text = style->selected_text_normal; } /* draw background color/image */ @@ -7030,15 +7041,14 @@ zr_draw_edit(struct zr_command_buffer *out, zr_flags state, if (box->cursor == box->glyphs) { /* draw cursor at the end of the string */ float text_width; - zr_size cursor_w = (zr_size)style->cursor_size; zr_size s = font->width(font->userdata, font->height, unselected_text, unselected_len); text_width = (float)s; if (cursor->type == ZR_STYLE_ITEM_IMAGE) zr_draw_image(out, zr_rect(label->x+(float)text_width, - label->y, (float)cursor_w, label->h), &cursor->data.image); + label->y, style->cursor_size, label->h), &cursor->data.image); else zr_fill_rect(out, zr_rect(label->x+(float)text_width, - label->y, (float)cursor_w, label->h), 0, cursor->data.color); + label->y, style->cursor_size, label->h), 0, cursor->data.color); } else { /* draw text selection */ struct zr_rect clip = out->clip; @@ -7587,6 +7597,56 @@ zr_do_color_picker(zr_flags *state, * STYLE * * ===============================================================*/ +void zr_style_default(struct zr_context *ctx){zr_style_from_table(ctx, 0);} +#define ZR_COLOR_MAP(ZR_COLOR)\ + ZR_COLOR(ZR_COLOR_TEXT, 175,175,175,255) \ + ZR_COLOR(ZR_COLOR_WINDOW, 45, 45, 45,255) \ + ZR_COLOR(ZR_COLOR_HEADER, 40, 40, 40,255) \ + ZR_COLOR(ZR_COLOR_BORDER, 65, 65, 65,255) \ + ZR_COLOR(ZR_COLOR_BUTTON, 50, 50, 50,255) \ + ZR_COLOR(ZR_COLOR_BUTTON_HOVER, 40, 40, 40,255) \ + ZR_COLOR(ZR_COLOR_BUTTON_ACTIVE, 35, 35, 35,255) \ + ZR_COLOR(ZR_COLOR_TOGGLE, 100,100,100,255) \ + ZR_COLOR(ZR_COLOR_TOGGLE_HOVER, 120,120,120,255) \ + ZR_COLOR(ZR_COLOR_TOGGLE_CURSOR, 45, 45, 45,255) \ + ZR_COLOR(ZR_COLOR_SELECTABLE, 45, 45, 45,255) \ + ZR_COLOR(ZR_COLOR_SELECTABLE_HOVER, 45, 45, 45,255) \ + ZR_COLOR(ZR_COLOR_SELECTABLE_TEXT, 175,175,175,255) \ + ZR_COLOR(ZR_COLOR_SLIDER, 38, 38, 38,255) \ + ZR_COLOR(ZR_COLOR_SLIDER_CURSOR, 100,100,100,255) \ + ZR_COLOR(ZR_COLOR_SLIDER_CURSOR_HOVER, 120,120,120,255) \ + ZR_COLOR(ZR_COLOR_SLIDER_CURSOR_ACTIVE, 150,150,150,255) \ + ZR_COLOR(ZR_COLOR_PROPERTY, 38, 38, 38,255) \ + ZR_COLOR(ZR_COLOR_PROPERTY_HOVER, 40, 40, 40,255) \ + ZR_COLOR(ZR_COLOR_PROPERTY_ACTIVE, 42, 42, 42,255) \ + ZR_COLOR(ZR_COLOR_EDIT, 38, 38, 38,255) \ + ZR_COLOR(ZR_COLOR_EDIT_CURSOR, 175,175,175,255) \ + ZR_COLOR(ZR_COLOR_COMBO, 45, 45, 45,255) \ + ZR_COLOR(ZR_COLOR_CHART, 120,120,120,255) \ + ZR_COLOR(ZR_COLOR_CHART_COLOR, 45,45,45,255) \ + ZR_COLOR(ZR_COLOR_CHART_COLOR_HIGHLIGHT,255,0,0,255) \ + ZR_COLOR(ZR_COLOR_SCROLLBAR, 40,40,40,255) \ + ZR_COLOR(ZR_COLOR_SCROLLBAR_CURSOR, 100,100,100,255) \ + ZR_COLOR(ZR_COLOR_SCROLLBAR_CURSOR_HOVER,120,120,120,255) \ + ZR_COLOR(ZR_COLOR_SCROLLBAR_CURSOR_ACTIVE, 150,150,150,255) \ + ZR_COLOR(ZR_COLOR_TAB_HEADER, 40, 40, 40,255) + +static const struct zr_color +zr_default_color_style[ZR_COLOR_COUNT] = { +#define ZR_COLOR(a,b,c,d,e) {b,c,d,e}, +ZR_COLOR_MAP(ZR_COLOR) +#undef ZR_COLOR +}; + +const char *zr_color_names[ZR_COLOR_COUNT] = { +#define ZR_COLOR(a,b,c,d,e) #a, +ZR_COLOR_MAP(ZR_COLOR) +#undef ZR_COLOR +}; + +const char *zr_style_color_name(enum zr_style_colors c) +{return zr_color_names[c];} + struct zr_style_item zr_style_item_image(struct zr_image img) {struct zr_style_item i; i.type = ZR_STYLE_ITEM_IMAGE; i.data.image = img; return i;} @@ -7597,7 +7657,7 @@ struct zr_style_item zr_style_item_hide(void) {struct zr_style_item i; i.type = ZR_STYLE_ITEM_COLOR; i.data.color = zr_rgba(0,0,0,0); return i;} void -zr_style_default(struct zr_context *ctx) +zr_style_from_table(struct zr_context *ctx, const struct zr_color *table) { struct zr_style *style; struct zr_style_text *text; @@ -7617,23 +7677,24 @@ zr_style_default(struct zr_context *ctx) ZR_ASSERT(ctx); if (!ctx) return; style = &ctx->style; + table = (!table) ? zr_default_color_style: table; /* default text */ text = &style->text; - text->color = zr_rgb(175,175,175); + text->color = table[ZR_COLOR_TEXT]; text->padding = zr_vec2(4,4); /* default button */ button = &style->button; zr_zero_struct(*button); - button->normal = zr_style_item_color(zr_rgb(50,50,50)); - button->hover = zr_style_item_color(zr_rgb(40,40,40)); - button->active = zr_style_item_color(zr_rgb(35,35,35)); - button->border_color = zr_rgb(65,65,65); - button->text_background = zr_rgb(50,50,50); - button->text_normal = zr_rgb(175, 175, 175); - button->text_hover = zr_rgb(165,165,165); - button->text_active = zr_rgb(155,155,155); + button->normal = zr_style_item_color(table[ZR_COLOR_BUTTON]); + button->hover = zr_style_item_color(table[ZR_COLOR_BUTTON_HOVER]); + button->active = zr_style_item_color(table[ZR_COLOR_BUTTON_ACTIVE]); + button->border_color = table[ZR_COLOR_BORDER]; + button->text_background = table[ZR_COLOR_BUTTON]; + button->text_normal = table[ZR_COLOR_TEXT]; + button->text_hover = table[ZR_COLOR_TEXT]; + button->text_active = table[ZR_COLOR_TEXT]; button->padding = zr_vec2(4.0f,4.0f); button->image_padding = zr_vec2(0.0f,0.0f); button->touch_padding = zr_vec2(0.0f, 0.0f); @@ -7650,14 +7711,14 @@ zr_style_default(struct zr_context *ctx) /* contextual button */ button = &style->contextual_button; zr_zero_struct(*button); - button->normal = zr_style_item_color(zr_rgb(45,45,45)); - button->hover = zr_style_item_color(zr_rgb(40,40,40)); - button->active = zr_style_item_color(zr_rgb(35,35,35)); - button->border_color = zr_rgb(45,45,45); - button->text_background = zr_rgb(45,45,45); - button->text_normal = zr_rgb(175,175,175); - button->text_hover = zr_rgb(165,165,165); - button->text_active = zr_rgb(155,155,155); + button->normal = zr_style_item_color(table[ZR_COLOR_WINDOW]); + button->hover = zr_style_item_color(table[ZR_COLOR_BUTTON_HOVER]); + button->active = zr_style_item_color(table[ZR_COLOR_BUTTON_ACTIVE]); + button->border_color = table[ZR_COLOR_WINDOW]; + button->text_background = table[ZR_COLOR_WINDOW]; + button->text_normal = table[ZR_COLOR_TEXT]; + button->text_hover = table[ZR_COLOR_TEXT]; + button->text_active = table[ZR_COLOR_TEXT]; button->padding = zr_vec2(4.0f,4.0f); button->touch_padding = zr_vec2(0.0f,0.0f); button->userdata = zr_handle_ptr(0); @@ -7673,14 +7734,14 @@ zr_style_default(struct zr_context *ctx) /* menu button */ button = &style->menu_button; zr_zero_struct(*button); - button->normal = zr_style_item_color(zr_rgb(45,45,45)); - button->hover = zr_style_item_color(zr_rgb(40,40,40)); - button->active = zr_style_item_color(zr_rgb(35,35,35)); - button->border_color = zr_rgb(65,65,65); - button->text_background = zr_rgb(40,40,40); - button->text_normal = zr_rgb(175,175,175); - button->text_hover = zr_rgb(175,175,175); - button->text_active = zr_rgb(175,175,175); + button->normal = zr_style_item_color(table[ZR_COLOR_WINDOW]); + button->hover = zr_style_item_color(table[ZR_COLOR_WINDOW]); + button->active = zr_style_item_color(table[ZR_COLOR_WINDOW]); + button->border_color = table[ZR_COLOR_WINDOW]; + button->text_background = table[ZR_COLOR_WINDOW]; + button->text_normal = table[ZR_COLOR_TEXT]; + button->text_hover = table[ZR_COLOR_TEXT]; + button->text_active = table[ZR_COLOR_TEXT]; button->padding = zr_vec2(4.0f,4.0f); button->touch_padding = zr_vec2(0.0f,0.0f); button->userdata = zr_handle_ptr(0); @@ -7696,16 +7757,16 @@ zr_style_default(struct zr_context *ctx) /* checkbox toggle */ toggle = &style->checkbox; zr_zero_struct(*toggle); - toggle->normal = zr_style_item_color(zr_rgb(100,100,100)); - toggle->hover = zr_style_item_color(zr_rgb(120,120,120)); - toggle->active = zr_style_item_color(zr_rgb(100,100,100)); - toggle->cursor_normal = zr_style_item_color(zr_rgb(45,45,45)); - toggle->cursor_hover = zr_style_item_color(zr_rgb(45,45,45)); + toggle->normal = zr_style_item_color(table[ZR_COLOR_TOGGLE]); + toggle->hover = zr_style_item_color(table[ZR_COLOR_TOGGLE_HOVER]); + toggle->active = zr_style_item_color(table[ZR_COLOR_TOGGLE_HOVER]); + toggle->cursor_normal = zr_style_item_color(table[ZR_COLOR_TOGGLE_CURSOR]); + toggle->cursor_hover = zr_style_item_color(table[ZR_COLOR_TOGGLE_CURSOR]); toggle->userdata = zr_handle_ptr(0); - toggle->text_background = zr_rgb(45,45,45); - toggle->text_normal = zr_rgb(175,175,175); - toggle->text_hover = zr_rgb(175,175,175); - toggle->text_active = zr_rgb(175,175,175); + toggle->text_background = table[ZR_COLOR_WINDOW]; + toggle->text_normal = table[ZR_COLOR_TEXT]; + toggle->text_hover = table[ZR_COLOR_TEXT]; + toggle->text_active = table[ZR_COLOR_TEXT]; toggle->padding = zr_vec2(4.0f, 4.0f); toggle->touch_padding = zr_vec2(0,0); toggle->fixed_width = 0; @@ -7715,16 +7776,16 @@ zr_style_default(struct zr_context *ctx) /* option toggle */ toggle = &style->option; zr_zero_struct(*toggle); - toggle->normal = zr_style_item_color(zr_rgb(100,100,100)); - toggle->hover = zr_style_item_color(zr_rgb(120,120,120)); - toggle->active = zr_style_item_color(zr_rgb(100,100,100)); - toggle->cursor_normal = zr_style_item_color(zr_rgb(45,45,45)); - toggle->cursor_hover = zr_style_item_color(zr_rgb(45,45,45)); + toggle->normal = zr_style_item_color(table[ZR_COLOR_TOGGLE]); + toggle->hover = zr_style_item_color(table[ZR_COLOR_TOGGLE_HOVER]); + toggle->active = zr_style_item_color(table[ZR_COLOR_TOGGLE_HOVER]); + toggle->cursor_normal = zr_style_item_color(table[ZR_COLOR_TOGGLE_CURSOR]); + toggle->cursor_hover = zr_style_item_color(table[ZR_COLOR_TOGGLE_CURSOR]); toggle->userdata = zr_handle_ptr(0); - toggle->text_background = zr_rgb(45,45,45); - toggle->text_normal = zr_rgb(175,175,175); - toggle->text_hover = zr_rgb(175,175,175); - toggle->text_active = zr_rgb(175,175,175); + toggle->text_background = table[ZR_COLOR_WINDOW]; + toggle->text_normal = table[ZR_COLOR_TEXT]; + toggle->text_hover = table[ZR_COLOR_TEXT]; + toggle->text_active = table[ZR_COLOR_TEXT]; toggle->padding = zr_vec2(4.0f, 4.0f); toggle->touch_padding = zr_vec2(0,0); toggle->fixed_width = 0; @@ -7734,25 +7795,25 @@ zr_style_default(struct zr_context *ctx) /* selectable */ select = &style->selectable; zr_zero_struct(*select); - select->normal = zr_style_item_color(zr_rgb(45,45,45)); - select->hover = zr_style_item_color(zr_rgb(45,45,45)); - select->pressed = zr_style_item_color(zr_rgb(45,45,45)); - select->normal_active = zr_style_item_color(zr_rgb(100,100,100)); - select->hover_active = zr_style_item_color(zr_rgb(100,100,100)); - select->pressed_active = zr_style_item_color(zr_rgb(100,100,100)); - select->text_normal = zr_rgb(175,175,175); - select->text_hover = zr_rgb(175,175,175); - select->text_pressed = zr_rgb(175,175,175); - select->text_normal_active = zr_rgb(45,45,45); - select->text_hover_active = zr_rgb(45,45,45); - select->text_pressed_active = zr_rgb(45,45,45); + select->normal = zr_style_item_color(table[ZR_COLOR_SELECTABLE]); + select->hover = zr_style_item_color(table[ZR_COLOR_SELECTABLE_HOVER]); + select->pressed = zr_style_item_color(table[ZR_COLOR_SELECTABLE_HOVER]); + select->normal_active = zr_style_item_color(table[ZR_COLOR_TEXT]); + select->hover_active = zr_style_item_color(table[ZR_COLOR_TEXT]); + select->pressed_active = zr_style_item_color(table[ZR_COLOR_TEXT]); + select->text_normal = table[ZR_COLOR_TEXT]; + select->text_hover = table[ZR_COLOR_TEXT]; + select->text_pressed = table[ZR_COLOR_TEXT]; + select->text_normal_active = table[ZR_COLOR_SELECTABLE]; + select->text_hover_active = table[ZR_COLOR_SELECTABLE]; + select->text_pressed_active = table[ZR_COLOR_SELECTABLE]; + select->padding = zr_vec2(4.0f,4.0f); + select->touch_padding = zr_vec2(0,0); + select->userdata = zr_handle_ptr(0); select->fixed_width = 0; select->fixed_height = 0; select->rounding = 0.0f; select->has_fixed_size = 0; - select->padding = zr_vec2(4.0f,4.0f); - select->touch_padding = zr_vec2(0,0); - select->userdata = zr_handle_ptr(0); select->draw_begin = 0; select->draw = 0; select->draw_end = 0; @@ -7763,13 +7824,13 @@ zr_style_default(struct zr_context *ctx) slider->normal = zr_style_item_hide(); slider->hover = zr_style_item_hide(); slider->active = zr_style_item_hide(); - slider->bar_normal = zr_rgb(38,38,38); - slider->bar_hover = zr_rgb(38,38,38); - slider->bar_active = zr_rgb(38,38,38); - slider->bar_filled = zr_rgb(100,100,100); - slider->cursor_normal = zr_style_item_color(zr_rgb(100,100,100)); - slider->cursor_hover = zr_style_item_color(zr_rgb(120,120,120)); - slider->cursor_active = zr_style_item_color(zr_rgb(150,150,150));; + slider->bar_normal = table[ZR_COLOR_SLIDER]; + slider->bar_hover = table[ZR_COLOR_SLIDER]; + slider->bar_active = table[ZR_COLOR_SLIDER]; + slider->bar_filled = table[ZR_COLOR_SLIDER_CURSOR]; + slider->cursor_normal = zr_style_item_color(table[ZR_COLOR_SLIDER_CURSOR]); + slider->cursor_hover = zr_style_item_color(table[ZR_COLOR_SLIDER_CURSOR_HOVER]); + slider->cursor_active = zr_style_item_color(table[ZR_COLOR_SLIDER_CURSOR_ACTIVE]); slider->inc_symbol = ZR_SYMBOL_TRIANGLE_RIGHT; slider->dec_symbol = ZR_SYMBOL_TRIANGLE_LEFT; slider->cursor_size = zr_vec2(16,16); @@ -7812,12 +7873,12 @@ zr_style_default(struct zr_context *ctx) /* progressbar */ prog = &style->progress; zr_zero_struct(*prog); - prog->normal = zr_style_item_color(zr_rgb(38,38,38)); - prog->hover = zr_style_item_color(zr_rgb(40,40,40)); - prog->active = zr_style_item_color(zr_rgb(42,42,42)); - prog->cursor_normal = zr_style_item_color(zr_rgb(100,100,100)); - prog->cursor_hover = zr_style_item_color(zr_rgb(120,120,120)); - prog->cursor_active = zr_style_item_color(zr_rgb(150,150,150)); + prog->normal = zr_style_item_color(table[ZR_COLOR_SLIDER]); + prog->hover = zr_style_item_color(table[ZR_COLOR_SLIDER]); + prog->active = zr_style_item_color(table[ZR_COLOR_SLIDER]); + prog->cursor_normal = zr_style_item_color(table[ZR_COLOR_SLIDER_CURSOR]); + prog->cursor_hover = zr_style_item_color(table[ZR_COLOR_SLIDER_CURSOR_HOVER]); + prog->cursor_active = zr_style_item_color(table[ZR_COLOR_SLIDER_CURSOR_ACTIVE]); prog->userdata = zr_handle_ptr(0); prog->padding = zr_vec2(4,4); prog->rounding = 0; @@ -7831,12 +7892,12 @@ zr_style_default(struct zr_context *ctx) /* scrollbars */ scroll = &style->scrollh; zr_zero_struct(*scroll); - scroll->normal = zr_style_item_color(zr_rgb(40,40,40)); - scroll->hover = zr_style_item_color(zr_rgb(40,40,40)); - scroll->active = zr_style_item_color(zr_rgb(40,40,40)); - scroll->cursor_normal = zr_style_item_color(zr_rgb(100,100,100)); - scroll->cursor_hover = zr_style_item_color(zr_rgb(120,120,120)); - scroll->cursor_active = zr_style_item_color(zr_rgb(150,150,150)); + scroll->normal = zr_style_item_color(table[ZR_COLOR_SCROLLBAR]); + scroll->hover = zr_style_item_color(table[ZR_COLOR_SCROLLBAR]); + scroll->active = zr_style_item_color(table[ZR_COLOR_SCROLLBAR]); + scroll->cursor_normal = zr_style_item_color(table[ZR_COLOR_SCROLLBAR_CURSOR]); + scroll->cursor_hover = zr_style_item_color(table[ZR_COLOR_SCROLLBAR_CURSOR_HOVER]); + scroll->cursor_active = zr_style_item_color(table[ZR_COLOR_SCROLLBAR_CURSOR_ACTIVE]); scroll->dec_symbol = ZR_SYMBOL_CIRCLE_FILLED; scroll->inc_symbol = ZR_SYMBOL_CIRCLE_FILLED; scroll->userdata = zr_handle_ptr(0); @@ -7878,23 +7939,23 @@ zr_style_default(struct zr_context *ctx) /* edit */ edit = &style->edit; zr_zero_struct(*edit); - edit->normal = zr_style_item_color(zr_rgb(45,45,45)); - edit->hover = zr_style_item_color(zr_rgb(47,47,47)); - edit->active = zr_style_item_color(zr_rgb(49,49,49)); - edit->cursor_normal = zr_style_item_color(zr_rgb(100,100,100)); - edit->cursor_hover = zr_style_item_color(zr_rgb(102,102,102)); - edit->cursor_active = zr_style_item_color(zr_rgb(104,104,104)); - edit->border_color = zr_rgb(65,65,65);; - edit->text_normal = zr_rgb(135,135,135); - edit->text_hover = zr_rgb(135,135,135); - edit->text_active = zr_rgb(135,135,135); - edit->selected_normal = zr_rgb(135,135,135); - edit->selected_hover = zr_rgb(135,135,135); - edit->selected_text_normal = zr_rgb(45,45,45); - edit->selected_text_hover = zr_rgb(45,45,45); + edit->normal = zr_style_item_color(table[ZR_COLOR_EDIT]); + edit->hover = zr_style_item_color(table[ZR_COLOR_EDIT]); + edit->active = zr_style_item_color(table[ZR_COLOR_EDIT]); + edit->cursor_normal = zr_style_item_color(table[ZR_COLOR_EDIT_CURSOR]); + edit->cursor_hover = zr_style_item_color(table[ZR_COLOR_EDIT_CURSOR]); + edit->cursor_active = zr_style_item_color(table[ZR_COLOR_EDIT_CURSOR]); + edit->border_color = table[ZR_COLOR_BORDER]; + edit->text_normal = table[ZR_COLOR_TEXT]; + edit->text_hover = table[ZR_COLOR_TEXT]; + edit->text_active = table[ZR_COLOR_TEXT]; + edit->selected_normal = table[ZR_COLOR_TEXT]; + edit->selected_hover = table[ZR_COLOR_TEXT]; + edit->selected_text_normal = table[ZR_COLOR_EDIT]; + edit->selected_text_hover = table[ZR_COLOR_EDIT]; edit->userdata = zr_handle_ptr(0); edit->padding = zr_vec2(4,4); - edit->cursor_size = 8; + edit->cursor_size = 4; edit->border = 1; edit->rounding = 0; edit->fixed_width = 0; @@ -7907,13 +7968,13 @@ zr_style_default(struct zr_context *ctx) /* property */ property = &style->property; zr_zero_struct(*property); - property->normal = zr_style_item_color(zr_rgb(38,38,38)); - property->hover = zr_style_item_color(zr_rgb(40,40,40)); - property->active = zr_style_item_color(zr_rgb(42,42,42)); - property->border_color = zr_rgb(65,65,65); - property->label_normal = zr_rgb(175,175,175); - property->label_hover = zr_rgb(175,175,175); - property->label_active = zr_rgb(175,175,175); + property->normal = zr_style_item_color(table[ZR_COLOR_PROPERTY]); + property->hover = zr_style_item_color(table[ZR_COLOR_PROPERTY_HOVER]); + property->active = zr_style_item_color(table[ZR_COLOR_PROPERTY_ACTIVE]); + property->border_color = table[ZR_COLOR_BORDER]; + property->label_normal = table[ZR_COLOR_TEXT]; + property->label_hover = table[ZR_COLOR_TEXT]; + property->label_active = table[ZR_COLOR_TEXT]; property->sym_left = ZR_SYMBOL_TRIANGLE_LEFT; property->sym_right = ZR_SYMBOL_TRIANGLE_RIGHT; property->userdata = zr_handle_ptr(0); @@ -7930,14 +7991,14 @@ zr_style_default(struct zr_context *ctx) /* property buttons */ button = &style->property.dec_button; zr_zero_struct(*button); - button->normal = zr_style_item_color(zr_rgb(38,38,38)); - button->hover = zr_style_item_color(zr_rgb(40,40,40)); - button->active = zr_style_item_color(zr_rgb(42,42,42)); + button->normal = zr_style_item_color(table[ZR_COLOR_PROPERTY]); + button->hover = zr_style_item_color(table[ZR_COLOR_PROPERTY_HOVER]); + button->active = zr_style_item_color(table[ZR_COLOR_PROPERTY_ACTIVE]); button->border_color = zr_rgba(0,0,0,0); - button->text_background = zr_rgb(38,38,38); - button->text_normal = zr_rgb(175,175,175); - button->text_hover = zr_rgb(175,175,175); - button->text_active = zr_rgb(175,175,175); + button->text_background = table[ZR_COLOR_PROPERTY]; + button->text_normal = table[ZR_COLOR_TEXT]; + button->text_hover = table[ZR_COLOR_TEXT]; + button->text_active = table[ZR_COLOR_TEXT]; button->padding = zr_vec2(0.0f,0.0f); button->touch_padding = zr_vec2(0.0f,0.0f); button->userdata = zr_handle_ptr(0); @@ -7954,20 +8015,21 @@ zr_style_default(struct zr_context *ctx) /* property edit */ edit = &style->property.edit; zr_zero_struct(*edit); - edit->normal = zr_style_item_color(zr_rgb(38,38,38)); - edit->hover = zr_style_item_color(zr_rgb(40,40,40)); - edit->active = zr_style_item_color(zr_rgb(42,42,42)); - edit->cursor_normal = zr_style_item_color(zr_rgb(175,175,175)); - edit->cursor_hover = zr_style_item_color(zr_rgb(175,175,175)); - edit->cursor_active = zr_style_item_color(zr_rgb(175,175,175)); + edit->normal = zr_style_item_color(table[ZR_COLOR_PROPERTY]); + edit->hover = zr_style_item_color(table[ZR_COLOR_PROPERTY_HOVER]); + edit->active = zr_style_item_color(table[ZR_COLOR_PROPERTY_ACTIVE]); + edit->cursor_normal = zr_style_item_color(table[ZR_COLOR_EDIT_CURSOR]); + edit->cursor_hover = zr_style_item_color(table[ZR_COLOR_EDIT_CURSOR]); + edit->cursor_active = zr_style_item_color(table[ZR_COLOR_EDIT_CURSOR]); edit->border_color = zr_rgba(0,0,0,0); - edit->text_normal = zr_rgb(175,175,175); - edit->text_hover = zr_rgb(175,175,175); - edit->text_active = zr_rgb(175,175,175); - edit->selected_normal = zr_rgb(175,175,175); - edit->selected_hover = zr_rgb(175,175,175); - edit->selected_text_normal = zr_rgb(38,38,38); - edit->selected_text_hover = zr_rgb(50,50,50); + edit->text_normal = table[ZR_COLOR_TEXT]; + edit->text_hover = table[ZR_COLOR_TEXT]; + edit->text_active = table[ZR_COLOR_TEXT]; + edit->selected_normal = table[ZR_COLOR_TEXT]; + edit->selected_hover = table[ZR_COLOR_TEXT]; + edit->selected_text_normal = table[ZR_COLOR_EDIT]; + edit->selected_text_hover = table[ZR_COLOR_EDIT]; + edit->userdata = zr_handle_ptr(0); edit->userdata = zr_handle_ptr(0); edit->padding = zr_vec2(0,0); edit->cursor_size = 8; @@ -7983,10 +8045,10 @@ zr_style_default(struct zr_context *ctx) /* chart */ chart = &style->line_chart; zr_zero_struct(*chart); - chart->background = zr_style_item_color(zr_rgb(120,120,120)); - chart->border_color = zr_rgb(65,65,65); - chart->selected_color = zr_rgb(256,0,0); - chart->color = zr_rgb(45,45,45); + chart->background = zr_style_item_color(table[ZR_COLOR_CHART]); + chart->border_color = table[ZR_COLOR_BORDER]; + chart->selected_color = table[ZR_COLOR_CHART_COLOR_HIGHLIGHT]; + chart->color = table[ZR_COLOR_CHART_COLOR]; chart->border = 0; chart->rounding = 0; chart->has_fixed_size = 0; @@ -7997,13 +8059,13 @@ zr_style_default(struct zr_context *ctx) /* combo */ combo = &style->combo; - combo->normal = zr_style_item_color(zr_rgb(45,45,45)); - combo->hover = zr_style_item_color(zr_rgb(45,45,45)); - combo->active = zr_style_item_color(zr_rgb(45,45,45)); - combo->border_color = zr_rgb(65,65,65); - combo->label_normal = zr_rgb(175,175,175); - combo->label_hover = zr_rgb(175,175,175); - combo->label_active = zr_rgb(175,175,175); + combo->normal = zr_style_item_color(table[ZR_COLOR_COMBO]); + combo->hover = zr_style_item_color(table[ZR_COLOR_COMBO]); + combo->active = zr_style_item_color(table[ZR_COLOR_COMBO]); + combo->border_color = table[ZR_COLOR_BORDER]; + combo->label_normal = table[ZR_COLOR_TEXT]; + combo->label_hover = table[ZR_COLOR_TEXT]; + combo->label_active = table[ZR_COLOR_TEXT]; combo->sym_normal = ZR_SYMBOL_TRIANGLE_DOWN; combo->sym_hover = ZR_SYMBOL_TRIANGLE_DOWN; combo->sym_active =ZR_SYMBOL_TRIANGLE_DOWN; @@ -8019,14 +8081,14 @@ zr_style_default(struct zr_context *ctx) /* combo button */ button = &style->combo.button; zr_zero_struct(*button); - button->normal = zr_style_item_color(zr_rgb(45,45,45)); - button->hover = zr_style_item_color(zr_rgb(45,45,45)); - button->active = zr_style_item_color(zr_rgb(45,45,45)); + button->normal = zr_style_item_color(table[ZR_COLOR_COMBO]); + button->hover = zr_style_item_color(table[ZR_COLOR_COMBO]); + button->active = zr_style_item_color(table[ZR_COLOR_COMBO]); button->border_color = zr_rgba(0,0,0,0); - button->text_background = zr_rgb(45,45,38); - button->text_normal = zr_rgb(175,175,175); - button->text_hover = zr_rgb(175,175,175); - button->text_active = zr_rgb(175,175,175); + button->text_background = table[ZR_COLOR_COMBO]; + button->text_normal = table[ZR_COLOR_TEXT]; + button->text_hover = table[ZR_COLOR_TEXT]; + button->text_active = table[ZR_COLOR_TEXT]; button->padding = zr_vec2(2.0f,2.0f); button->touch_padding = zr_vec2(0.0f,0.0f); button->userdata = zr_handle_ptr(0); @@ -8041,9 +8103,9 @@ zr_style_default(struct zr_context *ctx) /* tab */ tab = &style->tab; - tab->background = zr_style_item_color(zr_rgb(40,40,40)); - tab->border_color = zr_rgb(65,65,65); - tab->text = zr_rgb(175,175,175); + tab->background = zr_style_item_color(table[ZR_COLOR_TAB_HEADER]); + tab->border_color = table[ZR_COLOR_BORDER]; + tab->text = table[ZR_COLOR_TEXT]; tab->sym_minimize = ZR_SYMBOL_TRIANGLE_DOWN; tab->sym_maximize = ZR_SYMBOL_TRIANGLE_RIGHT; tab->border = 1; @@ -8054,14 +8116,14 @@ zr_style_default(struct zr_context *ctx) /* tab button */ button = &style->tab.tab_button; zr_zero_struct(*button); - button->normal = zr_style_item_color(zr_rgb(40,40,40)); - button->hover = zr_style_item_color(zr_rgb(40,40,40)); - button->active = zr_style_item_color(zr_rgb(40,40,40)); + button->normal = zr_style_item_color(table[ZR_COLOR_TAB_HEADER]); + button->hover = zr_style_item_color(table[ZR_COLOR_TAB_HEADER]); + button->active = zr_style_item_color(table[ZR_COLOR_TAB_HEADER]); button->border_color = zr_rgba(0,0,0,0); - button->text_background = zr_rgb(40,40,40); - button->text_normal = zr_rgb(175,175,175); - button->text_hover = zr_rgb(175,175,175); - button->text_active = zr_rgb(175,175,175); + button->text_background = table[ZR_COLOR_TAB_HEADER]; + button->text_normal = table[ZR_COLOR_TEXT]; + button->text_hover = table[ZR_COLOR_TEXT]; + button->text_active = table[ZR_COLOR_TEXT]; button->padding = zr_vec2(2.0f,2.0f); button->touch_padding = zr_vec2(0.0f,0.0f); button->userdata = zr_handle_ptr(0); @@ -8077,14 +8139,14 @@ zr_style_default(struct zr_context *ctx) /* node button */ button = &style->tab.node_button; zr_zero_struct(*button); - button->normal = zr_style_item_color(zr_rgb(45,45,45)); - button->hover = zr_style_item_color(zr_rgb(45,45,45)); - button->active = zr_style_item_color(zr_rgb(45,45,45)); + button->normal = zr_style_item_color(table[ZR_COLOR_WINDOW]); + button->hover = zr_style_item_color(table[ZR_COLOR_WINDOW]); + button->active = zr_style_item_color(table[ZR_COLOR_WINDOW]); button->border_color = zr_rgba(0,0,0,0); - button->text_background = zr_rgb(40,40,40); - button->text_normal = zr_rgb(175,175,175); - button->text_hover = zr_rgb(175,175,175); - button->text_active = zr_rgb(175,175,175); + button->text_background = table[ZR_COLOR_TAB_HEADER]; + button->text_normal = table[ZR_COLOR_TEXT]; + button->text_hover = table[ZR_COLOR_TEXT]; + button->text_active = table[ZR_COLOR_TEXT]; button->padding = zr_vec2(2.0f,2.0f); button->touch_padding = zr_vec2(0.0f,0.0f); button->userdata = zr_handle_ptr(0); @@ -8103,12 +8165,12 @@ zr_style_default(struct zr_context *ctx) win->header.close_symbol = ZR_SYMBOL_X; win->header.minimize_symbol = ZR_SYMBOL_MINUS; win->header.maximize_symbol = ZR_SYMBOL_PLUS; - win->header.normal = zr_style_item_color(zr_rgb(40,40,40)); - win->header.hover = zr_style_item_color(zr_rgb(40,40,40)); - win->header.active = zr_style_item_color(zr_rgb(40,40,40)); - win->header.label_normal = zr_rgb(175,175,175); - win->header.label_hover = zr_rgb(175,175,175); - win->header.label_active = zr_rgb(175,175,175); + win->header.normal = zr_style_item_color(table[ZR_COLOR_HEADER]); + win->header.hover = zr_style_item_color(table[ZR_COLOR_HEADER]); + win->header.active = zr_style_item_color(table[ZR_COLOR_HEADER]); + win->header.label_normal = table[ZR_COLOR_TEXT]; + win->header.label_hover = table[ZR_COLOR_TEXT]; + win->header.label_active = table[ZR_COLOR_TEXT]; win->header.label_padding = zr_vec2(4,4); win->header.padding = zr_vec2(4,4); win->header.spacing = zr_vec2(0,0); @@ -8116,14 +8178,14 @@ zr_style_default(struct zr_context *ctx) /* window header close button */ button = &style->window.header.close_button; zr_zero_struct(*button); - button->normal = zr_style_item_color(zr_rgb(40,40,40)); - button->hover = zr_style_item_color(zr_rgb(40,40,40)); - button->active = zr_style_item_color(zr_rgb(40,40,40)); + button->normal = zr_style_item_color(table[ZR_COLOR_HEADER]); + button->hover = zr_style_item_color(table[ZR_COLOR_HEADER]); + button->active = zr_style_item_color(table[ZR_COLOR_HEADER]); button->border_color = zr_rgba(0,0,0,0); - button->text_background = zr_rgb(40,40,40); - button->text_normal = zr_rgb(175,175,175); - button->text_hover = zr_rgb(175,175,175); - button->text_active = zr_rgb(175,175,175); + button->text_background = table[ZR_COLOR_HEADER]; + button->text_normal = table[ZR_COLOR_TEXT]; + button->text_hover = table[ZR_COLOR_TEXT]; + button->text_active = table[ZR_COLOR_TEXT]; button->padding = zr_vec2(0.0f,0.0f); button->touch_padding = zr_vec2(0.0f,0.0f); button->userdata = zr_handle_ptr(0); @@ -8139,14 +8201,14 @@ zr_style_default(struct zr_context *ctx) /* window header minimize button */ button = &style->window.header.minimize_button; zr_zero_struct(*button); - button->normal = zr_style_item_color(zr_rgb(40,40,40)); - button->hover = zr_style_item_color(zr_rgb(40,40,40)); - button->active = zr_style_item_color(zr_rgb(40,40,40)); + button->normal = zr_style_item_color(table[ZR_COLOR_HEADER]); + button->hover = zr_style_item_color(table[ZR_COLOR_HEADER]); + button->active = zr_style_item_color(table[ZR_COLOR_HEADER]); button->border_color = zr_rgba(0,0,0,0); - button->text_background = zr_rgb(40,40,40); - button->text_normal = zr_rgb(175,175,175); - button->text_hover = zr_rgb(175,175,175); - button->text_active = zr_rgb(175,175,175); + button->text_background = table[ZR_COLOR_HEADER]; + button->text_normal = table[ZR_COLOR_TEXT]; + button->text_hover = table[ZR_COLOR_TEXT]; + button->text_active = table[ZR_COLOR_TEXT]; button->padding = zr_vec2(0.0f,0.0f); button->touch_padding = zr_vec2(0.0f,0.0f); button->userdata = zr_handle_ptr(0); @@ -8160,10 +8222,10 @@ zr_style_default(struct zr_context *ctx) button->draw_end = 0; /* window */ - win->background = zr_rgb(45,45,45); - win->fixed_background = zr_style_item_color(zr_rgb(45,45,45)); - win->border_color = zr_rgb(65,65,65); - win->scaler = zr_style_item_color(zr_rgb(175,175,175)); + win->background = table[ZR_COLOR_WINDOW]; + win->fixed_background = zr_style_item_color(table[ZR_COLOR_WINDOW]); + win->border_color = table[ZR_COLOR_BORDER]; + win->scaler = zr_style_item_color(table[ZR_COLOR_TEXT]); win->footer_padding = zr_vec2(4,4); win->border = 1.0f; win->rounding = 0.0f; @@ -8177,6 +8239,7 @@ zr_style_default(struct zr_context *ctx) win->min_size = zr_vec2(64,64); } + void zr_style_set_font(struct zr_context *ctx, const struct zr_user_font *font) { @@ -8305,7 +8368,7 @@ zr_setup(struct zr_context *ctx, const struct zr_user_font *font) zr_style_default(ctx); ctx->style.font = *font; #if ZR_COMPILE_WITH_VERTEX_BUFFER - zr_canvas_init(&ctx->canvas); + zr_draw_list_init(&ctx->draw_list); #endif } @@ -8422,7 +8485,7 @@ zr_clear(struct zr_context *ctx) ctx->build = 0; ctx->memory.calls = 0; #if ZR_COMPILE_WITH_VERTEX_BUFFER - zr_canvas_clear(&ctx->canvas); + zr_draw_list_clear(&ctx->draw_list); #endif /* garbage collector */ @@ -11410,6 +11473,7 @@ zr_edit_buffer(struct zr_context *ctx, zr_flags flags, show_cursor = 0; } else { modifiable = 1; + show_cursor = 1; } /* check if edit is currently hot item */ diff --git a/zahnrad.h b/zahnrad.h index 8e87239..d8128f7 100644 --- a/zahnrad.h +++ b/zahnrad.h @@ -176,6 +176,9 @@ struct zr_rect zr_rectiv(const int *xywh); zr_size zr_utf_decode(const char*, zr_rune*, zr_size); zr_size zr_utf_encode(zr_rune, char*, zr_size); zr_size zr_utf_len(const char*, zr_size byte_len); +const char* zr_utf_at(const char *buffer, zr_size length, int index, + zr_rune *unicode, zr_size *len); + /* color (conversion user --> zahnrad) */ struct zr_color zr_rgb(int r, int g, int b); @@ -246,48 +249,38 @@ struct zr_image zr_subimage_id(int, unsigned short w, unsigned short h, /* A basic (double)-buffer with linear allocation and resetting as only freeing policy. The buffers main purpose is to control all memory management inside the GUI toolkit and still leave memory control as much as possible in - the hand of the user. The memory is provided in three different ways. - The first way is to use a fixed size block of memory to be filled up. - Biggest advantage is a simple memory model. Downside is that if the buffer - is full there is no way to accesses more memory, which fits target - application with a GUI with roughly known memory consumptions. - The second way to manage memory is by extending the fixed size block by - querying information from the buffer about the used size and needed size and - allocate new memory if the buffer is full. While this approach is still - better than just using a fixed size memory block the reallocation still has - one invalid frame as consquence since the used memory information is only - available at the end of the frame which leads to the last way of handling - memory. - The last and most complicated way of handling memory is by allocator - callbacks. The user hereby registers callbacks to be called to allocate and - free memory if needed. While this solves most allocation problems it causes - some loss of flow control on the user side. + the hand of the user while also making sure the library is easy to use if + not as much control is needed. + In general all memory inside this library can be provided from the user in + three different ways. - USAGE - ---------------------------- - To instantiate the buffer you either have to call the fixed size or - allocator initialization function and provide a memory block in the first - case and an allocator in the second case. - To allocate memory from the buffer you would call zr_buffer_alloc with a - request memory block size as well as an alignment for the block. - Finally to reset the memory at the end of the frame and when the memory - buffer inside the buffer is no longer needed you would call zr_buffer_reset. - To free all memory that has been allocated by an allocator if the buffer is - no longer being used you have to call zr_buffer_clear. + The first way and the one providing most control is by just passing a fixed + size memory block. In this case all control lies in the hand of the user + since he can exactly control where the memory comes from and how much memory + the library should consume. Of course using the fixed size API removes the + ability to automatically resize a buffer if not enough memory is provided so + you have to take over the resizing. While being a fixed sized buffer sounds + quite limiting, it is very effective in this library since the actual memory + consumption is quite stable and has a fixed upper bound for a lot of cases. + + If you don't want to think about how much memory the library should allocate + at all time or have a very dynamic UI with unpredictable memory consumoption + habits but still want control over memory allocation you can use the dynamic + allocator based API. The allocator consists of two callbacks for allocating + and freeing memory and optional userdata so you can plugin your own allocator. + + The final and easiest way can be used by defining + ZR_COMPILE_WITH_DEFAULT_ALLOCATOR as 1 which uses the standard library memory + allocation functions malloc and free and takes over complete control over + memory in this library. */ struct zr_memory_status { void *memory; - /* pointer to the currently used memory block inside the referenced buffer*/ unsigned int type; - /* type of the buffer which is either fixed size or dynamic */ zr_size size; - /* total size of the memory block */ zr_size allocated; - /* allocated amount of memory */ zr_size needed; - /* memory size that would have been allocated if enough memory was present*/ zr_size calls; - /* number of allocation calls referencing this buffer */ }; struct zr_allocator { @@ -340,6 +333,11 @@ void zr_buffer_init_default(struct zr_buffer*); void zr_buffer_init(struct zr_buffer*, const struct zr_allocator*, zr_size size); void zr_buffer_init_fixed(struct zr_buffer*, void *memory, zr_size size); void zr_buffer_info(struct zr_memory_status*, struct zr_buffer*); +void zr_buffer_push(struct zr_buffer*, enum zr_buffer_allocation_type type, + void *memory, zr_size size, zr_size align); +void zr_buffer_mark(struct zr_buffer*, enum zr_buffer_allocation_type type); +void zr_buffer_reset(struct zr_buffer*, enum zr_buffer_allocation_type type); +void zr_buffer_clear(struct zr_buffer*); void zr_buffer_free(struct zr_buffer*); void *zr_buffer_memory(struct zr_buffer*); const void *zr_buffer_memory_const(const struct zr_buffer*); @@ -350,41 +348,42 @@ zr_size zr_buffer_total(struct zr_buffer*); * FONT * * ===============================================================*/ -/* Font handling in this library can be achived in three different ways. - The first and simplest ways is by just using your font handling mechanism - and provide a simple callback for text string width calculation with - `zr_user_font`. This requires the default drawing output - and is not possible for the optional vertex buffer output. +/* Font handling in this library was designed to be quite customizeable and lets + you decide what you want to use and what you want to provide. In this sense + there are four different degrees between control and ease of use and two + different drawing APIs to provide for. - The second way of font handling is by using the same `zr_user_font` struct - to referencing a font as before but providing a second callback for - `zr_user_font_glyph` querying which is used for text drawing in the optional - vertex buffer output. In addition to the callback it is also required to - provide a texture atlas from the font to draw. + So first of the easiest way to do font handling is by just providing a + `zr_user_font` struct which only requires the height in pixel of the used + font and a callback to calculate the width of a string. This way of handling + fonts is best fitted for using the normal draw shape command API were you + do all the text drawing yourself and the library does not require any kind + of deeper knowledge about which font handling mechanism you use. - The final and most complex way is to use the optional font baker - and font handling function, which requires two additional headers for - TTF font baking. While the previous two methods did no need any functions - outside callbacks and are therefore rather simple to handle, the final - font handling method is quite complex and you need to handle the complex - font baking API. The reason why it is complex is because there are multible - ways of using the API. For example it must be possible to use the font - for default command output as well as vertex buffer output. So for example - texture coordinates can either be UV for vertex buffer output or absolute - pixel for drawing function based on pixels. Furthermore it is possible to - incoperate custom user data into the resulting baked image (for example a - white pixel for the vertex buffer output). - In addition and probably the most complex aspect of the baking API was to - incoperate baking of multible fonts into one image. + While the first approach works fine if you don't want to use the optional + vertex buffer output it is not enough if you do. To get font handling working + for these cases you have to provide to additional parameter inside the + `zr_user_font`. First a texture atlas handle used to draw text as subimages + of a bigger font atlas texture and a callback to query a characters glyph + information (offset, size, ...). So it is still possible to provide your own + font and use the vertex buffer output. - In general the font baking API can be understood as having a number of - loaded in memory TTF-fonts, font baking configuration and optional custom - render data as input, while the output is made of font specific data, a big - glyph array of all baked glyphs and the baked image. The API - was designed that way to have a typical file format and not - a perfectly ready in memory library instance of a font. The reason is more - control and seperates the font baking code from the in library used font - format. + The final approach if you do not have a font handling functionality or don't + want to use it in this library is by using the optional font baker. This API + is divided into a high- and low-level API with different priorites between + ease of use and control. Both API's can be used to create a font and + font atlas texture and can even be used with or without the vertex buffer + output. So it still uses the `zr_user_font` struct and the two different + approaches previously stated still work. + Now to the difference between the low level API and the high level API. The low + level API provides a lot of control over the baking process of the font and + provides total control over memory. It consists of a number of functions that + need to be called from begin to end and each step requires some additional + configuration, so it is a lot more complex than the high-level API. + If you don't want to do all the work required for using the low-level API + you can use the font atlas API. It provides the same functionality as the + low-level API but takes away some configuration and all of memory control and + in term provides a easier to use API. */ typedef zr_size(*zr_text_width_f)(zr_handle, float h, const char*, zr_size len); typedef void(*zr_query_font_glyph_f)(zr_handle handle, float font_height, @@ -544,10 +543,7 @@ void zr_font_bake_convert(void *out_memory, int image_width, int image_height, /* Font * ----------------------------------------------------------------- * The font structure is just a simple container to hold the output of a baking - * process in the low level API and as output in the atlas font API. - * The actual font handle used inside the library only references the font - * which allows using custom user font handlers and can be generated by calling - * `zr_font_ref`. */ + * process in the low level API. */ void zr_font_init(struct zr_font*, float pixel_height, zr_rune fallback_codepoint, struct zr_font_glyph*, const struct zr_baked_font*, zr_handle atlas); @@ -699,13 +695,15 @@ const char *zr_edit_box_get_selection(zr_size *len, struct zr_edit_box*); Each frame therefore fills the command buffer with draw commands that then need to be executed by the user and his own render backend. After that the command buffer needs to be cleared and a new frame can be - started. + started. It is probably important to note that the command buffer is the main + drawing API and the optional vertex buffer API only takes this format and + converts it into a hardware accessable format. - The reason for buffering simple primitives as draw commands instead of - directly buffering a hardware accessible format with vertex and element - buffer was to support native render backends like X11 and Win32. - That being said it is possible to convert the command buffer into a - hardware accessible format to support hardware based rendering as well. + Draw commands are divided into filled shapes and shape outlines but only + the filled shapes as well as line, curves and scissor are required to be provided. + All other shape drawing commands can be used but are not required. This was + done to allow the maximum number of render backends to be able to use this + library without you having to do additional work. */ enum zr_command_type { ZR_COMMAND_NOP, @@ -891,34 +889,6 @@ struct zr_command_buffer { zr_size begin, end, last; }; -#if ZR_COMPILE_WITH_VERTEX_BUFFER -typedef unsigned short zr_draw_index; -typedef zr_uint zr_draw_vertex_color; - -enum zr_anti_aliasing { - ZR_ANTI_ALIASING_OFF = zr_false, - ZR_ANTI_ALIASING_ON -}; - -struct zr_draw_vertex { - struct zr_vec2 position; - struct zr_vec2 uv; - zr_draw_vertex_color col; -}; -#endif - -struct zr_draw_command { - unsigned int elem_count; - /* number of elements in the current draw batch */ - struct zr_rect clip_rect; - /* current screen clipping rectangle */ - zr_handle texture; - /* current texture to set */ -#if ZR_COMPILE_WITH_COMMAND_USERDATA - zr_handle userdata; -#endif -}; - /* shape outlines */ void zr_push_scissor(struct zr_command_buffer*, struct zr_rect); void zr_stroke_line(struct zr_command_buffer *b, float x0, float y0, @@ -955,6 +925,150 @@ void zr_draw_text(struct zr_command_buffer*, struct zr_rect, const char *text, zr_size len, const struct zr_user_font*, struct zr_color, struct zr_color); +/* =============================================================== + * + * DRAW LIST + * + * ===============================================================*/ +/* The optional vertex buffer draw list provides a 2D drawing context + with antialiasing functionality which takes basic filled or outlined shapes + or a path and outputs vertexes, elements and draw commands. + The actual draw list API is not required to be used dirctly while using this + library since converting the default library draw command output is done by + just calling `zr_convert` but I decided to still makes this library accessable + since it can be useful. + + The draw list is based on a path buffering and polygon and polyline + rendering API which allows a lot of ways to draw 2D content to screen. + In fact it is probably more powerful than needed but allows even more crazy + things than this library provides by default. +*/ +#if ZR_COMPILE_WITH_VERTEX_BUFFER +typedef unsigned short zr_draw_index; +typedef zr_uint zr_draw_vertex_color; + +enum zr_draw_list_stroke { + ZR_STROKE_OPEN = zr_false, + /* build up path has no connection back to the beginning */ + ZR_STROKE_CLOSED = zr_true + /* build up path has a connection back to the beginning */ +}; + +enum zr_anti_aliasing { + ZR_ANTI_ALIASING_OFF = zr_false, + ZR_ANTI_ALIASING_ON +}; + +struct zr_draw_vertex { + struct zr_vec2 position; + struct zr_vec2 uv; + zr_draw_vertex_color col; +}; + +struct zr_draw_command { + unsigned int elem_count; + /* number of elements in the current draw batch */ + struct zr_rect clip_rect; + /* current screen clipping rectangle */ + zr_handle texture; + /* current texture to set */ +#if ZR_COMPILE_WITH_COMMAND_USERDATA + zr_handle userdata; +#endif +}; + +struct zr_draw_list { + float global_alpha; + enum zr_anti_aliasing shape_AA; + enum zr_anti_aliasing line_AA; + struct zr_draw_null_texture null; + struct zr_rect clip_rect; + struct zr_buffer *buffer; + struct zr_buffer *vertices; + struct zr_buffer *elements; + unsigned int element_count; + unsigned int vertex_count; + zr_size cmd_offset; + unsigned int cmd_count; + unsigned int path_count; + unsigned int path_offset; + struct zr_vec2 circle_vtx[12]; +#if ZR_COMPILE_WITH_COMMAND_USERDATA + zr_handle userdata; +#endif +}; +#endif + +/* draw list */ +void zr_draw_list_init(struct zr_draw_list*); +void zr_draw_list_setup(struct zr_draw_list*, float global_alpha, + enum zr_anti_aliasing line_AA, enum zr_anti_aliasing shape_AA, + struct zr_draw_null_texture, struct zr_buffer *cmds, + struct zr_buffer *vertices, struct zr_buffer *elements); +void zr_draw_list_clear(struct zr_draw_list*); + +/* command drawing */ +#define zr_draw_list_foreach(cmd, can, b)\ + for((cmd)=zr__draw_list_begin(can, b); (cmd)!=0; (cmd)=zr__draw_list_next(cmd, b, can)) +const struct zr_draw_command* zr__draw_list_begin(const struct zr_draw_list*, const struct zr_buffer*); +const struct zr_draw_command* zr__draw_list_next(const struct zr_draw_command*, + const struct zr_buffer*, + const struct zr_draw_list*); +/* path */ +void zr_draw_list_path_clear(struct zr_draw_list*); +void zr_draw_list_path_line_to(struct zr_draw_list *list, struct zr_vec2 pos); +void zr_draw_list_path_arc_to_fast(struct zr_draw_list*, struct zr_vec2 center, + float radius, int a_min, int a_max); +void zr_draw_list_path_arc_to(struct zr_draw_list*, struct zr_vec2 center, + float radius, float a_min, float a_max, + unsigned int segments); +void zr_draw_list_path_rect_to(struct zr_draw_list*, struct zr_vec2 a, + struct zr_vec2 b, float rounding); +void zr_draw_list_path_curve_to(struct zr_draw_list*, struct zr_vec2 p2, + struct zr_vec2 p3, struct zr_vec2 p4, + unsigned int num_segments); +void zr_draw_list_path_fill(struct zr_draw_list*, struct zr_color); +void zr_draw_list_path_stroke(struct zr_draw_list*, struct zr_color, + enum zr_draw_list_stroke closed, float thickness); +/* stroke */ +void zr_draw_list_stroke_line(struct zr_draw_list*, struct zr_vec2 a, struct zr_vec2 b, + struct zr_color, float thickness); +void zr_draw_list_stroke_rect(struct zr_draw_list*, struct zr_rect rect, struct zr_color, + float rounding, float thickness); +void zr_draw_list_stroke_triangle(struct zr_draw_list*, struct zr_vec2 a, struct zr_vec2 b, + struct zr_vec2 c, struct zr_color, float thickness); +void zr_draw_list_stroke_circle(struct zr_draw_list*, struct zr_vec2 center, float radius, + struct zr_color, unsigned int segs, float thickness); +void zr_draw_list_stroke_curve(struct zr_draw_list*, struct zr_vec2 p0, struct zr_vec2 cp0, + struct zr_vec2 cp1, struct zr_vec2 p1, struct zr_color, + unsigned int segments, float thickness); +void zr_draw_list_stroke_poly_line(struct zr_draw_list*, const struct zr_vec2 *points, + const unsigned int count, struct zr_color, + enum zr_draw_list_stroke closed, float thickness, + enum zr_anti_aliasing aliasing); +/* fill */ +void zr_draw_list_fill_rect(struct zr_draw_list*, struct zr_rect rect, + struct zr_color, float rounding); +void zr_draw_list_fill_rect_multi_color(struct zr_draw_list *list, struct zr_rect rect, + struct zr_color left, struct zr_color top, + struct zr_color right, struct zr_color bottom); +void zr_draw_list_fill_triangle(struct zr_draw_list*, struct zr_vec2 a, struct zr_vec2 b, + struct zr_vec2 c, struct zr_color); +void zr_draw_list_fill_circle(struct zr_draw_list*, struct zr_vec2 center, + float radius, struct zr_color col, unsigned int segs); +void zr_draw_list_fill_poly_convex(struct zr_draw_list*, const struct zr_vec2 *points, + const unsigned int count, struct zr_color, + enum zr_anti_aliasing aliasing); +/* misc */ +void zr_draw_list_add_image(struct zr_draw_list*, struct zr_image texture, + struct zr_rect rect, struct zr_color); +void zr_draw_list_add_text(struct zr_draw_list*, const struct zr_user_font*, + struct zr_rect, const char *text, zr_size len, + float font_height, struct zr_color); +#if ZR_COMPILE_WITH_COMMAND_USERDATA +void zr_draw_list_push_userdata(struct zr_draw_list*, zr_handle userdata); +#endif + /* =============================================================== * * GUI @@ -1547,6 +1661,41 @@ struct zr_style { struct zr_style_window window; }; +enum zr_style_colors { + ZR_COLOR_TEXT, + ZR_COLOR_WINDOW, + ZR_COLOR_HEADER, + ZR_COLOR_BORDER, + ZR_COLOR_BUTTON, + ZR_COLOR_BUTTON_HOVER, + ZR_COLOR_BUTTON_ACTIVE, + ZR_COLOR_TOGGLE, + ZR_COLOR_TOGGLE_HOVER, + ZR_COLOR_TOGGLE_CURSOR, + ZR_COLOR_SELECTABLE, + ZR_COLOR_SELECTABLE_HOVER, + ZR_COLOR_SELECTABLE_TEXT, + ZR_COLOR_SLIDER, + ZR_COLOR_SLIDER_CURSOR, + ZR_COLOR_SLIDER_CURSOR_HOVER, + ZR_COLOR_SLIDER_CURSOR_ACTIVE, + ZR_COLOR_PROPERTY, + ZR_COLOR_PROPERTY_HOVER, + ZR_COLOR_PROPERTY_ACTIVE, + ZR_COLOR_EDIT, + ZR_COLOR_EDIT_CURSOR, + ZR_COLOR_COMBO, + ZR_COLOR_CHART, + ZR_COLOR_CHART_COLOR, + ZR_COLOR_CHART_COLOR_HIGHLIGHT, + ZR_COLOR_SCROLLBAR, + ZR_COLOR_SCROLLBAR_CURSOR, + ZR_COLOR_SCROLLBAR_CURSOR_HOVER, + ZR_COLOR_SCROLLBAR_CURSOR_ACTIVE, + ZR_COLOR_TAB_HEADER, + ZR_COLOR_COUNT +}; + struct zr_style_item zr_style_item_image(struct zr_image img); struct zr_style_item zr_style_item_color(struct zr_color); struct zr_style_item zr_style_item_hide(void); @@ -1819,46 +1968,6 @@ struct zr_window { /*============================================================== * CONTEXT * =============================================================*/ -#if ZR_COMPILE_WITH_VERTEX_BUFFER -struct zr_convert_config { - float global_alpha; - /* line thickness mininum: 1*/ - enum zr_anti_aliasing line_AA; - /* line anti-aliasing flag can be turned off if you are thight on memory */ - enum zr_anti_aliasing shape_AA; - /* shape anti-aliasing flag can be turned off if you are thight on memory */ - unsigned int circle_segment_count; - /* number of segments used for circles: default to 22 */ - unsigned int arc_segment_count; - /* number of segments used for arcs: default to 22 */ - unsigned int curve_segment_count; - /* number of segments used for curves: default to 22 */ - struct zr_draw_null_texture null; - /* handle to texture with a white pixel to draw shapes */ -}; - -struct zr_canvas { - float global_alpha; - enum zr_anti_aliasing shape_AA; - enum zr_anti_aliasing line_AA; - struct zr_draw_null_texture null; - struct zr_rect clip_rect; - struct zr_buffer *buffer; - struct zr_buffer *vertices; - struct zr_buffer *elements; - unsigned int element_count; - unsigned int vertex_count; - zr_size cmd_offset; - unsigned int cmd_count; - unsigned int path_count; - unsigned int path_offset; - struct zr_vec2 circle_vtx[12]; -#if ZR_COMPILE_WITH_COMMAND_USERDATA - zr_handle userdata; -#endif -}; -#endif - struct zr_context { /* public: can be accessed freely */ struct zr_input input; @@ -1871,7 +1980,7 @@ struct zr_context { should only be accessed if you know what you are doing */ #if ZR_COMPILE_WITH_VERTEX_BUFFER - struct zr_canvas canvas; + struct zr_draw_list draw_list; #endif #if ZR_COMPILE_WITH_COMMAND_USERDATA zr_handle userdata; @@ -1955,6 +2064,22 @@ const struct zr_command* zr__next(struct zr_context*, const struct zr_command*); const struct zr_command* zr__begin(struct zr_context*); #if ZR_COMPILE_WITH_VERTEX_BUFFER +struct zr_convert_config { + float global_alpha; + /* global alpha value */ + enum zr_anti_aliasing line_AA; + /* line anti-aliasing flag can be turned off if you are thight on memory */ + enum zr_anti_aliasing shape_AA; + /* shape anti-aliasing flag can be turned off if you are thight on memory */ + unsigned int circle_segment_count; + /* number of segments used for circles: default to 22 */ + unsigned int arc_segment_count; + /* number of segments used for arcs: default to 22 */ + unsigned int curve_segment_count; + /* number of segments used for curves: default to 22 */ + struct zr_draw_null_texture null; + /* handle to texture with a white pixel for shape drawing */ +}; void zr_convert(struct zr_context*, struct zr_buffer *cmds, struct zr_buffer *vertices, struct zr_buffer *elements, const struct zr_convert_config*); @@ -1984,6 +2109,8 @@ void zr_input_end(struct zr_context*); * STYLE * -------------------------------------------------------------*/ void zr_style_default(struct zr_context*); +void zr_style_from_table(struct zr_context*, const struct zr_color*); +const char *zr_style_color_name(enum zr_style_colors); void zr_style_set_font(struct zr_context*, const struct zr_user_font*); /*--------------------------------------------------------------