Mon, 30 Dec 2024 12:50:52 +0100
fix menu itemlist position (Motif)
ui/common/menu.c | file | annotate | diff | comparison | revisions | |
ui/common/menu.h | file | annotate | diff | comparison | revisions | |
ui/motif/menu.c | file | annotate | diff | comparison | revisions | |
ui/ui/menu.h | file | annotate | diff | comparison | revisions |
--- a/ui/common/menu.c Sun Dec 22 11:49:59 2024 +0100 +++ b/ui/common/menu.c Mon Dec 30 12:50:52 2024 +0100 @@ -198,6 +198,7 @@ item->callback = args.onselect; item->userdata = args.onselectdata; item->varname = nl_strdup(args.varname); + item->addseparator = args.addseparator; add_item((UiMenuItemI*)item); }
--- a/ui/common/menu.h Sun Dec 22 11:49:59 2024 +0100 +++ b/ui/common/menu.h Mon Dec 30 12:50:52 2024 +0100 @@ -114,6 +114,7 @@ ui_callback callback; void *userdata; char *varname; + UiBool addseparator; };
--- a/ui/motif/menu.c Sun Dec 22 11:49:59 2024 +0100 +++ b/ui/motif/menu.c Mon Dec 30 12:50:52 2024 +0100 @@ -216,7 +216,7 @@ ls->getvalue = il->getvalue; ls->callback = il->callback; ls->userdata = il->userdata; - ls->addseparator = TRUE; + ls->addseparator = il->addseparator; ls->var = uic_create_var(ui_global_context(), il->varname, UI_VAR_LIST); //uic_widget_var(obj->ctx, obj->ctx, NULL, il->varname, UI_VAR_LIST); UiList *list = ls->var->value; @@ -260,12 +260,14 @@ void* elm = ui_list_first(ls); int i = 0; if(elm && list->addseparator) { - Widget s = XmCreateSeparatorGadget(list->menu, "menuseparator", NULL, 0); + XtSetArg(args[0], XmNpositionIndex, list->index); + Widget s = XmCreateSeparatorGadget(list->menu, "menuseparator", args, 1); XtManageChild(s); i++; } ui_getvaluefunc getvalue = list->getvalue; + int pos = list->index; while(elm) { n = 0; char *label = (char*) (getvalue ? getvalue(elm, 0) : elm); @@ -273,7 +275,8 @@ s = XmStringCreateLocalized(label); XtSetArg(args[n], XmNlabelString, s); n++; } - + XtSetArg(args[n], XmNpositionIndex, pos+i); n++; + Widget mitem = XtCreateManagedWidget( "menubutton", xmPushButtonWidgetClass,
--- a/ui/ui/menu.h Sun Dec 22 11:49:59 2024 +0100 +++ b/ui/ui/menu.h Mon Dec 30 12:50:52 2024 +0100 @@ -64,6 +64,7 @@ ui_getvaluefunc getvalue; ui_callback onselect; void* onselectdata; + UiBool addseparator; } UiMenuItemListArgs; #define ui_menu(label) for(ui_menu_create(label);ui_menu_is_open();ui_menu_close())