| 53 return container; |
53 return container; |
| 54 } |
54 } |
| 55 |
55 |
| 56 cxmutstr ui_container_args_to_string(UiContext *ctx, UiContainerArgs *args) { |
56 cxmutstr ui_container_args_to_string(UiContext *ctx, UiContainerArgs *args) { |
| 57 CxBuffer buf; |
57 CxBuffer buf; |
| 58 cxBufferInit(&buf, NULL, 256, ctx->allocator, CX_BUFFER_AUTO_EXTEND | CX_BUFFER_FREE_CONTENTS); |
58 cxBufferInit(&buf, ctx->allocator, NULL, 256, CX_BUFFER_AUTO_EXTEND | CX_BUFFER_FREE_CONTENTS); |
| 59 |
59 |
| 60 cxBufferPutString(&buf, "{"); |
60 cxBufferPutString(&buf, "{"); |
| 61 |
61 |
| 62 UI_STANDARD_ARGS(&buf, args); |
62 UI_STANDARD_ARGS(&buf, args); |
| 63 UI_SPACING_ARGS(&buf, args); |
63 UI_SPACING_ARGS(&buf, args); |
| 77 const CxAllocator *a = obj->ctx->allocator; |
77 const CxAllocator *a = obj->ctx->allocator; |
| 78 UiWidget *widget = cxZalloc(a, sizeof(UiWidget)); |
78 UiWidget *widget = cxZalloc(a, sizeof(UiWidget)); |
| 79 widget->obj = obj->widget->obj; |
79 widget->obj = obj->widget->obj; |
| 80 widget->type = cx_str(type); |
80 widget->type = cx_str(type); |
| 81 widget->args = ui_container_args_to_string(obj->ctx, args); |
81 widget->args = ui_container_args_to_string(obj->ctx, args); |
| 82 widget->children = cxLinkedListCreate(a, NULL, CX_STORE_POINTERS); |
82 widget->children = cxLinkedListCreate(a, CX_STORE_POINTERS); |
| 83 widget->serialize = ui_container_serialize; |
83 widget->serialize = ui_container_serialize; |
| 84 |
84 |
| 85 UiWidget *parent = obj->container_end->container; |
85 UiWidget *parent = obj->container_end->container; |
| 86 cxListAdd(parent->children, widget); |
86 cxListAdd(parent->children, widget); |
| 87 |
87 |
| 107 } |
107 } |
| 108 } |
108 } |
| 109 |
109 |
| 110 cxmutstr ui_container_serialize(UiWidget *w) { |
110 cxmutstr ui_container_serialize(UiWidget *w) { |
| 111 CxBuffer buf; |
111 CxBuffer buf; |
| 112 cxBufferInit(&buf, NULL, 1024, NULL, CX_BUFFER_AUTO_EXTEND | CX_BUFFER_FREE_CONTENTS); |
112 cxBufferInit(&buf, cxDefaultAllocator, NULL, 1024, CX_BUFFER_AUTO_EXTEND | CX_BUFFER_FREE_CONTENTS); |
| 113 |
113 |
| 114 cxBufferPutString(&buf, "{"); |
114 cxBufferPutString(&buf, "{"); |
| 115 ui_serialize_type_obj_id(w, &buf); |
115 ui_serialize_type_obj_id(w, &buf); |
| 116 cxBufferPutString(&buf, ",\"args\":"); |
116 cxBufferPutString(&buf, ",\"args\":"); |
| 117 cxBufferPutString(&buf, w->args.ptr); |
117 cxBufferPutString(&buf, w->args.ptr); |