application/main.c

changeset 786
150a1180f7ec
parent 783
25b2da0aac15
child 789
d70799b3333e
--- a/application/main.c	Thu Oct 02 14:49:17 2025 +0200
+++ b/application/main.c	Thu Oct 02 14:49:27 2025 +0200
@@ -435,7 +435,8 @@
 
 void action_sourcelist_activate(UiEvent *event, void *userdata) {
     UiSubListEventData *eventdata = event->eventdata;
-    printf("sourcelist %s index %d\n", eventdata->row_data, event->intval);
+    printf("sourcelist %s index %d\n", eventdata->row_data, eventdata->row_index);
+    ui_list_update_row(eventdata->list, eventdata->row_index);
 }
 
 void action_table_activate(UiEvent *event, void *userdata) {
@@ -458,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) {
@@ -563,6 +570,11 @@
     ui_linkbutton_value_set(doc->link, label, uri);
 }
 
+static UiBool list_save(UiList *list, int row, int col, UiCellValue *value, void *userdata) {
+    printf("list new value at [%d, %d]: %s\n", row, col, value->string);
+    return FALSE;
+}
+
 void application_startup(UiEvent *event, void *data) {
     // global list
     UiContext *global = ui_global_context();
@@ -573,7 +585,7 @@
     
     
     
-    UiObject *obj = ui_sidebar_window("Test", NULL);
+    UiObject *obj = ui_splitview_window("Test", TRUE);
     
     MyDocument *doc = create_doc();
     ui_attach_document(obj->ctx, doc);
@@ -585,6 +597,10 @@
                 .onactivate = action_sourcelist_activate);
     }
     
+    ui_right_panel(obj, .margin = 10, .spacing = 10) {
+        ui_button(obj, .label = "Test");
+    }
+    
     ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview", .fill = TRUE) {
         ui_tab(obj, "Tab 0") {
             ui_vbox(obj, .fill = FALSE, .margin = 15, .spacing = 15) {
@@ -607,7 +623,10 @@
                 ui_label(obj, .label = "Label Col 2", .style = UI_LABEL_STYLE_TITLE, .align = UI_ALIGN_RIGHT);
                 ui_newline(obj);
 
-                ui_spinner(obj, .step = 5);
+                ui_spinbox(obj, .step = 5);
+                ui_newline(obj);
+                
+                ui_switch(obj, .varname = "switch");
                 ui_newline(obj);
 
                 ui_progressbar(obj, .colspan = 2, .varname = "progress");
@@ -645,10 +664,10 @@
             }
         }
         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,
+                    .getvalue = table_getvalue, .getstyle = table_getstyle, .onsave = list_save,
                     .onactivate = action_table_activate, .onactivatedata = "activate",
                     .onselection = action_table_activate, .onselectiondata = "selection");
             ui_hbox(obj, .fill = FALSE) {
@@ -710,7 +729,7 @@
         }
         
         ui_tab(obj, "Tab 8") {
-            ui_hsplitpane(obj, .initial_position = 100, .fill = TRUE) {
+            ui_hsplitpane(obj, .initial_position = 100, .position_property = "hsplitpane.position", .fill = TRUE) {
                 ui_button(obj, .label = "Button 1");
                 ui_button(obj, .label = "Button 2");
             }
@@ -1035,7 +1054,7 @@
         
         ui_button(obj, .label = "Button Y");
         ui_checkbox(obj, .label = "Checkbox");
-        ui_spinner(obj, .digits = 2);
+        ui_spinbox(obj, .digits = 2);
         ui_newline(obj);
         
         ui_hbox(obj, .colspan = 3) {

mercurial