ui/common/object.c

branch
newapi
changeset 404
384f6d1f5784
parent 384
8be7fd628fbc
child 406
0ebf9d7b23e8
--- a/ui/common/object.c	Sat Nov 30 20:33:16 2024 +0100
+++ b/ui/common/object.c	Wed Dec 04 08:55:49 2024 +0100
@@ -32,6 +32,8 @@
 #include "object.h"
 #include "context.h"
 
+#include "../ui/container.h"
+
 void ui_end(UiObject *obj) {
     if(!obj->next) {
         return;
@@ -49,6 +51,15 @@
     }
 }
 
+void ui_end_new(UiObject *obj) {
+    if(!obj->container_end) {
+        return;
+    }
+    UiContainerX *rm = obj->container_end;
+    uic_object_pop_container(obj);
+    ui_free(obj->ctx, rm);
+}
+
 void ui_object_ref(UiObject *obj) {
     obj->ref++;
 }
@@ -109,3 +120,23 @@
 UiContainer* uic_get_current_container(UiObject *obj) {
     return uic_current_obj(obj)->container;
 }
+
+void uic_object_push_container(UiObject *toplevel, UiContainerX *newcontainer) {
+    newcontainer->prev = toplevel->container_end;
+    if(toplevel->container_end) {
+        toplevel->container_end->next = newcontainer;
+        toplevel->container_end = newcontainer;
+    } else {
+        toplevel->container_begin = newcontainer;
+        toplevel->container_end = newcontainer;
+    }
+}
+
+void uic_object_pop_container(UiObject *toplevel) {
+    toplevel->container_end = toplevel->container_end->prev;
+    if(toplevel->container_end) {
+        toplevel->container_end->next = NULL;
+    } else {
+        toplevel->container_begin = NULL;
+    }
+}

mercurial