diff --git a/demo/demo.c b/demo/demo.c index 81923be..af1f0a5 100644 --- a/demo/demo.c +++ b/demo/demo.c @@ -55,7 +55,8 @@ struct demo_gui { void *memory; struct show_window show; struct control_window control; - gui_command_buffer buffer; + gui_command_buffer show_buffer; + gui_command_buffer control_buffer; struct gui_stack stack; struct gui_config config; struct gui_font font; @@ -200,7 +201,7 @@ update_flags(struct gui_panel_layout *panel, struct control_window *control) gui_size n = 0; gui_flags res = 0; gui_flags i = 0x01; - const char *options[] = {"Hidden", "Border", "Minimizable", "Closeable", "Moveable", "Scaleable"}; + const char *options[]={"Hidden","Border","Minimizable","Closeable","Moveable","Scaleable"}; gui_panel_row(panel, 30, 2); do { if (gui_panel_check(panel, options[n++], (control->show_flags & i) ? gui_true : gui_false)) @@ -359,26 +360,28 @@ init_demo(struct demo_gui *gui, struct gui_font *font) struct gui_config *config = &gui->config; gui->font = *font; gui->running = gui_true; - gui_command_buffer_init_fixed(&gui->buffer, gui->memory, MAX_MEMORY); + gui_command_buffer_init_fixed(&gui->show_buffer, gui->memory, MAX_MEMORY/2); + gui_command_buffer_init_fixed(&gui->control_buffer, + GUI_PTR_ADD(void*, gui->memory, (MAX_MEMORY/2)), MAX_MEMORY/2); gui_config_default(config, font); gui_stack_clear(&gui->stack); - /*init_show(&gui->show, config, &gui->buffer, &gui->stack);*/ - init_control(&gui->control, config, &gui->buffer, &gui->stack); + init_show(&gui->show, config, &gui->show_buffer, &gui->stack); + init_control(&gui->control, config, &gui->control_buffer, &gui->stack); + gui->show.hook.flags |= GUI_PANEL_HIDDEN; } static void run_demo(struct demo_gui *gui, struct gui_input *input) { struct control_window *control = &gui->control; + struct show_window *show = &gui->show; gui->running = update_control(control, &gui->stack, input, &gui->config); /* Show window */ - /* - show->hook.panel.flags = control->show_flags; + show->hook.flags = control->show_flags; update_show(show, &gui->stack, input); - if (show->hook.panel.flags & GUI_PANEL_HIDDEN) + if (show->hook.flags & GUI_PANEL_HIDDEN) control->show_flags |= GUI_PANEL_HIDDEN; - */ } diff --git a/gui.c b/gui.c index 193a55b..fa721f4 100644 --- a/gui.c +++ b/gui.c @@ -1387,6 +1387,8 @@ gui_panel_begin(struct gui_panel_layout *l, struct gui_panel *p, /* check arguments */ if (!p || !p->buffer || !l) return gui_false; + if (!(p->flags & GUI_PANEL_TAB)) + gui_command_buffer_reset(p->buffer); if (p->flags & GUI_PANEL_HIDDEN) { zero(l, sizeof(*l)); l->valid = gui_false; @@ -1459,8 +1461,6 @@ gui_panel_begin(struct gui_panel_layout *l, struct gui_panel *p, l->row_columns = 0; l->row_height = 0; l->offset = p->offset; - if (!(p->flags & GUI_PANEL_TAB)) - gui_command_buffer_reset(l->buffer); if (!(p->flags & GUI_PANEL_NO_HEADER)) { header = &c->colors[GUI_COLOR_HEADER]; diff --git a/gui.h b/gui.h index 5c6994c..0223f54 100644 --- a/gui.h +++ b/gui.h @@ -594,8 +594,8 @@ void gui_panel_row(struct gui_panel_layout*, gui_float height, gui_size cols); gui_bool gui_panel_widget(struct gui_rect*, struct gui_panel_layout*); void gui_panel_spacing(struct gui_panel_layout*, gui_size cols); void gui_panel_text(struct gui_panel_layout*, const char*, gui_size, enum gui_text_align); -void gui_panel_text_colored(struct gui_panel_layout*, const char*, gui_size, enum gui_text_align, - struct gui_color color); +void gui_panel_text_colored(struct gui_panel_layout*, const char*, gui_size, + enum gui_text_align, struct gui_color color); void gui_panel_label(struct gui_panel_layout*, const char*, enum gui_text_align); void gui_panel_label_colored(struct gui_panel_layout*, const char*, enum gui_text_align, struct gui_color color); @@ -626,7 +626,7 @@ gui_size gui_panel_selector(struct gui_panel_layout*, const char *items[], gui_size item_count, gui_size item_current); void gui_panel_graph_begin(struct gui_panel_layout*, struct gui_graph*, enum gui_graph_type, gui_size count, gui_float min_value, gui_float max_value); -gui_bool gui_panel_graph_push(struct gui_panel_layout *layout, struct gui_graph*, gui_float); +gui_bool gui_panel_graph_push(struct gui_panel_layout *layout,struct gui_graph*,gui_float); void gui_panel_graph_end(struct gui_panel_layout *layout, struct gui_graph*); gui_int gui_panel_graph(struct gui_panel_layout*, enum gui_graph_type, const gui_float *values, gui_size count, gui_size offset);