finished stack layered input

This commit is contained in:
vurtun 2015-03-24 19:28:59 +01:00
parent 855e181015
commit 1085f843aa
2 changed files with 16 additions and 5 deletions

17
gui.c
View File

@ -2440,9 +2440,20 @@ gui_begin_panel(struct gui_context *ctx, struct gui_panel *panel,
cpanel = CONTAINER_OF(panel, struct gui_context_panel, panel);
inpanel = INBOX(in->mouse_prev.x,in->mouse_prev.y, cpanel->x, cpanel->y, cpanel->w, cpanel->h);
if (in->mouse_down && in->mouse_clicked && inpanel) {
gui_rm_draw_list(ctx, &cpanel->list);
gui_add_draw_list(ctx, &cpanel->list);
ctx->active = cpanel;
gui_size n = 0;
struct gui_context_panel *p = NULL;
while (n < ctx->panel_size && ctx->panel_lists[n++] != &cpanel->list);
while (n < ctx->panel_size) {
p = CONTAINER_OF(ctx->panel_lists[n], struct gui_context_panel, list);
if (INBOX(in->mouse_prev.x, in->mouse_prev.y, p->x, p->y, p->w, p->h))
break;
n++;
}
if (n >= ctx->panel_size) {
gui_rm_draw_list(ctx, &cpanel->list);
gui_add_draw_list(ctx, &cpanel->list);
ctx->active = cpanel;
}
}
if (ctx->active == cpanel && (flags & GUI_PANEL_MOVEABLE) && (flags & GUI_PANEL_HEADER)) {

View File

@ -408,8 +408,8 @@ main(int argc, char *argv[])
fprintf(stdout, "button pressed!\n");
gui_end_panel(ctx, panel, NULL);
gui_begin_panel(ctx, subpanel, "Subdemo",
GUI_PANEL_HEADER|GUI_PANEL_MINIMIZABLE|GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE);
gui_begin_panel(ctx, subpanel, "Error",
GUI_PANEL_HEADER|GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE);
gui_panel_layout(subpanel, 30, 2);
if (gui_panel_button_text(subpanel, "ok", 2, GUI_BUTTON_SWITCH))
fprintf(stdout, "ok pressed!\n");