# HG changeset patch
# User Olaf Wintermann <olaf.wintermann@gmail.com>
# Date 1706526919 -3600
# Node ID ee794586f51b35dffd8ac148550f727a388553eb
# Parent  9c79f00fbf361e7641096b797b8bf92659ce15a4
add getvalue func for menu item lists (WinUI3)

diff -r 9c79f00fbf36 -r ee794586f51b ui/common/menu.c
--- 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);
diff -r 9c79f00fbf36 -r ee794586f51b ui/common/menu.h
--- 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;
 };
 
 
diff -r 9c79f00fbf36 -r ee794586f51b ui/ui/menu.h
--- 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;
diff -r 9c79f00fbf36 -r ee794586f51b ui/winui/appmenu.cpp
--- 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;