47 // TODO: free last obj |
49 // TODO: free last obj |
48 prev->next = NULL; |
50 prev->next = NULL; |
49 } |
51 } |
50 } |
52 } |
51 |
53 |
|
54 void ui_end_new(UiObject *obj) { |
|
55 if(!obj->container_end) { |
|
56 return; |
|
57 } |
|
58 UiContainerX *rm = obj->container_end; |
|
59 uic_object_pop_container(obj); |
|
60 ui_free(obj->ctx, rm); |
|
61 } |
|
62 |
52 void ui_object_ref(UiObject *obj) { |
63 void ui_object_ref(UiObject *obj) { |
53 obj->ref++; |
64 obj->ref++; |
54 } |
65 } |
55 |
66 |
56 void ui_object_unref(UiObject *obj) { |
67 int ui_object_unref(UiObject *obj) { |
57 // it is possible to have 0 references, in case |
68 // it is possible to have 0 references, in case |
58 // a window was created but ui_show was never called |
69 // a window was created but ui_show was never called |
59 if(obj->ref == 0 || --obj->ref == 0) { |
70 if(obj->ref == 0 || --obj->ref == 0) { |
60 if(obj->destroy) { |
71 if(obj->destroy) { |
61 obj->destroy(obj); |
72 obj->destroy(obj); |
62 } else { |
|
63 uic_object_destroy(obj); |
|
64 } |
73 } |
|
74 uic_object_destroy(obj); |
|
75 return 0; |
65 } |
76 } |
|
77 return 1; |
66 } |
78 } |
67 |
79 |
68 void uic_object_destroy(UiObject *obj) { |
80 void uic_object_destroy(UiObject *obj) { |
69 if(obj->ctx->close_callback) { |
81 if(obj->ctx->close_callback) { |
70 UiEvent ev; |
82 UiEvent ev; |
107 } |
119 } |
108 |
120 |
109 UiContainer* uic_get_current_container(UiObject *obj) { |
121 UiContainer* uic_get_current_container(UiObject *obj) { |
110 return uic_current_obj(obj)->container; |
122 return uic_current_obj(obj)->container; |
111 } |
123 } |
|
124 |
|
125 void uic_object_push_container(UiObject *toplevel, UiContainerX *newcontainer) { |
|
126 newcontainer->prev = toplevel->container_end; |
|
127 if(toplevel->container_end) { |
|
128 toplevel->container_end->next = newcontainer; |
|
129 toplevel->container_end = newcontainer; |
|
130 } else { |
|
131 toplevel->container_begin = newcontainer; |
|
132 toplevel->container_end = newcontainer; |
|
133 } |
|
134 } |
|
135 |
|
136 void uic_object_pop_container(UiObject *toplevel) { |
|
137 toplevel->container_end = toplevel->container_end->prev; |
|
138 if(toplevel->container_end) { |
|
139 toplevel->container_end->next = NULL; |
|
140 } else { |
|
141 toplevel->container_begin = NULL; |
|
142 } |
|
143 } |