major update no.1

This commit is contained in:
vurtun 2015-12-17 16:48:35 +01:00
parent 847645a29c
commit daae1b8804
5 changed files with 821 additions and 561 deletions

View File

@ -13,7 +13,7 @@ render backends it only focuses on the actual UI.
## Features
- Immediate mode graphical user interface toolkit
- Written in C89 (ANSI C)
- Small codebase (~8kLOC)
- Small codebase (~9kLOC)
- Focus on portability, efficiency, simplicity and minimal internal state
- No dependencies (not even the standard library)
- No global or hidden state

View File

@ -240,43 +240,25 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
if (show_color_picker_popup)
{
/* color picker popup */
static int active[4];
struct zr_context popup;
int r,g,b,a;
zr_flags res = zr_popup_begin(&layout, &popup, ZR_POPUP_STATIC, "Color Picker",
ZR_WINDOW_CLOSEABLE, zr_rect(10, 100, 360, 280), zr_vec2(0,0));
if (res & ZR_WINDOW_CLOSEABLE)
{
zr_popup_close(&popup);
show_color_picker_popup = zr_false;
memset(active, 0, sizeof(active));
}
zr_layout_row_dynamic(&popup, 30, 2);
zr_label(&popup, zr_style_color_name((enum zr_style_colors)color_picker_index), ZR_TEXT_LEFT);
zr_button_color(&popup, color_picker_color, ZR_BUTTON_DEFAULT);
zr_layout_row_dynamic(&popup, 30, 3);
r = color_picker_color.r; g = color_picker_color.g;
b = color_picker_color.b; a = color_picker_color.a;
/* color selection */
zr_drag_int(&popup, 0, &r, 255, 1);
zr_spinner_int(&popup, 0, &r, 255, 1, &active[0]);
zr_slider_int(&popup, 0, &r, 255, 10);
zr_drag_int(&popup, 0, &g, 255, 1);
zr_spinner_int(&popup, 0, &g, 255, 1, &active[1]);
zr_slider_int(&popup, 0, &g, 255, 10);
zr_drag_int(&popup, 0, &b, 255, 1);
zr_spinner_int(&popup, 0, &b, 255, 1, &active[2]);
zr_slider_int(&popup, 0, &b, 255, 10);
zr_drag_int(&popup, 0, &a, 255, 1);
zr_spinner_int(&popup, 0, &a, 255, 1, &active[3]);
zr_slider_int(&popup, 0, &a, 255, 10);
color_picker_color = zr_rgba((zr_byte)r,(zr_byte)g,(zr_byte)b,(zr_byte)a);
zr_layout_row_dynamic(&popup, 30, 2);
color_picker_color.r = (zr_byte)zr_propertyi(&popup, "#R:", 0, color_picker_color.r, 255, 1,1);
color_picker_color.g = (zr_byte)zr_propertyi(&popup, "#G:", 0, color_picker_color.g, 255, 1,1);
color_picker_color.b = (zr_byte)zr_propertyi(&popup, "#B", 0, color_picker_color.b, 255, 1,1);
color_picker_color.a = (zr_byte)zr_propertyi(&popup, "#A", 0, color_picker_color.a, 255, 1,1);
zr_layout_row_dynamic(&popup, 30, 4);
zr_spacing(&popup, 1);
@ -285,13 +267,11 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_popup_close(&popup);
show_color_picker_popup = zr_false;
config->colors[color_picker_index] = color_picker_color;
memset(active, 0, sizeof(active));
}
if (zr_button_text(&popup, "cancel", ZR_BUTTON_DEFAULT))
{
zr_popup_close(&popup);
show_color_picker_popup = zr_false;
memset(active, 0, sizeof(active));
}
zr_popup_end(&layout, &popup, NULL);
}
@ -346,11 +326,11 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
/* theme */
zr_layout_row_static(&layout, 30, 80, 2);
zr_label(&layout, "Theme:", ZR_TEXT_LEFT);
zr_combo_begin(&layout, &combo, themes[*theme], &theme_active);
zr_combo_begin_text(&layout, &combo, themes[*theme], &theme_active, 200, 0);
zr_layout_row_dynamic(&combo, 25, 1);
*theme = zr_combo_item(&combo, themes[THEME_BLACK], ZR_TEXT_CENTERED) ? THEME_BLACK : *theme;
*theme = zr_combo_item(&combo, themes[THEME_WHITE], ZR_TEXT_CENTERED) ? THEME_WHITE : *theme;
zr_combo_end(&layout, &combo, &theme_active);
zr_combo_end(&layout, &combo, &theme_active, 0);
if (zr_layout_push(&layout, ZR_LAYOUT_NODE, "Properties", &property_state))
{
@ -359,8 +339,8 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_layout_row_dynamic(&layout, 30, 3);
for (i = 0; i <= ZR_PROPERTY_SCROLLBAR_SIZE; ++i) {
zr_label(&layout, zr_style_property_name((enum zr_style_properties)i), ZR_TEXT_LEFT);
zr_spinner_float(&layout, 0, &config->properties[i].x, 20, 1, NULL);
zr_spinner_float(&layout, 0, &config->properties[i].y, 20, 1, NULL);
zr_property_float(&layout, "#X:", 0, &config->properties[i].x, 20, 1, 1);
zr_property_float(&layout, "#Y:", 0, &config->properties[i].y, 20, 1, 1);
}
zr_layout_pop(&layout);
}
@ -372,7 +352,7 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_layout_row_dynamic(&layout, 30, 2);
for (i = 0; i < ZR_ROUNDING_MAX; ++i) {
zr_label(&layout, zr_style_rounding_name((enum zr_style_rounding)i), ZR_TEXT_LEFT);
zr_spinner_float(&layout, 0, &config->rounding[i], 20, 1, NULL);
zr_property_float(&layout, "#R:", 0, &config->rounding[i], 20, 1, 1);
}
zr_layout_pop(&layout);
}
@ -467,11 +447,10 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
static size_t prog_value = 40;
static float float_spinner = 2.5f;
static int int_spinner = 20;
static float drag_float = 2;
static int drag_int = 10;
static int r = 255,g = 160, b = 0;
static int h = 100, s = 70, v = 20;
static int spinneri_active, spinnerf_active;
static float property_float = 2;
static int property_int = 10;
static const float ratio[] = {120, 150};
const struct zr_input *in = zr_input(&layout);
struct zr_rect bounds;
@ -500,33 +479,10 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_labelf(&layout, ZR_TEXT_LEFT, "Progressbar" , prog_value);
zr_progress(&layout, &prog_value, 100, ZR_MODIFIABLE);
zr_layout_row(&layout, ZR_STATIC, 30, 2, ratio);
zr_label(&layout, "Spinner int:", ZR_TEXT_LEFT);
zr_spinner_int(&layout, 0, &int_spinner, 50.0, 1, &spinneri_active);
zr_label(&layout, "Spinner float:", ZR_TEXT_LEFT);
zr_spinner_float(&layout, 0, &float_spinner, 5.0, 0.5f, &spinnerf_active);
zr_label(&layout, "Drag float:", ZR_TEXT_LEFT);
zr_drag_float(&layout, 0, &drag_float, 64.0f, 0.1f);
zr_label(&layout, "Drag int:", ZR_TEXT_LEFT);
zr_drag_int(&layout, 0, &drag_int, 100, 1);
zr_layout_row_dynamic(&layout, 30, 6);
zr_label(&layout, "RGB:", ZR_TEXT_LEFT);
zr_drag_int(&layout, 0, &r, 255, 1);
zr_drag_int(&layout, 0, &g, 255, 1);
zr_drag_int(&layout, 0, &b, 255, 1);
color = zr_rgb((zr_byte)r,(zr_byte)g,(zr_byte)b);
zr_button_color(&layout, color, ZR_BUTTON_DEFAULT);
zr_layout_row_dynamic(&layout, 30, 6);
zr_label(&layout, "HSV:", ZR_TEXT_LEFT);
zr_drag_int(&layout, 0, &h, 255, 1);
zr_drag_int(&layout, 0, &s, 255, 1);
zr_drag_int(&layout, 0, &v, 255, 1);
color = zr_hsv((zr_byte)h,(zr_byte)s,(zr_byte)v);
zr_button_color(&layout, color, ZR_BUTTON_DEFAULT);
zr_label(&layout, "Property float:", ZR_TEXT_LEFT);
zr_property_float(&layout, "Float:", 0, &property_float, 64.0f, 0.1f, 0.2f);
zr_label(&layout, "Property int:", ZR_TEXT_LEFT);
zr_property_int(&layout, "Int:", 0, &property_int, 100.0f, 1, 1);
zr_layout_pop(&layout);
}
@ -579,11 +535,13 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
static int com_color_active = zr_false;
static int prog_active = zr_false;
static int check_active = zr_false;
static const float values[]={8.0f,15.0f,20.0f,30.0f,35.0f,40.0f};
static float graph_selection = 8.0f;
static int graph_active = 0;
static const char *weapons[] = {"Fist","Pistol","Shotgun","Plasma","BFG"};
static size_t current_weapon = 0;
static int check_values[5];
static int r = 130, g = 50, b = 50, a = 255;
static struct zr_color combo_color = {130, 50, 50, 255};
static size_t x = 20, y = 40, z = 10, w = 90;
struct zr_context combo;
@ -592,7 +550,7 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
/* default combobox */
zr_layout_row_static(&layout, 30, 200, 1);
zr_combo_begin(&layout, &combo, weapons[current_weapon], &weapon_active);
zr_combo_begin_text(&layout, &combo, weapons[current_weapon], &weapon_active, 200, 0);
{
size_t i = 0;
zr_layout_row_dynamic(&combo, 25, 1);
@ -601,31 +559,28 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
current_weapon = i;
}
}
zr_combo_end(&layout, &combo, &weapon_active);
zr_combo_end(&layout, &combo, &weapon_active, 0);
/* slider color combobox */
sprintf(buffer, "#%02x%02x%02x%02x", r, g, b, a);
zr_style_push_color(config, ZR_COLOR_SPINNER, zr_rgba((zr_byte)r,(zr_byte)g,(zr_byte)b,(zr_byte)a));
zr_combo_begin(&layout, &combo, buffer, &com_color_active);
zr_combo_begin_color(&layout, &combo, combo_color, &com_color_active, 200, 0);
{
float ratios[] = {0.15f, 0.85f};
zr_layout_row(&combo, ZR_DYNAMIC, 30, 2, ratios);
zr_label(&combo, "R", ZR_TEXT_LEFT);
zr_slider_int(&combo, 0, &r, 255, 5);
combo_color.r = (zr_byte)zr_slide_int(&combo, 0, combo_color.r, 255, 5);
zr_label(&combo, "G", ZR_TEXT_LEFT);
zr_slider_int(&combo, 0, &g, 255, 5);
combo_color.g = (zr_byte)zr_slide_int(&combo, 0, combo_color.g, 255, 5);
zr_label(&combo, "B", ZR_TEXT_LEFT);
zr_slider_int(&combo, 0, &b, 255, 5);
combo_color.b = (zr_byte)zr_slide_int(&combo, 0, combo_color.b, 255, 5);
zr_label(&combo, "A", ZR_TEXT_LEFT);
zr_slider_int(&combo, 0, &a, 255, 5);
combo_color.a = (zr_byte)zr_slide_int(&combo, 0, combo_color.a , 255, 5);
}
zr_combo_end(&layout, &combo, NULL);
zr_style_pop_color(config);
zr_combo_end(&layout, &combo, NULL, 0);
/* progressbar combobox */
sum = x + y + z + w;
sprintf(buffer, "%lu", sum);
zr_combo_begin(&layout, &combo, buffer, &prog_active);
zr_combo_begin_text(&layout, &combo, buffer, &prog_active, 200, 0);
{
zr_layout_row_dynamic(&combo, 30, 1);
zr_progress(&combo, &x, 100, ZR_MODIFIABLE);
@ -633,12 +588,12 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_progress(&combo, &z, 100, ZR_MODIFIABLE);
zr_progress(&combo, &w, 100, ZR_MODIFIABLE);
}
zr_combo_end(&layout, &combo, NULL);
zr_combo_end(&layout, &combo, NULL, 0);
/* checkbox combobox */
sum = (size_t)(check_values[0] + check_values[1] + check_values[2] + check_values[3] + check_values[4]);
sprintf(buffer, "%lu", sum);
zr_combo_begin(&layout, &combo, buffer, &check_active);
zr_combo_begin_text(&layout, &combo, buffer, &check_active, 200, 0);
{
zr_layout_row_dynamic(&combo, 30, 1);
zr_checkbox(&combo, weapons[0], &check_values[0]);
@ -646,8 +601,26 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_checkbox(&combo, weapons[2], &check_values[2]);
zr_checkbox(&combo, weapons[3], &check_values[3]);
}
zr_combo_end(&layout, &combo, NULL);
zr_combo_end(&layout, &combo, NULL, 0);
/* graph combobox */
sprintf(buffer, "%.1f", graph_selection);
zr_combo_begin_text(&layout, &combo, buffer, &graph_active, 200, 0);
{
size_t i = 0;
struct zr_graph graph;
zr_layout_row_dynamic(&combo, 120, 1);
zr_graph_begin(&combo, &graph, ZR_GRAPH_COLUMN, LEN(values), 0, 50);
for (i = 0; i < LEN(values); ++i) {
zr_flags res = zr_graph_push(&combo, &graph, values[i]);
if (res & ZR_GRAPH_CLICKED) {
graph_selection = values[i];
zr_combo_close(&combo, &graph_active);
}
}
zr_graph_end(&combo, &graph);
}
zr_combo_end(&layout, &combo, NULL, 0);
zr_layout_pop(&layout);
}
if (zr_layout_push(&layout, ZR_LAYOUT_NODE, "Input", &input_state))
@ -803,7 +776,6 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
static int group_width = 320;
static int group_height = 200;
static struct zr_vec2 scrollbar;
static int width_active, height_active;
struct zr_context tab;
zr_flags group_flags = 0;
@ -819,9 +791,9 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_layout_row_push(&layout, 50);
zr_label(&layout, "size:", ZR_TEXT_LEFT);
zr_layout_row_push(&layout, 130);
zr_spinner_int(&layout, 100, &group_width, 500, 10, &width_active);
zr_property_int(&layout, "#Width:", 100, &group_width, 500, 10, 1);
zr_layout_row_push(&layout, 130);
zr_spinner_int(&layout, 100, &group_height, 500, 10, &height_active);
zr_property_int(&layout, "#Height:", 100, &group_height, 500, 10, 1);
zr_layout_row_end(&layout);
zr_layout_row_static(&layout, (float)group_height, (size_t)group_width, 2);
@ -850,7 +822,6 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
if (zr_layout_push(&layout, ZR_LAYOUT_NODE, "Vertical", &vertical_state))
{
static float a = 100, b = 100, c = 100;
static int a_active, b_active, c_active;
struct zr_rect bounds;
struct zr_context sub;
@ -862,18 +833,15 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
row_layout[4] = c;
/* header */
zr_layout_row_static(&layout, 30, 100, 3);
zr_layout_row_static(&layout, 30, 100, 2);
zr_label(&layout, "left:", ZR_TEXT_LEFT);
zr_slider_float(&layout, 10.0f, &a, 200.0f, 10.0f);
zr_spinner_float(&layout, 10.0f, &a, 200.0f, 1.0f, &a_active);
zr_label(&layout, "middle:", ZR_TEXT_LEFT);
zr_slider_float(&layout, 10.0f, &b, 200.0f, 10.0f);
zr_spinner_float(&layout, 10.0f, &b, 200.0f, 1.0f, &b_active);
zr_label(&layout, "right:", ZR_TEXT_LEFT);
zr_slider_float(&layout, 10.0f, &c, 200.0f, 10.0f);
zr_spinner_float(&layout, 10.0f, &c, 200.0f, 1.0f, &c_active);
/* tiles */
zr_layout_row(&layout, ZR_STATIC, 200, 5, row_layout);
@ -925,18 +893,15 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
struct zr_rect bounds;
/* header */
zr_layout_row_static(&layout, 30, 100, 3);
zr_layout_row_static(&layout, 30, 100, 2);
zr_label(&layout, "top:", ZR_TEXT_LEFT);
zr_slider_float(&layout, 10.0f, &a, 200.0f, 10.0f);
zr_spinner_float(&layout, 10.0f, &a, 200.0f, 1.0f, &a_active);
zr_label(&layout, "middle:", ZR_TEXT_LEFT);
zr_slider_float(&layout, 10.0f, &b, 200.0f, 10.0f);
zr_spinner_float(&layout, 10.0f, &b, 200.0f, 1.0f, &b_active);
zr_label(&layout, "bottom:", ZR_TEXT_LEFT);
zr_slider_float(&layout, 10.0f, &c, 200.0f, 10.0f);
zr_spinner_float(&layout, 10.0f, &c, 200.0f, 1.0f, &c_active);
zr_style_push_property(config, ZR_PROPERTY_ITEM_SPACING, zr_vec2(4, 0));
@ -1020,14 +985,13 @@ init_demo(struct demo *gui)
gui->config_white.colors[ZR_COLOR_PROGRESS_CURSOR] = zr_rgba(80, 80, 80, 255);
gui->config_white.colors[ZR_COLOR_PROGRESS_CURSOR_HOVER] = zr_rgba(70, 70, 70, 255);
gui->config_white.colors[ZR_COLOR_PROGRESS_CURSOR_ACTIVE] = zr_rgba(60, 60, 60, 255);
gui->config_white.colors[ZR_COLOR_DRAG] = zr_rgba(150, 150, 150, 255);
gui->config_white.colors[ZR_COLOR_DRAG_HOVER] = zr_rgba(160, 160, 160, 255);
gui->config_white.colors[ZR_COLOR_DRAG_ACTIVE] = zr_rgba(165, 165, 165, 255);
gui->config_white.colors[ZR_COLOR_PROPERTY] = zr_rgba(150, 150, 150, 255);
gui->config_white.colors[ZR_COLOR_PROPERTY_HOVER] = zr_rgba(160, 160, 160, 255);
gui->config_white.colors[ZR_COLOR_PROPERTY_ACTIVE] = zr_rgba(165, 165, 165, 255);
gui->config_white.colors[ZR_COLOR_INPUT] = zr_rgba(150, 150, 150, 255);
gui->config_white.colors[ZR_COLOR_INPUT_CURSOR] = zr_rgba(0, 0, 0, 255);
gui->config_white.colors[ZR_COLOR_INPUT_TEXT] = zr_rgba(0, 0, 0, 255);
gui->config_white.colors[ZR_COLOR_SPINNER] = zr_rgba(175, 175, 175, 255);
gui->config_white.colors[ZR_COLOR_SPINNER_TRIANGLE] = zr_rgba(0, 0, 0, 255);
gui->config_white.colors[ZR_COLOR_COMBO] = zr_rgba(175, 175, 175, 255);
gui->config_white.colors[ZR_COLOR_HISTO] = zr_rgba(160, 160, 160, 255);
gui->config_white.colors[ZR_COLOR_HISTO_BARS] = zr_rgba(45, 45, 45, 255);
gui->config_white.colors[ZR_COLOR_HISTO_NEGATIVE] = zr_rgba(255, 255, 255, 255);

View File

@ -359,8 +359,10 @@ basic_demo(struct zr_window *window, struct zr_style *config, struct icons *img)
static int slider = 30;
static size_t prog = 80;
static int combo_active = 0;
static int combo2_active = 0;
static int selected_item = 0;
static int selected_image = 2;
static int selected_icon = 0;
static const char *items[] = {"Item 0","item 1","item 2"};
static int piemenu_active = 0;
@ -410,12 +412,21 @@ basic_demo(struct zr_window *window, struct zr_style *config, struct icons *img)
*------------------------------------------------*/
ui_header(&layout, config, "Combo box");
ui_widget(&layout, config, 40, 22);
zr_combo_begin(&layout, &combo, items[selected_item], &combo_active);
zr_combo_begin_text(&layout, &combo, items[selected_item], &combo_active, 200, 0);
zr_layout_row_dynamic(&combo, 35, 1);
for (i = 0; i < 3; ++i)
if (zr_combo_item(&combo, items[i], ZR_TEXT_LEFT))
selected_item = i;
zr_combo_end(&layout, &combo, &combo_active);
zr_combo_end(&layout, &combo, &combo_active, 0);
ui_widget(&layout, config, 40, 22);
zr_combo_begin_icon(&layout, &combo, items[selected_icon],
zr_image_id(img->images[selected_icon]), &combo2_active, 200, 0);
zr_layout_row_dynamic(&combo, 35, 1);
for (i = 0; i < 3; ++i)
if (zr_combo_item_icon(&combo, zr_image_id(img->images[i]), items[i], ZR_TEXT_RIGHT))
selected_icon = i;
zr_combo_end(&layout, &combo, &combo2_active, 0);
/*------------------------------------------------
* CHECKBOX
@ -486,12 +497,12 @@ grid_demo(struct zr_window *window, struct zr_style *config)
zr_label(&layout, "Checkbox:", ZR_TEXT_RIGHT);
zr_checkbox(&layout, "Check me", &check);
zr_label(&layout, "Combobox:", ZR_TEXT_RIGHT);
zr_combo_begin(&layout, &combo, items[selected_item], &combo_active);
zr_combo_begin_text(&layout, &combo, items[selected_item], &combo_active, 200, 0);
zr_layout_row_dynamic(&combo, 30, 1);
for (i = 0; i < 3; ++i)
if (zr_combo_item(&combo, items[i], ZR_TEXT_LEFT))
selected_item = i;
zr_combo_end(&layout, &combo, &combo_active);
zr_combo_end(&layout, &combo, &combo_active, 0);
zr_end(&layout, window);
}
@ -770,7 +781,7 @@ main(int argc, char *argv[])
zr_window_init(&gui.button_demo, zr_rect(50, 50, 255, 600),
ZR_WINDOW_BORDER|ZR_WINDOW_MOVEABLE|ZR_WINDOW_BORDER_HEADER,
&gui.queue, &gui.config, &gui.input);
zr_window_init(&gui.basic_demo, zr_rect(320, 50, 275, 600),
zr_window_init(&gui.basic_demo, zr_rect(320, 50, 275, 610),
ZR_WINDOW_BORDER|ZR_WINDOW_MOVEABLE|ZR_WINDOW_BORDER_HEADER,
&gui.queue, &gui.config, &gui.input);
zr_window_init(&gui.grid_demo, zr_rect(600, 350, 275, 250),

1054
zahnrad.c

File diff suppressed because it is too large Load Diff

149
zahnrad.h
View File

@ -43,6 +43,7 @@ extern "C" {
/* defines the number of temporary configuration user font changes that can be stored */
#define ZR_MAX_FONT_HEIGHT_STACK 32
/* defines the number of temporary configuration font height changes that can be stored */
#define ZR_MAX_NUMBER_BUFFER 64
/*
* ==============================================================
*
@ -1839,14 +1840,13 @@ enum zr_style_colors {
ZR_COLOR_PROGRESS_CURSOR,
ZR_COLOR_PROGRESS_CURSOR_HOVER,
ZR_COLOR_PROGRESS_CURSOR_ACTIVE,
ZR_COLOR_DRAG,
ZR_COLOR_DRAG_HOVER,
ZR_COLOR_DRAG_ACTIVE,
ZR_COLOR_PROPERTY,
ZR_COLOR_PROPERTY_HOVER,
ZR_COLOR_PROPERTY_ACTIVE,
ZR_COLOR_INPUT,
ZR_COLOR_INPUT_CURSOR,
ZR_COLOR_INPUT_TEXT,
ZR_COLOR_SPINNER,
ZR_COLOR_SPINNER_TRIANGLE,
ZR_COLOR_COMBO,
ZR_COLOR_HISTO,
ZR_COLOR_HISTO_BARS,
ZR_COLOR_HISTO_NEGATIVE,
@ -1870,6 +1870,7 @@ enum zr_style_rounding {
ZR_ROUNDING_PROGRESS,
ZR_ROUNDING_CHECK,
ZR_ROUNDING_INPUT,
ZR_ROUNDING_PROPERTY,
ZR_ROUNDING_GRAPH,
ZR_ROUNDING_SCROLLBAR,
ZR_ROUNDING_MAX
@ -2161,6 +2162,17 @@ enum zr_window_flags {
/* INTERNAL ONLY!: removes the read only mode at the end of the window */
};
struct zr_value {
int active, prev;
char buffer[ZR_MAX_NUMBER_BUFFER];
zr_size length;
zr_size cursor;
zr_ulong name;
unsigned int seq;
unsigned int old;
int state;
};
struct zr_window {
struct zr_rect bounds;
/* size with width and height and position of the window */
@ -2176,6 +2188,8 @@ struct zr_window {
/* output command queue which hold the command buffer */
struct zr_input *input;
/* input state for updating the window and all its widgets */
struct zr_value property;
/* currently active property */
};
void zr_window_init(struct zr_window*, struct zr_rect bounds, zr_flags flags,
@ -2202,7 +2216,6 @@ int zr_window_has_flag(struct zr_window*, zr_flags);
/* this function checks if a window has given flag(s) */
int zr_window_is_minimized(struct zr_window*);
/* this function checks if the window is minimized */
/* --------------------------------------------------------------
*
* CONTEXT
@ -2342,6 +2355,8 @@ struct zr_context {
/* command draw call output command buffer */
struct zr_command_queue *queue;
/* command draw call output command buffer */
struct zr_value *property;
/* currently active property */
};
zr_flags zr_begin(struct zr_context*, struct zr_window*, const char *title);
@ -2601,14 +2616,10 @@ void zr_layout_pop(struct zr_context*);
zr_slider_int -- integer slider widget with min,max,step value
zr_slider_float -- float slider widget with min,max,step value
zr_progress -- progressbar widget
zr_drag_float -- float value draggable
zr_drag_int -- integer value dragable
zr_edit -- edit textbox widget for text input
zr_edit_filtered -- edit textbox widget for text input with filter input
zr_edit_field -- edit text field with cursor, clipboard and filter
zr_edit_box -- edit text box with cursor, clipboard and filter
zr_spinner_int -- integer spinner widget with keyboard or mouse modification
zr_spinner_float -- float spinner widget with keyboard or mouse modification
*/
enum zr_text_align {
ZR_TEXT_LEFT,
@ -2858,29 +2869,27 @@ void zr_slider_int(struct zr_context*, int min, int *val, int max,
Output:
- the from user input updated slider value
*/
void zr_drag_float(struct zr_context*, float min, float *val,
float max, float inc_per_pixel);
/* this function executes a dragable float widget
float zr_slide_float(struct zr_context*, float min, float val, float max,
float step);
/* this function creates a float slider for value manipulation
Input:
- minimal dragging value that will not be underflown
- slider dragging which shall be updated
- maximal dragging value that will not be overflown
- value increment per dragged pixel delta
- dragging axis with either ZR_AXIS_X or ZR_AXIS_Y
- minimal slider value that will not be underflown
- slider value which shall be updated
- maximal slider value that will not be overflown
- step intervall to change the slider with
Output:
- returns the from the user input updated value
- the from user input updated slider value
*/
void zr_drag_int(struct zr_context*, int min, int *val,
int max, int inc_per_pixel);
/* this function executes a dragable int value widget
int zr_slide_int(struct zr_context*, int min, int val, int max, int step);
/* this function creates a int slider for value manipulation
Input:
- minimal dragging value that will not be underflown
- slider dragging which shall be updated
- maximal dragging value that will not be overflown
- value increment per dragged pixel delta
- dragging axis with either ZR_AXIS_X or ZR_AXIS_Y
- minimal slider value that will not be underflown
- slider value which shall be updated
- maximal slider value that will not be overflown
- step intervall to change the slider with
Output:
- returns the from the user input updated value
- the from user input updated slider value
*/
void zr_progress(struct zr_context*, zr_size *cur, zr_size max, int modifyable);
/* this function creates an either user or program controlled progressbar
@ -2922,9 +2931,9 @@ void zr_edit_filtered(struct zr_context*, char *buffer, zr_size *len,
- length of the buffer after user input update
- current state of the editbox with active(zr_true) or inactive(zr_false)
*/
void zr_spinner_int(struct zr_context*, int min, int *value, int max,
int step, int *active);
/* this function creates a integer spinner widget
void zr_property_float(struct zr_context *layout, const char *name,
float min, float *val, float max, float step, float inc_per_pixel);
/* this function creates a float property widget
Input:
- min value that will not be underflown
- current spinner value to be updated by user input
@ -2935,9 +2944,35 @@ void zr_spinner_int(struct zr_context*, int min, int *value, int max,
- the from user input updated spinner value
- current state of the editbox with active(zr_true) or inactive(zr_false)
*/
void zr_spinner_float(struct zr_context*, float min, float *value, float max,
float step, int *active);
/* this function creates a float spinner widget
void zr_property_int(struct zr_context *layout, const char *name,
int min, int *val, int max, int step, int inc_per_pixel);
/* this function creates a float property widget
Input:
- min value that will not be underflown
- current spinner value to be updated by user input
- max value that will not be overflown
- spinner value modificaton stepping intervall
- current state of the spinner with active as currently modfied by user input
Output:
- the from user input updated spinner value
- current state of the editbox with active(zr_true) or inactive(zr_false)
*/
float zr_propertyf(struct zr_context *layout, const char *name, float min, float val, float max,
float step, float inc_per_pixel);
/* this function creates a float property widget
Input:
- min value that will not be underflown
- current spinner value to be updated by user input
- max value that will not be overflown
- spinner value modificaton stepping intervall
- current state of the spinner with active as currently modfied by user input
Output:
- the from user input updated spinner value
- current state of the editbox with active(zr_true) or inactive(zr_false)
*/
int zr_propertyi(struct zr_context *layout, const char *name, int min, int val, int max,
int step, int inc_per_pixel);
/* this function creates a float property widget
Input:
- min value that will not be underflown
- current spinner value to be updated by user input
@ -2973,9 +3008,9 @@ void zr_spinner_float(struct zr_context*, float min, float *value, float max,
zr_combo_close -- closes the previously opened combo box
zr_combo_end -- ends the combo box build up process
*/
void zr_combo_begin(struct zr_context *parent, struct zr_context *combo,
const char *selected, int *active);
/* this function begins the combobox build up process
void zr_combo_begin_text(struct zr_context *parent, struct zr_context *combo,
const char *selected, int *active, int height, struct zr_vec2 *scrollbar);
/* this function begins the combobox build up process with a text header
Input:
- parent window layout the combo box will be placed into
- ouput combo box window layout which will be needed to fill the combo box
@ -2983,6 +3018,39 @@ void zr_combo_begin(struct zr_context *parent, struct zr_context *combo,
- the current state of the combobox with either zr_true (active) or zr_false else
- the current scrollbar offset of the combo box popup window
*/
void zr_combo_begin_color(struct zr_context *parent, struct zr_context *combo,
struct zr_color color, int *active, int height,
struct zr_vec2 *scrollbar);
/* this function begins the combobox build up process with a color header
Input:
- parent window layout the combo box will be placed into
- ouput combo box window layout which will be needed to fill the combo box
- title color to show
- the current state of the combobox with either zr_true (active) or zr_false else
- the current scrollbar offset of the combo box popup window
*/
void zr_combo_begin_image(struct zr_context *parent, struct zr_context *combo,
struct zr_image img, int *active, int height,
struct zr_vec2 *scrollbar);
/* this function begins the combobox build up process with a image header
Input:
- parent window layout the combo box will be placed into
- ouput combo box window layout which will be needed to fill the combo box
- title color to show
- the current state of the combobox with either zr_true (active) or zr_false else
- the current scrollbar offset of the combo box popup window
*/
void zr_combo_begin_icon(struct zr_context *parent, struct zr_context *combo,
const char *selected, struct zr_image img, int *active, int height,
struct zr_vec2 *scrollbar);
/* this function begins the combobox build up process with a icon text header
Input:
- parent window layout the combo box will be placed into
- ouput combo box window layout which will be needed to fill the combo box
- title color to show
- the current state of the combobox with either zr_true (active) or zr_false else
- the current scrollbar offset of the combo box popup window
*/
int zr_combo_item(struct zr_context *menu, const char*, enum zr_text_align align);
/* this function execute a combo box item
Input:
@ -3010,11 +3078,11 @@ int zr_combo_item_symbol(struct zr_context *menu, enum zr_symbol symbol,
Output
- `zr_true` if has been clicked `zr_false` otherwise
*/
void zr_combo_close(struct zr_context *combo);
void zr_combo_close(struct zr_context *combo, int *state);
/* this function closes a opened combobox */
void zr_combo_end(struct zr_context *parent, struct zr_context *combo, int*);
void zr_combo_end(struct zr_context *parent, struct zr_context *menu,
int *state, struct zr_vec2 *scrollbar);
/* this function ends the combobox build up process */
/* --------------------------------------------------------------
*
* GRAPH
@ -3092,7 +3160,6 @@ zr_flags zr_graph_push(struct zr_context*,struct zr_graph*,float);
*/
void zr_graph_end(struct zr_context *layout, struct zr_graph*);
/* this function ends the graph */
/* --------------------------------------------------------------
*
* GROUP