ui/common/context.c

changeset 168
1b99acacc5bb
parent 167
161511838ea6
child 169
fe49cff3c571
equal deleted inserted replaced
167:161511838ea6 168:1b99acacc5bb
393 ctx->close_callback = fnc; 393 ctx->close_callback = fnc;
394 ctx->close_data = udata; 394 ctx->close_data = udata;
395 } 395 }
396 396
397 397
398
399 void ui_set_group(UiContext *ctx, int group) { 398 void ui_set_group(UiContext *ctx, int group) {
400 if(ucx_list_find(ctx->groups, (void*)(intptr_t)group, NULL, NULL) == -1) { 399 if(ucx_list_find(ctx->groups, (void*)(intptr_t)group, NULL, NULL) == -1) {
401 ctx->groups = ucx_list_append_a(ctx->mempool->allocator, ctx->groups, (void*)(intptr_t)group); 400 ctx->groups = ucx_list_append_a(ctx->mempool->allocator, ctx->groups, (void*)(intptr_t)group);
402 } 401 }
403 402
454 if(check[i] == 0) { 453 if(check[i] == 0) {
455 enable = 0; 454 enable = 0;
456 break; 455 break;
457 } 456 }
458 } 457 }
459 ui_set_enabled(gw->widget, enable); 458 gw->enable(gw->widget, enable);
460 } 459 }
461 460
462 if(groups) { 461 if(groups) {
463 free(groups); 462 free(groups);
464 } 463 }
465 } 464 }
466 465
467 void uic_add_group_widget(UiContext *ctx, void *widget, UcxList *groups) { 466 void ui_widget_set_groups(UiContext *ctx, UIWIDGET widget, ui_enablefunc enable, ...) {
467 // get groups
468 UcxList *groups = NULL;
469 va_list ap;
470 va_start(ap, enable);
471 int group;
472 while((group = va_arg(ap, int)) != -1) {
473 groups = ucx_list_append(groups, (void*)(intptr_t)group);
474 }
475 va_end(ap);
476
477 uic_add_group_widget(ctx, widget, enable, groups);
478
479 ucx_list_free(groups);
480 }
481
482 void uic_add_group_widget(UiContext *ctx, void *widget, ui_enablefunc enable, UcxList *groups) {
468 UcxMempool *mp = ctx->mempool; 483 UcxMempool *mp = ctx->mempool;
469 UiGroupWidget *gw = ucx_mempool_malloc(mp, sizeof(UiGroupWidget)); 484 UiGroupWidget *gw = ucx_mempool_malloc(mp, sizeof(UiGroupWidget));
470 485
471 gw->widget = widget; 486 gw->widget = widget;
487 gw->enable = enable;
472 gw->numgroups = ucx_list_size(groups); 488 gw->numgroups = ucx_list_size(groups);
473 gw->groups = ucx_mempool_calloc(mp, gw->numgroups, sizeof(int)); 489 gw->groups = ucx_mempool_calloc(mp, gw->numgroups, sizeof(int));
474 int i = 0; 490 int i = 0;
475 UCX_FOREACH(elm, groups) { 491 UCX_FOREACH(elm, groups) {
476 gw->groups[i++] = (intptr_t)elm->data; 492 gw->groups[i++] = (intptr_t)elm->data;

mercurial