| 105 uic_object_destroyed(obj); |
104 uic_object_destroyed(obj); |
| 106 cxMempoolFree(obj->ctx->mp); |
105 cxMempoolFree(obj->ctx->mp); |
| 107 } |
106 } |
| 108 |
107 |
| 109 UiObject* uic_object_new_toplevel(void) { |
108 UiObject* uic_object_new_toplevel(void) { |
| |
109 fflush(stdout); |
| 110 CxMempool *mp = cxMempoolCreateSimple(256); |
110 CxMempool *mp = cxMempoolCreateSimple(256); |
| 111 UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); |
111 UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); |
| |
112 fflush(stdout); |
| 112 obj->ctx = uic_context(obj, mp); |
113 obj->ctx = uic_context(obj, mp); |
| 113 obj->ctx->parent = ui_global_context(); |
114 obj->ctx->parent = ui_global_context(); |
| |
115 fflush(stdout); |
| 114 uic_object_created(obj); |
116 uic_object_created(obj); |
| |
117 fflush(stdout); |
| 115 return obj; |
118 return obj; |
| 116 } |
119 } |
| 117 |
120 |
| 118 UiObject* uic_ctx_object_new(UiContext *ctx, UIWIDGET widget) { |
121 UiObject* uic_ctx_object_new(UiContext *ctx, UIWIDGET widget) { |
| 119 UiObject *newobj = cxCalloc(ctx->allocator, 1, sizeof(UiObject)); |
122 UiObject *newobj = cxCalloc(ctx->allocator, 1, sizeof(UiObject)); |
| 139 if(toplevel->container_end) { |
142 if(toplevel->container_end) { |
| 140 toplevel->container_end->next = NULL; |
143 toplevel->container_end->next = NULL; |
| 141 } else { |
144 } else { |
| 142 toplevel->container_begin = NULL; |
145 toplevel->container_begin = NULL; |
| 143 } |
146 } |
| |
147 |
| |
148 // TODO: free container? |
| 144 } |
149 } |
| |
150 |
| |
151 /* |
| |
152 * This might look like a weird function, but in case a container creates a |
| |
153 * sub-container, 2 container objects are added to the list, however we want |
| |
154 * only one container, otherwise ui_container_finish() would not work |
| |
155 */ |
| |
156 void uic_object_remove_second_last_container(UiObject *toplevel) { |
| |
157 if(toplevel->container_end && toplevel->container_end->prev) { |
| |
158 UiContainerX *end = toplevel->container_end; |
| |
159 UiContainerX *rm = toplevel->container_end->prev; |
| |
160 |
| |
161 end->prev = rm->prev; |
| |
162 if(rm->prev) { |
| |
163 rm->prev->next = end; |
| |
164 } else { |
| |
165 toplevel->container_begin = end; |
| |
166 } |
| |
167 |
| |
168 // TODO: free container? |
| |
169 } else { |
| |
170 fprintf(stderr, "Error: uic_object_remove_second_last_container expected at least 2 containers\n"); |
| |
171 } |
| |
172 } |