fixed multiple windows with opened popups

This commit is contained in:
vurtun 2015-11-21 12:19:22 +01:00
parent 297e271915
commit da8ce2e673
3 changed files with 8 additions and 48 deletions

View File

@ -69,7 +69,6 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
static int graph_state = ZR_MINIMIZED;
static int style_state = ZR_MINIMIZED;
static int group_state = ZR_MINIMIZED;
static int shelf_state = ZR_MINIMIZED;
static int splitter_state = ZR_MINIMIZED;
/* popups */
@ -774,41 +773,6 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_layout_pop(&layout);
}
if (zr_layout_push(&layout, ZR_LAYOUT_TAB, "Shelf", &shelf_state))
{
static const char *tabs[] = {"Up","Down","Left","Right"};
static int active = 0;
static struct zr_vec2 scrollbar;
struct zr_context tab;
zr_layout_row_dynamic(&layout, 140, 1);
zr_shelf_begin(&layout, &tab, tabs, LEN(tabs), &active, scrollbar);
zr_layout_row_static(&tab, 50, 50, 4);
if (active == 0) {
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_UP, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_DOWN, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_LEFT, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_RIGHT, ZR_BUTTON_DEFAULT);
} else if (active == 1) {
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_DOWN, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_LEFT, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_RIGHT, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_UP, ZR_BUTTON_DEFAULT);
} else if (active == 2) {
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_LEFT, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_RIGHT, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_UP, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_DOWN, ZR_BUTTON_DEFAULT);
} else if (active == 3) {
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_RIGHT, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_UP, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_DOWN, ZR_BUTTON_DEFAULT);
zr_button_symbol(&tab, ZR_SYMBOL_TRIANGLE_LEFT, ZR_BUTTON_DEFAULT);
}
zr_shelf_end(&layout, &tab, &scrollbar);
zr_layout_pop(&layout);
}
if (zr_layout_push(&layout, ZR_LAYOUT_TAB, "Splitter", &splitter_state))
{
static int vertical_state = ZR_MINIMIZED;
@ -1036,10 +1000,6 @@ init_demo(struct demo *gui)
gui->config_white.colors[ZR_COLOR_SCROLLBAR_CURSOR_ACTIVE] = zr_rgba(160, 160, 160, 255);
gui->config_white.colors[ZR_COLOR_TABLE_LINES] = zr_rgba(100, 100, 100, 255);
gui->config_white.colors[ZR_COLOR_TAB_HEADER] = zr_rgba(180, 180, 180, 255);
gui->config_white.colors[ZR_COLOR_SHELF] = zr_rgba(150, 150, 150, 255);
gui->config_white.colors[ZR_COLOR_SHELF_TEXT] = zr_rgba(0, 0, 0, 255);
gui->config_white.colors[ZR_COLOR_SHELF_ACTIVE] = zr_rgba(180, 180, 180, 255);
gui->config_white.colors[ZR_COLOR_SHELF_ACTIVE_TEXT] = zr_rgba(0, 0, 0, 255);
gui->config_white.colors[ZR_COLOR_SCALER] = zr_rgba(100, 100, 100, 255);
/* windows */

View File

@ -1973,14 +1973,14 @@ zr_command_queue_start_child(struct zr_command_queue *queue,
buf->end = buffer->end;
buf->parent_last = buffer->last;
buf->last = buf->begin;
buf->next = 0;
/* add first sub-buffer into the stack */
stack = &queue->stack;
stack->count++;
if (!stack->begin) {
buf->next = 0;
stack->begin = offset;
stack->end = offset;
stack->count = 1;
return zr_true;
}
@ -1988,8 +1988,7 @@ zr_command_queue_start_child(struct zr_command_queue *queue,
size = queue->buffer.memory.size;
end = zr_ptr_add(struct zr_command_sub_buffer, memory, (size - stack->end));
end->next = offset;
buf->next = offset;
stack->count++;
stack->end = offset;
return zr_true;
}
@ -2050,15 +2049,16 @@ zr_command_queue_finish(struct zr_command_queue *queue,
iter = zr_ptr_add(struct zr_command_sub_buffer, memory, (size - stack->begin));
/* fix buffer command list for subbuffers */
for (i = 0; i < stack->count; ++i) {
for (i = 0; i < queue->stack.count; ++i) {
struct zr_command *parent_last, *sublast, *last;
parent_last = zr_ptr_add(struct zr_command, memory, iter->parent_last);
sublast = zr_ptr_add(struct zr_command, memory, iter->last);
last = zr_ptr_add(struct zr_command, memory, buffer->last);
/* redirect the subbuffer to the end of the current command buffer */
parent_last->next = iter->end;
if (i == (stack->count - 1))
if (i == (queue->stack.count-1))
sublast->next = last->next;
last->next = iter->begin;
buffer->last = iter->last;
@ -2066,6 +2066,8 @@ zr_command_queue_finish(struct zr_command_queue *queue,
iter = zr_ptr_add(struct zr_command_sub_buffer, memory, size - iter->next);
}
queue->stack.count = 0;
queue->stack.begin = 0;
queue->stack.end = 0;
}
void

View File

@ -2951,7 +2951,6 @@ void zr_spinner_float(struct zr_context*, float min, float *value, float max,
- the from user input updated spinner value
- current state of the editbox with active(zr_true) or inactive(zr_false)
*/
/* --------------------------------------------------------------
*
* COMBO BOX
@ -3195,7 +3194,6 @@ void zr_popup_end(struct zr_context *parent, struct zr_context *popup,
Output:
- The from user input updated popup scrollbar pixel offset
*/
/* --------------------------------------------------------------
*
* CONTEXTUAL