Sun, 28 Sep 2025 20:09:08 +0200
add UI_STRING_EDITABLE model type (GTK)
| application/main.c | file | annotate | diff | comparison | revisions | |
| ui/gtk/list.c | file | annotate | diff | comparison | revisions | |
| ui/gtk/toolkit.c | file | annotate | diff | comparison | revisions | |
| ui/ui/tree.h | file | annotate | diff | comparison | revisions |
--- a/application/main.c Wed Sep 24 21:33:33 2025 +0200 +++ b/application/main.c Sun Sep 28 20:09:08 2025 +0200 @@ -459,11 +459,17 @@ case 3: return ui_foldericon(16); case 4: return ui_fileicon(16); case 5: return "file"; + case 6: return (void*)(intptr_t)123; + case 7: return "edit me"; + case 8: return "edit me too"; } return NULL; } UiBool table_getstyle(UiList *list, void *elm, int row, int col, void *userdata, UiTextStyle *style) { + if(col > 6) { + return FALSE; + } if(row < 2 && col != -1) { style->text_style = UI_TEXT_STYLE_BOLD; if(col == 2) { @@ -649,7 +655,7 @@ } } ui_tab(obj, "Tab 1") { - UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "col1", UI_INTEGER, "col2", UI_ICON, "col3", UI_ICON_TEXT, "col4", UI_INTEGER, "col5", -1); + UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "col1", UI_INTEGER, "col2", UI_ICON, "col3", UI_ICON_TEXT, "col4", UI_INTEGER, "col5", UI_STRING_EDITABLE, "edit6", UI_STRING_EDITABLE, "edit7", -1); model->columnsize[0] = -1; ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .fill = TRUE, .contextmenu = menubuilder, .multiselection = TRUE, .fill = TRUE, .getvalue = table_getvalue, .getstyle = table_getstyle,
--- a/ui/gtk/list.c Wed Sep 24 21:33:33 2025 +0200 +++ b/ui/gtk/list.c Sun Sep 28 20:09:08 2025 +0200 @@ -159,6 +159,10 @@ } else if(type == UI_ICON) { GtkWidget *image = gtk_image_new(); gtk_list_item_set_child(item, image); + } else if(type == UI_STRING_EDITABLE) { + GtkWidget *textfield = gtk_entry_new(); + gtk_widget_add_css_class(textfield, "ui-table-entry"); + gtk_list_item_set_child(item, textfield); } else { GtkWidget *label = gtk_label_new(NULL); gtk_label_set_xalign(GTK_LABEL(label), 0); @@ -293,6 +297,10 @@ } break; } + case UI_STRING_EDITABLE: { + ENTRY_SET_TEXT(child, data); + break; + } } if(attributes != listview->current_row_attributes) {