ui/common/context.c

changeset 3
c04433993fbb
parent 2
ea89bbb0c4c8
--- a/ui/common/context.c	Thu Dec 10 13:43:25 2020 +0100
+++ b/ui/common/context.c	Fri Dec 11 11:46:19 2020 +0100
@@ -395,7 +395,6 @@
 }
 
 
-
 void ui_set_group(UiContext *ctx, int group) {
     if(ucx_list_find(ctx->groups, (void*)(intptr_t)group, NULL, NULL) == -1) {
         ctx->groups = ucx_list_append_a(ctx->mempool->allocator, ctx->groups, (void*)(intptr_t)group);
@@ -456,7 +455,7 @@
                 break;
             }
         }
-        ui_set_enabled(gw->widget, enable);
+        gw->enable(gw->widget, enable);
     }
     
     if(groups) {
@@ -464,11 +463,28 @@
     }
 }
 
-void uic_add_group_widget(UiContext *ctx, void *widget, UcxList *groups) {
+void ui_widget_set_groups(UiContext *ctx, UIWIDGET widget, ui_enablefunc enable, ...) {
+    // get groups
+    UcxList *groups = NULL;
+    va_list ap;
+    va_start(ap, enable);
+    int group;
+    while((group = va_arg(ap, int)) != -1) {
+        groups = ucx_list_append(groups, (void*)(intptr_t)group);
+    }
+    va_end(ap);
+    
+    uic_add_group_widget(ctx, widget, enable, groups);
+    
+    ucx_list_free(groups);
+}
+
+void uic_add_group_widget(UiContext *ctx, void *widget, ui_enablefunc enable, UcxList *groups) {
     UcxMempool *mp = ctx->mempool;
     UiGroupWidget *gw = ucx_mempool_malloc(mp, sizeof(UiGroupWidget));
     
     gw->widget = widget;
+    gw->enable = enable;
     gw->numgroups = ucx_list_size(groups);
     gw->groups = ucx_mempool_calloc(mp, gw->numgroups, sizeof(int));
     int i = 0;

mercurial