diff -r 7d15cad351fc -r 28a5920bebe0 application/main.c --- a/application/main.c Sun Dec 15 22:53:51 2024 +0100 +++ b/application/main.c Sun Dec 22 11:49:59 2024 +0100 @@ -486,67 +486,39 @@ #if defined(UI_COCOA) || defined(UI_MOTIF) +static UiList *menulist; +int items = 4; + void action_button(UiEvent *event, void *data) { printf("action_button\n"); + + char *newitem = malloc(32); + snprintf(newitem, 32, "Item %d", ++items); + ui_list_append(menulist, newitem); + ui_list_notify(menulist); } typedef struct WData { UiString *path; } WData; + + void application_startup(UiEvent *event, void *data) { + + menulist = ui_list_new(ui_global_context(), "menulist"); + ui_list_append(menulist, "Item 1"); + ui_list_append(menulist, "Item 2"); + ui_list_append(menulist, "Item 3"); + ui_list_append(menulist, "Item 4"); + UiObject *obj = ui_window("Test", NULL); WData *wdata = ui_malloc(obj->ctx, sizeof(WData)); wdata->path = ui_string_new(obj->ctx, NULL); obj->window = wdata; - /* - ui_grid(obj, .margin = 10) { - ui_button(obj, .label = "Test Button", .onclick = action_button); - ui_newline(obj); - - ui_togglebutton(obj, .label = "Togglebutton"); - ui_togglebutton(obj, .label = "XY", .hfill = TRUE); - ui_togglebutton(obj, .label = "AB", .hfill = TRUE); - ui_togglebutton(obj, .label = "ZZ", .hexpand = TRUE, .hfill = TRUE); - ui_newline(obj); - - ui_hbox(obj, .colspan = 4, .hfill = TRUE, .hexpand = TRUE) { - ui_checkbox(obj, .label = "Checkbox", .enable_group = 123); - ui_checkbox(obj, .label = "Checkbox Disabled", .groups = UI_GROUPS(123)); - ui_button(obj, .label = "fill", .fill = UI_ON); - } - ui_newline(obj); - - - - ui_hbox(obj, .colspan = 4, .hfill = TRUE, .hexpand = TRUE) { - ui_radiobutton(obj, .label = "Radio 1", .varname = "radio"); - ui_radiobutton(obj, .label = "Radio 2", .varname = "radio"); - ui_button(obj, .label = "fill", .hexpand = TRUE, .hfill = TRUE); - } - ui_newline(obj); - - - ui_hbox(obj, .colspan = 4, .vexpand = TRUE, .vfill = TRUE) { - ui_button(obj, .label = "F1----------------------A"); - ui_button(obj, .label = "F2 test test test test test test test"); - ui_button(obj, .label = "F312343543"); - } - - - } - */ - - - - //ui_textfield(obj, .varname = "textfield"); - //ui_textfield(obj, .varname = "textfield2"); - ui_path_textfield(obj, .value = wdata->path, .hfill = TRUE, .hexpand = TRUE); - - ui_set(wdata->path, "/test/path/string"); - + ui_button(obj, .label = "Add Item", .onclick = action_button); ui_show(obj); } @@ -564,12 +536,18 @@ ui_menuitem(.label = "Test 1", .onclick = action_test); ui_menuitem(.label = "Test 2", .onclick = action_test); ui_menuitem(.label = "Test 3", .onclick = action_test); + ui_menuseparator(); ui_menu_toggleitem(.label = "Toggle 1"); ui_menu_toggleitem(.label = "Toggle 2"); + ui_menuseparator(); ui_menu_radioitem(.label = "Radio 1", .varname = "menu_radio"); ui_menu_radioitem(.label = "Radio 2", .varname = "menu_radio"); ui_menu_radioitem(.label = "Radio 3", .varname = "menu_radio"); ui_menu_radioitem(.label = "Radio 4", .varname = "menu_radio"); + ui_menuseparator(); + ui_menu_itemlist(.varname = "menulist"); + ui_menuseparator(); + ui_menuitem(.label = "Quit"); } ui_main();