simplified some APIs
This commit is contained in:
parent
0f464e6086
commit
273fb3f293
56
demo/demo.c
56
demo/demo.c
|
@ -353,7 +353,17 @@ static void
|
|||
combo_box(struct zr_context *panel, struct combobox *combo,
|
||||
const char**values, zr_size count)
|
||||
{
|
||||
zr_combo(panel, values, count, &combo->selected, 20, &combo->active);
|
||||
zr_size i = 0;
|
||||
struct zr_context layout;
|
||||
zr_combo_begin(panel, &layout, values[combo->selected], &combo->active);
|
||||
zr_layout_row_dynamic(&layout, 25, 1);
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (combo->selected == i) continue;
|
||||
if (zr_combo_item(&layout, ZR_TEXT_LEFT, values[i])) {
|
||||
combo->selected = i;
|
||||
}
|
||||
}
|
||||
combo->active = zr_combo_end(panel, &layout);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -427,6 +437,45 @@ check_combo_box(struct zr_context *panel, zr_bool *values, zr_size count,
|
|||
zr_combo_end(panel, &combo);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* GRAPH
|
||||
* ----------------------------------------------------------------- */
|
||||
static int
|
||||
graph(struct zr_context *layout, enum zr_graph_type type,
|
||||
const zr_float *values, zr_size count, zr_size offset)
|
||||
{
|
||||
zr_size i;
|
||||
zr_int index = -1;
|
||||
zr_float min_value;
|
||||
zr_float max_value;
|
||||
struct zr_graph graph;
|
||||
|
||||
ZR_ASSERT(layout);
|
||||
ZR_ASSERT(values);
|
||||
ZR_ASSERT(count);
|
||||
if (!layout || !layout->valid || !values || !count)
|
||||
return -1;
|
||||
|
||||
/* find min and max graph value */
|
||||
max_value = values[0];
|
||||
min_value = values[0];
|
||||
for (i = offset; i < count; ++i) {
|
||||
if (values[i] > max_value)
|
||||
max_value = values[i];
|
||||
if (values[i] < min_value)
|
||||
min_value = values[i];
|
||||
}
|
||||
|
||||
/* execute graph */
|
||||
zr_graph_begin(layout, &graph, type, count, min_value, max_value);
|
||||
for (i = offset; i < count; ++i) {
|
||||
if (zr_graph_push(layout, &graph, values[i]))
|
||||
index = (zr_int)i;
|
||||
}
|
||||
zr_graph_end(layout, &graph);
|
||||
return index;
|
||||
}
|
||||
|
||||
/* =================================================================
|
||||
*
|
||||
* DEMO
|
||||
|
@ -491,6 +540,7 @@ struct demo_gui {
|
|||
zr_size w, h;
|
||||
};
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* WIDGETS
|
||||
* ----------------------------------------------------------------- */
|
||||
|
@ -846,9 +896,9 @@ run_demo(struct demo_gui *gui)
|
|||
zr_layout_row_dynamic(&tab, 100, 1);
|
||||
switch (state->shelf_selection) {
|
||||
case COLUMNS:
|
||||
zr_graph(&tab, ZR_GRAPH_COLUMN, values, LEN(values), 0); break;
|
||||
graph(&tab, ZR_GRAPH_COLUMN, values, LEN(values), 0); break;
|
||||
case LINES:
|
||||
zr_graph(&tab, ZR_GRAPH_LINES, values, LEN(values), 0); break;
|
||||
graph(&tab, ZR_GRAPH_LINES, values, LEN(values), 0); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,25 +95,6 @@ struct device {
|
|||
struct zr_buffer cmds;
|
||||
};
|
||||
|
||||
#define glerror() glerror_(__FILE__, __LINE__)
|
||||
static void
|
||||
glerror_(const char *file, int line)
|
||||
{
|
||||
const GLenum code = glGetError();
|
||||
if (code == GL_INVALID_ENUM)
|
||||
fprintf(stdout, "[GL] Error: (%s:%d) invalid value!\n", file, line);
|
||||
else if (code == GL_INVALID_OPERATION)
|
||||
fprintf(stdout, "[GL] Error: (%s:%d) invalid operation!\n", file, line);
|
||||
else if (code == GL_INVALID_FRAMEBUFFER_OPERATION)
|
||||
fprintf(stdout, "[GL] Error: (%s:%d) invalid frame op!\n", file, line);
|
||||
else if (code == GL_OUT_OF_MEMORY)
|
||||
fprintf(stdout, "[GL] Error: (%s:%d) out of memory!\n", file, line);
|
||||
else if (code == GL_STACK_UNDERFLOW)
|
||||
fprintf(stdout, "[GL] Error: (%s:%d) stack underflow!\n", file, line);
|
||||
else if (code == GL_STACK_OVERFLOW)
|
||||
fprintf(stdout, "[GL] Error: (%s:%d) stack overflow!\n", file, line);
|
||||
}
|
||||
|
||||
static void
|
||||
device_init(struct device *dev)
|
||||
{
|
||||
|
@ -164,11 +145,10 @@ device_init(struct device *dev)
|
|||
dev->attrib_pos = glGetAttribLocation(dev->prog, "Position");
|
||||
dev->attrib_uv = glGetAttribLocation(dev->prog, "TexCoord");
|
||||
dev->attrib_col = glGetAttribLocation(dev->prog, "Color");
|
||||
glerror();
|
||||
|
||||
{
|
||||
/* buffer setup */
|
||||
size_t vs = sizeof(struct zr_draw_vertex);
|
||||
GLsizei vs = sizeof(struct zr_draw_vertex);
|
||||
size_t vp = offsetof(struct zr_draw_vertex, position);
|
||||
size_t vt = offsetof(struct zr_draw_vertex, uv);
|
||||
size_t vc = offsetof(struct zr_draw_vertex, col);
|
||||
|
@ -180,7 +160,6 @@ device_init(struct device *dev)
|
|||
glBindVertexArray(dev->vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, dev->vbo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo);
|
||||
glerror();
|
||||
|
||||
glEnableVertexAttribArray((GLuint)dev->attrib_pos);
|
||||
glEnableVertexAttribArray((GLuint)dev->attrib_uv);
|
||||
|
@ -189,14 +168,12 @@ device_init(struct device *dev)
|
|||
glVertexAttribPointer((GLuint)dev->attrib_pos, 2, GL_FLOAT, GL_FALSE, vs, (void*)vp);
|
||||
glVertexAttribPointer((GLuint)dev->attrib_uv, 2, GL_FLOAT, GL_FALSE, vs, (void*)vt);
|
||||
glVertexAttribPointer((GLuint)dev->attrib_col, 4, GL_UNSIGNED_BYTE, GL_TRUE, vs, (void*)vc);
|
||||
glerror();
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
glerror();
|
||||
}
|
||||
|
||||
static struct zr_user_font
|
||||
|
@ -233,7 +210,7 @@ font_bake_and_upload(struct device *dev, struct zr_font *font,
|
|||
config.coord_type = ZR_COORD_UV;
|
||||
config.range = range;
|
||||
config.pixel_snap = zr_false;
|
||||
config.size = font_height;
|
||||
config.size = (zr_float)font_height;
|
||||
config.spacing = zr_vec2(0,0);
|
||||
config.oversample_h = 1;
|
||||
config.oversample_v = 1;
|
||||
|
@ -281,7 +258,7 @@ font_bake_and_upload(struct device *dev, struct zr_font *font,
|
|||
this was done to have the possibility to have multible fonts with one
|
||||
total glyph array. Not quite sure if it is a good thing since the
|
||||
glyphes have to be freed as well. */
|
||||
zr_font_init(font, font_height, '?', glyphes, &baked_font, dev->null.texture);
|
||||
zr_font_init(font, (zr_float)font_height, '?', glyphes, &baked_font, dev->null.texture);
|
||||
user_font = zr_font_ref(font);
|
||||
return user_font;
|
||||
}
|
||||
|
@ -323,7 +300,6 @@ device_draw(struct device *dev, struct zr_command_queue *queue, int width, int h
|
|||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_vao);
|
||||
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_ebo);
|
||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vbo);
|
||||
glerror();
|
||||
|
||||
/* setup global state */
|
||||
glViewport(0, 0, width, height);
|
||||
|
@ -334,13 +310,11 @@ device_draw(struct device *dev, struct zr_command_queue *queue, int width, int h
|
|||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glerror();
|
||||
|
||||
/* setup program */
|
||||
glUseProgram(dev->prog);
|
||||
glUniform1i(dev->uniform_tex, 0);
|
||||
glUniformMatrix4fv(dev->uniform_proj, 1, GL_FALSE, &ortho[0][0]);
|
||||
glerror();
|
||||
|
||||
{
|
||||
/* convert from command queue into draw list and draw to screen */
|
||||
|
@ -359,7 +333,6 @@ device_draw(struct device *dev, struct zr_command_queue *queue, int width, int h
|
|||
|
||||
glBufferData(GL_ARRAY_BUFFER, max_vertex_memory, NULL, GL_STREAM_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, max_element_memory, NULL, GL_STREAM_DRAW);
|
||||
glerror();
|
||||
|
||||
/* load draw vertexes & elements directly into vertex + element buffer */
|
||||
vertexes = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
|
@ -374,7 +347,6 @@ device_draw(struct device *dev, struct zr_command_queue *queue, int width, int h
|
|||
}
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
|
||||
glerror();
|
||||
|
||||
/* iterate and execute each draw command */
|
||||
zr_foreach_draw_command(cmd, &draw_list) {
|
||||
|
@ -384,7 +356,6 @@ device_draw(struct device *dev, struct zr_command_queue *queue, int width, int h
|
|||
(GLint)cmd->clip_rect.w, (GLint)cmd->clip_rect.h);
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)cmd->elem_count, GL_UNSIGNED_SHORT, offset);
|
||||
offset += cmd->elem_count;
|
||||
glerror();
|
||||
}
|
||||
|
||||
zr_command_queue_clear(queue);
|
||||
|
@ -398,7 +369,6 @@ device_draw(struct device *dev, struct zr_command_queue *queue, int width, int h
|
|||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)last_ebo);
|
||||
glBindVertexArray((GLuint)last_vao);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glerror();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
205
zahnrad.c
205
zahnrad.c
|
@ -7114,80 +7114,6 @@ zr_graph_end(struct zr_context *layout, struct zr_graph *graph)
|
|||
graph->w = 0;
|
||||
graph->h = 0;
|
||||
}
|
||||
|
||||
zr_int
|
||||
zr_graph(struct zr_context *layout, enum zr_graph_type type,
|
||||
const zr_float *values, zr_size count, zr_size offset)
|
||||
{
|
||||
zr_size i;
|
||||
zr_int index = -1;
|
||||
zr_float min_value;
|
||||
zr_float max_value;
|
||||
struct zr_graph graph;
|
||||
|
||||
ZR_ASSERT(layout);
|
||||
ZR_ASSERT(values);
|
||||
ZR_ASSERT(count);
|
||||
if (!layout || !layout->valid || !values || !count)
|
||||
return -1;
|
||||
|
||||
/* find min and max graph value */
|
||||
max_value = values[0];
|
||||
min_value = values[0];
|
||||
for (i = offset; i < count; ++i) {
|
||||
if (values[i] > max_value)
|
||||
max_value = values[i];
|
||||
if (values[i] < min_value)
|
||||
min_value = values[i];
|
||||
}
|
||||
|
||||
/* execute graph */
|
||||
zr_graph_begin(layout, &graph, type, count, min_value, max_value);
|
||||
for (i = offset; i < count; ++i) {
|
||||
if (zr_graph_push(layout, &graph, values[i]))
|
||||
index = (zr_int)i;
|
||||
}
|
||||
zr_graph_end(layout, &graph);
|
||||
return index;
|
||||
}
|
||||
|
||||
zr_int
|
||||
zr_graph_callback(struct zr_context *layout, enum zr_graph_type type,
|
||||
zr_size count, zr_float(*get_value)(void*, zr_size), void *userdata)
|
||||
{
|
||||
zr_size i;
|
||||
zr_int index = -1;
|
||||
zr_float min_value;
|
||||
zr_float max_value;
|
||||
struct zr_graph graph;
|
||||
|
||||
ZR_ASSERT(layout);
|
||||
ZR_ASSERT(get_value);
|
||||
ZR_ASSERT(count);
|
||||
if (!layout || !layout->valid || !get_value || !count)
|
||||
return -1;
|
||||
|
||||
/* find min and max graph value */
|
||||
max_value = get_value(userdata, 0);
|
||||
min_value = max_value;
|
||||
for (i = 1; i < count; ++i) {
|
||||
zr_float value = get_value(userdata, i);
|
||||
if (value > max_value)
|
||||
max_value = value;
|
||||
if (value < min_value)
|
||||
min_value = value;
|
||||
}
|
||||
|
||||
/* execute graph */
|
||||
zr_graph_begin(layout, &graph, type, count, min_value, max_value);
|
||||
for (i = 0; i < count; ++i) {
|
||||
zr_float value = get_value(userdata, i);
|
||||
if (zr_graph_push(layout, &graph, value))
|
||||
index = (zr_int)i;
|
||||
}
|
||||
zr_graph_end(layout, &graph);
|
||||
return index;
|
||||
}
|
||||
/*
|
||||
* -------------------------------------------------------------
|
||||
*
|
||||
|
@ -7280,6 +7206,13 @@ zr_popup_end(struct zr_context *parent, struct zr_context *popup)
|
|||
return pan.offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------------------------------------------
|
||||
*
|
||||
* CONTEXTUAL
|
||||
*
|
||||
* --------------------------------------------------------------
|
||||
*/
|
||||
static zr_bool
|
||||
zr_popup_nonblocking_begin(struct zr_context *parent,
|
||||
struct zr_context *popup, zr_flags flags, zr_state *active, zr_state is_active,
|
||||
|
@ -7329,7 +7262,7 @@ zr_popup_nonblocking_end(struct zr_context *parent,
|
|||
}
|
||||
|
||||
void
|
||||
zr_popup_nonblock_begin(struct zr_context *parent, struct zr_context *popup,
|
||||
zr_contextual_begin(struct zr_context *parent, struct zr_context *popup,
|
||||
zr_flags flags, zr_state *active, struct zr_rect body)
|
||||
{
|
||||
ZR_ASSERT(parent);
|
||||
|
@ -7339,26 +7272,39 @@ zr_popup_nonblock_begin(struct zr_context *parent, struct zr_context *popup,
|
|||
zr_popup_nonblocking_begin(parent, popup, flags, active, *active, body);
|
||||
}
|
||||
|
||||
zr_state
|
||||
zr_popup_nonblock_close(struct zr_context *popup)
|
||||
zr_bool
|
||||
zr_contextual_item(struct zr_context *menu, const char *title, enum zr_text_align align)
|
||||
{
|
||||
ZR_ASSERT(popup);
|
||||
if (!popup) return ZR_INACTIVE;
|
||||
zr_popup_close(popup);
|
||||
popup->flags |= ZR_WINDOW_HIDDEN;
|
||||
return ZR_INACTIVE;
|
||||
ZR_ASSERT(menu);
|
||||
if (zr_button_fitting(menu, title, align, ZR_BUTTON_DEFAULT)) {
|
||||
zr_contextual_close(menu);
|
||||
return zr_true;
|
||||
}
|
||||
return zr_false;
|
||||
}
|
||||
|
||||
void
|
||||
zr_popup_nonblock_end(struct zr_context *parent, struct zr_context *popup)
|
||||
zr_contextual_close(struct zr_context *popup)
|
||||
{
|
||||
ZR_ASSERT(popup);
|
||||
if (!popup) return;
|
||||
zr_popup_close(popup);
|
||||
popup->flags |= ZR_WINDOW_HIDDEN;
|
||||
}
|
||||
|
||||
zr_state
|
||||
zr_contextual_end(struct zr_context *parent, struct zr_context *menu)
|
||||
{
|
||||
ZR_ASSERT(parent);
|
||||
ZR_ASSERT(popup);
|
||||
if (!parent || !popup) return;
|
||||
if ((!parent->valid || !popup->valid) && !(popup->flags & ZR_WINDOW_HIDDEN))
|
||||
return;
|
||||
zr_popup_nonblocking_end(parent, popup);
|
||||
return;
|
||||
ZR_ASSERT(menu);
|
||||
if (!parent || !menu) return zr_false;
|
||||
if (!parent->valid) return zr_false;
|
||||
if ((!parent->valid || !menu->valid) && !(menu->flags & ZR_WINDOW_HIDDEN))
|
||||
return zr_false;
|
||||
zr_popup_nonblocking_end(parent, menu);
|
||||
if (menu->flags & ZR_WINDOW_HIDDEN)
|
||||
return zr_false;
|
||||
return zr_true;
|
||||
}
|
||||
/*
|
||||
* -------------------------------------------------------------
|
||||
|
@ -7463,54 +7409,17 @@ failed:
|
|||
combo->queue = parent->queue;
|
||||
}
|
||||
|
||||
void
|
||||
zr_combo_end(struct zr_context *parent, struct zr_context *combo)
|
||||
{
|
||||
ZR_ASSERT(parent);
|
||||
ZR_ASSERT(combo);
|
||||
if (!parent || !combo) return;
|
||||
if ((!parent->valid || !combo->valid) && !(combo->flags & ZR_WINDOW_HIDDEN))
|
||||
return;
|
||||
zr_popup_nonblocking_end(parent, combo);
|
||||
return;
|
||||
}
|
||||
zr_bool
|
||||
zr_combo_item(struct zr_context *combo, enum zr_text_align align, const char *title)
|
||||
{return zr_contextual_item(combo, title, align);}
|
||||
|
||||
zr_state
|
||||
zr_combo_end(struct zr_context *parent, struct zr_context *menu)
|
||||
{return zr_contextual_end(parent, menu);}
|
||||
|
||||
void
|
||||
zr_combo_close(struct zr_context *combo)
|
||||
{
|
||||
ZR_ASSERT(combo);
|
||||
if (!combo) return;
|
||||
zr_popup_close(combo);
|
||||
combo->flags |= ZR_WINDOW_HIDDEN;
|
||||
}
|
||||
|
||||
void
|
||||
zr_combo(struct zr_context *layout, const char **entries,
|
||||
zr_size count, zr_size *current, zr_size row_height,
|
||||
zr_state *active)
|
||||
{
|
||||
zr_size i;
|
||||
struct zr_context combo;
|
||||
ZR_ASSERT(layout);
|
||||
ZR_ASSERT(entries);
|
||||
ZR_ASSERT(current);
|
||||
ZR_ASSERT(active);
|
||||
if (!layout || !layout->valid || !entries || !current || !active) return;
|
||||
if (!count) return;
|
||||
|
||||
zr_zero(&combo, sizeof(combo));
|
||||
zr_combo_begin(layout, &combo, entries[*current], active);
|
||||
zr_layout_row_dynamic(&combo, (zr_float)row_height, 1);
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (i == *current) continue;
|
||||
if (zr_button_fitting(&combo,entries[i], ZR_TEXT_LEFT, ZR_BUTTON_DEFAULT)) {
|
||||
zr_combo_close(&combo);
|
||||
*active = zr_false;
|
||||
*current = i;
|
||||
}
|
||||
}
|
||||
zr_combo_end(layout, &combo);
|
||||
}
|
||||
{zr_contextual_close(combo);}
|
||||
/*
|
||||
* -------------------------------------------------------------
|
||||
*
|
||||
|
@ -7578,37 +7487,15 @@ failed:
|
|||
|
||||
zr_bool
|
||||
zr_menu_item(struct zr_context *menu, enum zr_text_align align, const char *title)
|
||||
{
|
||||
if (zr_button_fitting(menu, title, align, ZR_BUTTON_DEFAULT)) {
|
||||
zr_menu_close(menu);
|
||||
return zr_true;
|
||||
}
|
||||
return zr_false;
|
||||
}
|
||||
{return zr_contextual_item(menu, title, align);}
|
||||
|
||||
void
|
||||
zr_menu_close(struct zr_context *menu)
|
||||
{
|
||||
ZR_ASSERT(menu);
|
||||
if (!menu) return;
|
||||
zr_popup_close(menu);
|
||||
menu->flags |= ZR_WINDOW_HIDDEN;
|
||||
}
|
||||
{zr_contextual_close(menu);}
|
||||
|
||||
zr_state
|
||||
zr_menu_end(struct zr_context *parent, struct zr_context *menu)
|
||||
{
|
||||
ZR_ASSERT(parent);
|
||||
ZR_ASSERT(menu);
|
||||
if (!parent || !menu) return zr_false;
|
||||
if (!parent->valid) return zr_false;
|
||||
if ((!parent->valid || !menu->valid) && !(menu->flags & ZR_WINDOW_HIDDEN))
|
||||
return zr_false;
|
||||
zr_popup_nonblocking_end(parent, menu);
|
||||
if (menu->flags & ZR_WINDOW_HIDDEN)
|
||||
return zr_false;
|
||||
return zr_true;
|
||||
}
|
||||
{return zr_contextual_end(parent, menu);}
|
||||
/*
|
||||
* -------------------------------------------------------------
|
||||
*
|
||||
|
|
211
zahnrad.h
211
zahnrad.h
|
@ -3602,9 +3602,12 @@ struct zr_vec2 zr_popup_end(struct zr_context *parent,
|
|||
Output:
|
||||
- The from user input updated popup scrollbar pixel offset
|
||||
*/
|
||||
void zr_popup_nonblock_begin(struct zr_context *parent, struct zr_context *popup,
|
||||
/* --------------------------------------------------------------
|
||||
* CONTEXTUAL
|
||||
* --------------------------------------------------------------*/
|
||||
void zr_contextual_begin(struct zr_context *parent, struct zr_context *popup,
|
||||
zr_flags flags, zr_state *active, struct zr_rect body);
|
||||
/* this function adds a no-blocking context menu popup
|
||||
/* this function adds a context menu popup
|
||||
Input:
|
||||
- type of the popup as either growing or static
|
||||
- additonal popup window flags
|
||||
|
@ -3613,13 +3616,100 @@ void zr_popup_nonblock_begin(struct zr_context *parent, struct zr_context *popup
|
|||
Output:
|
||||
- popup layout to fill with widgets
|
||||
*/
|
||||
zr_state zr_popup_nonblock_close(struct zr_context *popup);
|
||||
zr_bool zr_contextual_item(struct zr_context *menu, const char*, enum zr_text_align align);
|
||||
/* this function execute contextual menu item
|
||||
Input:
|
||||
- text alignment of the title
|
||||
- title of the item
|
||||
Output
|
||||
- `zr_true` if has been clicked `zr_false` otherwise
|
||||
*/
|
||||
void zr_contextual_close(struct zr_context *popup);
|
||||
/* this functions closes the context menu
|
||||
Output:
|
||||
- update state of the context menu
|
||||
*/
|
||||
void zr_popup_nonblock_end(struct zr_context *parent, struct zr_context *popup);
|
||||
zr_state zr_contextual_end(struct zr_context *parent, struct zr_context *popup);
|
||||
/* this functions closes a previously opened context menu */
|
||||
/* --------------------------------------------------------------
|
||||
* COMBO BOX
|
||||
* --------------------------------------------------------------
|
||||
COMBO BOX
|
||||
The combo box is a minimizable popup window and extends the old school
|
||||
text combo box with the possibility to fill combo boxes with any kind of widgets.
|
||||
The combo box is internall implemented with a dynamic popup window
|
||||
and can only be as height as the window allows.
|
||||
There are two different ways to create a combo box. The first one is a
|
||||
standart text combo box which has it own function `zr_combo`. The second
|
||||
way is the more complex immediate mode API which allows to create
|
||||
any kind of content inside the combo box. In case of the second API it is
|
||||
additionally possible and sometimes wanted to close the combo box popup
|
||||
window This can be achived with `zr_combo_close`.
|
||||
|
||||
combo box API
|
||||
zr_combo_begin -- begins the combo box popup window
|
||||
zr_combo_close -- closes the previously opened combo box
|
||||
zr_combo_end -- ends the combo box build up process
|
||||
*/
|
||||
void zr_combo_begin(struct zr_context *parent,
|
||||
struct zr_context *combo, const char *selected,
|
||||
zr_state *active);
|
||||
/* this function begins the combobox build up process
|
||||
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 of the combo box or in the case of the text combo box the selected item
|
||||
- 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
|
||||
*/
|
||||
zr_bool zr_combo_item(struct zr_context *menu, enum zr_text_align align, const char*);
|
||||
/* this function execute a combo item
|
||||
Input:
|
||||
- title of the item
|
||||
Output
|
||||
- `zr_true` if has been clicked `zr_false` otherwise
|
||||
*/
|
||||
void zr_combo_close(struct zr_context *combo);
|
||||
/* this function closes a opened combobox */
|
||||
zr_state zr_combo_end(struct zr_context *parent, struct zr_context *combo);
|
||||
/* this function ends the combobox build up process */
|
||||
/*----------------------------------------------------------------
|
||||
* MENU
|
||||
* --------------------------------------------------------------
|
||||
MENU
|
||||
The menu widget provides a overlapping popup window which can
|
||||
be opened/closed by clicking on the menu button. It is normally
|
||||
placed at the top of the window and is independent of the parent
|
||||
scrollbar offset. But if needed the menu can even be placed inside the window.
|
||||
At the moment the menu only allows a single depth but that will change
|
||||
in the future.
|
||||
|
||||
menu widget API
|
||||
zr_menu_begin -- begins the menu item build up processs
|
||||
zr_menu_push -- adds a item into the menu
|
||||
zr_menu_end -- ends the menu item build up process
|
||||
*/
|
||||
void zr_menu_begin(struct zr_context *parent,
|
||||
struct zr_context *menu, const char *title,
|
||||
zr_float width, zr_state *active);
|
||||
/* this function begins the menu build up process
|
||||
Input:
|
||||
- parent window layout the menu will be placed into
|
||||
- ouput menu window layout
|
||||
- title of the menu to
|
||||
- the current state of the menu with either zr_true (open) or zr_false else
|
||||
*/
|
||||
zr_bool zr_menu_item(struct zr_context *menu, enum zr_text_align align, const char*);
|
||||
/* this function execute a menu item
|
||||
Input:
|
||||
- title of the item
|
||||
Output
|
||||
- `zr_true` if has been clicked `zr_false` otherwise
|
||||
*/
|
||||
void zr_menu_close(struct zr_context *menu);
|
||||
/* this function closes a opened menu */
|
||||
zr_state zr_menu_end(struct zr_context *parent, struct zr_context *menu);
|
||||
/* this function ends the menu build up process */
|
||||
/* --------------------------------------------------------------
|
||||
* GRAPH
|
||||
* --------------------------------------------------------------
|
||||
|
@ -3686,118 +3776,7 @@ zr_bool zr_graph_push(struct zr_context*,struct zr_graph*,zr_float);
|
|||
- value data point to fill into the graph either as point or as bar
|
||||
*/
|
||||
void zr_graph_end(struct zr_context *layout, struct zr_graph*);
|
||||
/* this function pops the graph from being used
|
||||
*/
|
||||
zr_int zr_graph(struct zr_context*, enum zr_graph_type,
|
||||
const zr_float *values, zr_size count, zr_size offset);
|
||||
/* this function create a graph with given type from an array of value
|
||||
Input:
|
||||
- type of the graph with either line or bar graph
|
||||
- graph values in continues array form
|
||||
- number of graph values
|
||||
- offset into the value array from which to begin drawing
|
||||
*/
|
||||
zr_int zr_graph_callback(struct zr_context*, enum zr_graph_type,
|
||||
zr_size count, zr_float(*get_value)(void*, zr_size),
|
||||
void *userdata);
|
||||
/* this function create a graph with given type from callback providing the
|
||||
graph with values
|
||||
Input:
|
||||
- type of the graph with either line or bar graph
|
||||
- number of values inside the graph
|
||||
- callback to access the values inside your datastrucutre
|
||||
- userdata to pull the graph values from
|
||||
*/
|
||||
/* --------------------------------------------------------------
|
||||
* COMBO BOX
|
||||
* --------------------------------------------------------------
|
||||
COMBO BOX
|
||||
The combo box is a minimizable popup window and extends the old school
|
||||
text combo box with the possibility to fill combo boxes with any kind of widgets.
|
||||
The combo box is internall implemented with a dynamic popup window
|
||||
and can only be as height as the window allows.
|
||||
There are two different ways to create a combo box. The first one is a
|
||||
standart text combo box which has it own function `zr_combo`. The second
|
||||
way is the more complex immediate mode API which allows to create
|
||||
any kind of content inside the combo box. In case of the second API it is
|
||||
additionally possible and sometimes wanted to close the combo box popup
|
||||
window This can be achived with `zr_combo_close`.
|
||||
|
||||
combo box API
|
||||
zr_combo_begin -- begins the combo box popup window
|
||||
zr_combo_close -- closes the previously opened combo box
|
||||
zr_combo_end -- ends the combo box build up process
|
||||
zr_combo -- shorthand version for a text based combo box
|
||||
*/
|
||||
void zr_combo(struct zr_context*, const char **entries,
|
||||
zr_size count, zr_size *current, zr_size row_height,
|
||||
zr_state *active);
|
||||
/* this function creates a standart text based combobox
|
||||
Input:
|
||||
- parent window layout the combo box will be placed into
|
||||
- string array of all items inside the combo box
|
||||
- number of items inside the string array
|
||||
- the index of the currently selected item
|
||||
- the height of every widget inside the combobox
|
||||
- the current state of the combobox
|
||||
- the scrollbar offset of the window scrollbar
|
||||
Output:
|
||||
- updated currently selected index
|
||||
- updated state of the combo box
|
||||
*/
|
||||
void zr_combo_begin(struct zr_context *parent,
|
||||
struct zr_context *combo, const char *selected,
|
||||
zr_state *active);
|
||||
/* this function begins the combobox build up process
|
||||
Input:
|
||||
- parent window layout the combo box will be placed into
|
||||
- ouput combo box window layout which will be needed to fill the combo box
|
||||
- title of the combo box or in the case of the text combo box the selected item
|
||||
- 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_close(struct zr_context *combo);
|
||||
/* this function closes a opened combobox */
|
||||
void zr_combo_end(struct zr_context *parent, struct zr_context *combo);
|
||||
/* this function ends the combobox build up process */
|
||||
/*----------------------------------------------------------------
|
||||
* MENU
|
||||
* --------------------------------------------------------------
|
||||
MENU
|
||||
The menu widget provides a overlapping popup window which can
|
||||
be opened/closed by clicking on the menu button. It is normally
|
||||
placed at the top of the window and is independent of the parent
|
||||
scrollbar offset. But if needed the menu can even be placed inside the window.
|
||||
At the moment the menu only allows a single depth but that will change
|
||||
in the future.
|
||||
|
||||
menu widget API
|
||||
zr_menu_begin -- begins the menu item build up processs
|
||||
zr_menu_push -- adds a item into the menu
|
||||
zr_menu_end -- ends the menu item build up process
|
||||
zr_menu -- shorthand retain mode array version
|
||||
*/
|
||||
void zr_menu_begin(struct zr_context *parent,
|
||||
struct zr_context *menu, const char *title,
|
||||
zr_float width, zr_state *active);
|
||||
/* this function begins the menu build up process
|
||||
Input:
|
||||
- parent window layout the menu will be placed into
|
||||
- ouput menu window layout
|
||||
- title of the menu to
|
||||
- the current state of the menu with either zr_true (open) or zr_false else
|
||||
*/
|
||||
zr_bool zr_menu_item(struct zr_context *menu, enum zr_text_align align, const char*);
|
||||
/* this function execute a menu item
|
||||
Input:
|
||||
- title of the item
|
||||
Output
|
||||
- `zr_true` if has been clicked `zr_false` otherwise
|
||||
*/
|
||||
void zr_menu_close(struct zr_context *menu);
|
||||
/* this function closes a opened menu */
|
||||
zr_state zr_menu_end(struct zr_context *parent, struct zr_context *menu);
|
||||
/* this function ends the menu build up process */
|
||||
/* this function pops the graph from being used */
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* TREE
|
||||
|
|
Loading…
Reference in New Issue