diff -r 9a5f47fbc5c3 -r 458831c574f4 ui/common/object.c --- 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 #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; }