Mon, 29 Jan 2024 12:15:19 +0100
add getvalue func for menu item lists (WinUI3)
ui/common/menu.c | file | annotate | diff | comparison | revisions | |
ui/common/menu.h | file | annotate | diff | comparison | revisions | |
ui/ui/menu.h | file | annotate | diff | comparison | revisions | |
ui/winui/appmenu.cpp | file | annotate | diff | comparison | revisions |
--- a/ui/common/menu.c Sun Jan 28 20:46:49 2024 +0100 +++ b/ui/common/menu.c Mon Jan 29 12:15:19 2024 +0100 @@ -196,6 +196,7 @@ item->item.prev = NULL; item->item.next = NULL; item->item.type = UI_MENU_ITEM_LIST; + item->getvalue = args.getvalue; item->callback = args.onselect; item->userdata = args.onselectdata; item->varname = nl_strdup(args.varname);
--- a/ui/common/menu.h Sun Jan 28 20:46:49 2024 +0100 +++ b/ui/common/menu.h Mon Jan 29 12:15:19 2024 +0100 @@ -107,10 +107,11 @@ }; struct UiMenuItemList { - UiMenuItemI item; - ui_callback callback; - void *userdata; - const char *varname; + UiMenuItemI item; + ui_getvaluefunc getvalue; + ui_callback callback; + void *userdata; + const char *varname; };
--- a/ui/ui/menu.h Sun Jan 28 20:46:49 2024 +0100 +++ b/ui/ui/menu.h Mon Jan 29 12:15:19 2024 +0100 @@ -61,6 +61,7 @@ typedef struct UiMenuItemListArgs { const char* varname; + ui_getvaluefunc getvalue; ui_callback onselect; void* onselectdata; } UiMenuItemListArgs;
--- a/ui/winui/appmenu.cpp Sun Jan 28 20:46:49 2024 +0100 +++ b/ui/winui/appmenu.cpp Mon Jan 29 12:15:19 2024 +0100 @@ -170,6 +170,7 @@ int prevSize = 0; int insertPos = 0; UiVar* var = nullptr; + ui_getvaluefunc getvalue = nullptr; ui_callback callback = nullptr; void* userdata = nullptr; @@ -189,6 +190,7 @@ int count = 0; void* elm = list->first(list); while (elm) { + char *menuItemLabel = (char*) (getvalue ? getvalue(elm, 0) : elm); MenuFlyoutItem mi = MenuFlyoutItem(); wchar_t* wlabel = str2wstr((char*)elm, NULL); @@ -236,6 +238,7 @@ UiMenuList* mlist = new UiMenuList(); mlist->parent = parent; + mlist->getvalue = it->getvalue; mlist->callback = it->callback; mlist->userdata = it->userdata; mlist->prevSize = 0;