ui/common/context.c

changeset 51
e324291ca9f8
parent 49
2f71f4ee247a
--- a/ui/common/context.c	Sun Oct 06 18:43:06 2024 +0200
+++ b/ui/common/context.c	Sun Oct 20 21:24:13 2024 +0200
@@ -162,7 +162,7 @@
 
 static UiVar* ctx_getvar(UiContext *ctx, CxHashKey key) {
     UiVar *var = cxMapGet(ctx->vars, key);
-    if(!var) {
+    if(!var && ctx->documents) {
         CxIterator i = cxListIterator(ctx->documents);
         cx_foreach(void *, doc, i) {
             UiContext *subctx = ui_document_context(doc);
@@ -243,6 +243,9 @@
             val = ui_range_new(ctx, NULL);
             break;
         }
+        case UI_VAR_GENERIC: {
+            val = ui_generic_new(ctx, NULL);
+        }
     }
     return val;
 }
@@ -343,6 +346,14 @@
             t->set(t, t->value);
             break;
         }
+        case UI_VAR_GENERIC: {
+            UiGeneric *f = fromvalue;
+            UiGeneric *t = to->value;
+            if(!f->obj) break;
+            uic_generic_copy(f, t);
+            t->set(t, t->value, t->type);
+            break;
+        }
     }
 }
 
@@ -355,6 +366,7 @@
         case UI_VAR_TEXT: uic_text_save(var->value); break;
         case UI_VAR_LIST: break;
         case UI_VAR_RANGE: uic_range_save(var->value); break;
+        case UI_VAR_GENERIC: uic_generic_save(var->value); break;
     }
 }
 
@@ -367,6 +379,7 @@
         case UI_VAR_TEXT: uic_text_unbind(var->value); break;
         case UI_VAR_LIST: uic_list_unbind(var->value); break;
         case UI_VAR_RANGE: uic_range_unbind(var->value); break;
+        case UI_VAR_GENERIC: uic_generic_unbind(var->value); break;
     }
 }
 
@@ -528,6 +541,10 @@
     cxListAdd(ctx->group_widgets, &gw);
 }
 
+UIEXPORT void *ui_ctx_allocator(UiContext *ctx) {
+    return (void*) ctx ? ctx->allocator : NULL;
+}
+
 void* ui_malloc(UiContext *ctx, size_t size) {
     return ctx ? cxMalloc(ctx->allocator, size) : NULL;
 }

mercurial