diff --git a/v2/internal/ffenestri/traymenu_darwin.c b/v2/internal/ffenestri/traymenu_darwin.c index 0f677ac3b..3465d297f 100644 --- a/v2/internal/ffenestri/traymenu_darwin.c +++ b/v2/internal/ffenestri/traymenu_darwin.c @@ -31,7 +31,8 @@ TrayMenu* NewTrayMenu(const char* menuJSON) { result->ID = mustJSONString(processedJSON, "ID"); result->label = mustJSONString(processedJSON, "Label"); - result->icon = mustJSONString(processedJSON, "Icon"); + result->icon = mustJSONString(processedJSON, "Image"); + getJSONBool(processedJSON, "MacTemplateImage", &result->templateImage); JsonNode* processedMenu = mustJSONObject(processedJSON, "ProcessedMenu"); // Create the menu @@ -89,6 +90,10 @@ void UpdateTrayIcon(TrayMenu *trayMenu) { id imageData = msg(data, s("initWithBase64EncodedString:options:"), str(trayMenu->icon), 0); trayImage = ALLOC("NSImage"); msg(trayImage, s("initWithData:"), imageData); + + if( trayMenu->templateImage ) { + msg(trayImage, s("setTemplate:"), YES); + } } msg(statusBarButton, s("setImagePosition:"), trayMenu->trayIconPosition); diff --git a/v2/internal/ffenestri/traymenu_darwin.h b/v2/internal/ffenestri/traymenu_darwin.h index ce2e3b8a1..df5d1d72c 100644 --- a/v2/internal/ffenestri/traymenu_darwin.h +++ b/v2/internal/ffenestri/traymenu_darwin.h @@ -14,6 +14,8 @@ typedef struct { const char *icon; const char *ID; + bool templateImage; + Menu* menu; id statusbaritem; diff --git a/v2/internal/menumanager/traymenu.go b/v2/internal/menumanager/traymenu.go index 29447de8a..35233091f 100644 --- a/v2/internal/menumanager/traymenu.go +++ b/v2/internal/menumanager/traymenu.go @@ -23,13 +23,14 @@ func generateTrayID() string { } type TrayMenu struct { - ID string - Label string - Icon string - menuItemMap *MenuItemMap - menu *menu.Menu - ProcessedMenu *WailsMenu - trayMenu *menu.TrayMenu + ID string + Label string + Image string + MacTemplateImage bool + menuItemMap *MenuItemMap + menu *menu.Menu + ProcessedMenu *WailsMenu + trayMenu *menu.TrayMenu } func (t *TrayMenu) AsJSON() (string, error) { @@ -43,11 +44,12 @@ func (t *TrayMenu) AsJSON() (string, error) { func NewTrayMenu(trayMenu *menu.TrayMenu) *TrayMenu { result := &TrayMenu{ - Label: trayMenu.Label, - Icon: trayMenu.Icon, - menu: trayMenu.Menu, - menuItemMap: NewMenuItemMap(), - trayMenu: trayMenu, + Label: trayMenu.Label, + Image: trayMenu.Image, + MacTemplateImage: trayMenu.MacTemplateImage, + menu: trayMenu.Menu, + menuItemMap: NewMenuItemMap(), + trayMenu: trayMenu, } result.menuItemMap.AddMenu(trayMenu.Menu) diff --git a/v2/pkg/menu/tray.go b/v2/pkg/menu/tray.go index d3212136b..cf7a985cb 100644 --- a/v2/pkg/menu/tray.go +++ b/v2/pkg/menu/tray.go @@ -6,11 +6,15 @@ type TrayMenu struct { // Label is the text we wish to display in the tray Label string - // Icon is the name of the tray icon we wish to display. + // Image is the name of the tray icon we wish to display. // These are read up during build from /trayicons and // the filenames are used as IDs, minus the extension // EG: /trayicons/main.png can be referenced here with "main" - Icon string + // If the image is not a filename, it will be treated as base64 image data + Image string + + // MacTemplateImage indicates that on a Mac, this image is a template image + MacTemplateImage bool // Menu is the initial menu we wish to use for the tray Menu *Menu