ui/common/object.c

changeset 33
458831c574f4
parent 5
19d37cb9c96c
child 52
25e5390cce41
equal deleted inserted replaced
32:9a5f47fbc5c3 33:458831c574f4
28 28
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <stdlib.h> 30 #include <stdlib.h>
31 31
32 #include "object.h" 32 #include "object.h"
33 #include "context.h"
34
35 void ui_end(UiObject *obj) {
36 if(!obj->next) {
37 return;
38 }
39
40 UiObject *prev = NULL;
41 while(obj->next) {
42 prev = obj;
43 obj = obj->next;
44 }
45
46 if(prev) {
47 // TODO: free last obj
48 prev->next = NULL;
49 }
50 }
51
52
53 UiObject* uic_object_new(UiObject *toplevel, UIWIDGET widget) {
54 UiContext *ctx = toplevel->ctx;
55
56 UiObject *newobj = ucx_mempool_calloc(ctx->mempool, 1, sizeof(UiObject));
57 newobj->ctx = ctx;
58 newobj->widget = widget;
59
60 return newobj;
61 }
62
63 void uic_obj_add(UiObject *toplevel, UiObject *ctobj) {
64 UiObject *current = uic_current_obj(toplevel);
65 current->next = ctobj;
66 }
67
68 UiObject* uic_current_obj(UiObject *toplevel) {
69 UiObject *obj = toplevel;
70 while(obj->next) {
71 obj = obj->next;
72 }
73 return obj;
74 }
33 75
34 UiContainer* uic_get_current_container(UiObject *obj) { 76 UiContainer* uic_get_current_container(UiObject *obj) {
35 // TODO 77 return uic_current_obj(obj)->container;
36 return obj->container;
37 } 78 }

mercurial