--- a/application/main.c Thu Sep 10 17:36:06 2026 +0200 +++ b/application/main.c Fri Sep 11 17:27:12 2026 +0200 @@ -222,6 +222,7 @@ typedef struct TreeNode { char *name; int depth; + int heading; } TreeNode; int threadfunc(void *data) { @@ -399,28 +400,45 @@ TreeNode *root = malloc(sizeof(TreeNode)); root->name = "Root"; root->depth = 0; + root->heading = 0; ui_list_append(doc->tree, root); TreeNode *node_a = malloc(sizeof(TreeNode)); node_a->name = "Folder"; node_a->depth = 1; + node_a->heading = 0; ui_list_append(doc->tree, node_a); TreeNode *node_a0 = malloc(sizeof(TreeNode)); node_a0->name = "Leaf 1"; node_a0->depth = 2; + node_a0->heading = 0; ui_list_append(doc->tree, node_a0); TreeNode *node_a1 = malloc(sizeof(TreeNode)); node_a1->name = "Leaf 2"; node_a1->depth = 2; + node_a1->heading = 0; ui_list_append(doc->tree, node_a1); TreeNode *node_1 = malloc(sizeof(TreeNode)); node_1->name = "Leaf 3"; node_1->depth = 1; + node_1->heading = 0; ui_list_append(doc->tree, node_1); + TreeNode *root2 = malloc(sizeof(TreeNode)); + root2->name = "Root 2"; + root2->depth = 0; + root2->heading = 1; + ui_list_append(doc->tree, root2); + + TreeNode *node_b = malloc(sizeof(TreeNode)); + node_b->name = "Item"; + node_b->depth = 1; + node_b->heading = 0; + ui_list_append(doc->tree, node_b); + //doc->text = ui_text_new(docctx, "text"); return doc; @@ -575,9 +593,12 @@ return node->name; } -void sourcelist2_getvalue(UiList *list, void *elm, int index, UiSubListItem *item, void *userdata) { +void sourcelist2_getvalue(UiList *list, void *elm, int index, UiSourceListItem *item, void *userdata) { TreeNode *node = elm; - item->label = node->name; + item->label = strdup(node->name); + item->button_icon = strdup("call-start"); + item->depth = node->depth; + item->is_header = node->heading; } int tree_getdepth(UiList *list, void *elm, int row, void *userdata) { @@ -593,6 +614,10 @@ item->eventdata = sublistdata; } +void sourcelist2_activate(UiEvent *event, void *userdata) { + printf("sourcelist2 activate: %d\n", event->intval); +} + typedef struct Item { UiObject *obj; MyDocument *doc; @@ -958,7 +983,7 @@ //UiModel *model = ui_model(obj->ctx, UI_STRING, "test", -1); //ui_treeview(obj, .fill = TRUE, .model = model, .show_header = TRUE, .getvalue = tree_getvalue, .getdepth = tree_getdepth, .varname = "tree"); - ui_sourcelist2(obj, .fill = TRUE, .getvalue = sourcelist2_getvalue, .getdepth = tree_getdepth, .varname = "tree"); + ui_sourcelist2(obj, .fill = TRUE, .getvalue = sourcelist2_getvalue, .varname = "tree", .onactivate = sourcelist2_activate); } }