ui/common/object.c

changeset 33
458831c574f4
parent 5
19d37cb9c96c
child 52
25e5390cce41
--- a/ui/common/object.c	Sat Apr 12 13:44:53 2014 +0200
+++ b/ui/common/object.c	Sat May 10 15:43:22 2014 +0200
@@ -30,8 +30,49 @@
 #include <stdlib.h>
 
 #include "object.h"
+#include "context.h"
+
+void ui_end(UiObject *obj) {
+    if(!obj->next) {
+        return;
+    }
+    
+    UiObject *prev = NULL;
+    while(obj->next) {
+        prev = obj;
+        obj = obj->next;
+    }
+    
+    if(prev) {
+        // TODO: free last obj
+        prev->next = NULL;
+    }
+}
+
+
+UiObject* uic_object_new(UiObject *toplevel, UIWIDGET widget) {
+    UiContext *ctx = toplevel->ctx;
+    
+    UiObject *newobj = ucx_mempool_calloc(ctx->mempool, 1, sizeof(UiObject));
+    newobj->ctx = ctx;
+    newobj->widget = widget;
+    
+    return newobj;
+}
+
+void uic_obj_add(UiObject *toplevel, UiObject *ctobj) {
+    UiObject *current = uic_current_obj(toplevel);
+    current->next = ctobj;
+}
+
+UiObject* uic_current_obj(UiObject *toplevel) {
+    UiObject *obj = toplevel;
+    while(obj->next) {
+        obj = obj->next;
+    }
+    return obj;
+}
 
 UiContainer* uic_get_current_container(UiObject *obj) {
-    // TODO
-    return obj->container;
+    return uic_current_obj(obj)->container;
 }

mercurial