#include <stdio.h>
#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) {
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) {
if(!toplevel) {
return NULL;
}
UiObject *obj = toplevel;
while(obj->next) {
obj = obj->next;
}
return obj;
}
UiContainer* uic_get_current_container(UiObject *obj) {
return uic_current_obj(obj)->container;
}