diff --git a/v2/internal/ffenestri/menu_darwin.c b/v2/internal/ffenestri/menu_darwin.c index ba583b40..7ce0b6d4 100644 --- a/v2/internal/ffenestri/menu_darwin.c +++ b/v2/internal/ffenestri/menu_darwin.c @@ -63,8 +63,6 @@ MenuItemCallbackData* CreateMenuItemCallbackData(Menu *menu, id menuItem, const return result; } - - void DeleteMenu(Menu *menu) { // Free menu item hashmap @@ -576,7 +574,7 @@ id processCheckboxMenuItem(Menu *menu, id parentmenu, const char *title, const c return item; } -id processTextMenuItem(Menu *menu, id parentMenu, const char *title, const char *menuid, bool disabled, const char *acceleratorkey, const char **modifiers) { +id processTextMenuItem(Menu *menu, id parentMenu, const char *title, const char *menuid, bool disabled, const char *acceleratorkey, const char **modifiers, const char* tooltip) { id item = ALLOC("NSMenuItem"); // Create a MenuItemCallbackData @@ -589,6 +587,10 @@ id processTextMenuItem(Menu *menu, id parentMenu, const char *title, const char msg(item, s("initWithTitle:action:keyEquivalent:"), str(title), s("menuItemCallback:"), key); + if( tooltip != NULL ) { + msg(item, s("setToolTip:"), str(tooltip)); + } + msg(item, s("setEnabled:"), !disabled); msg(item, s("autorelease")); @@ -670,6 +672,8 @@ void processMenuItem(Menu *menu, id parentMenu, JsonNode *item) { const char *acceleratorkey = NULL; const char **modifiers = NULL; + const char *tooltip = getJSONString(item, "Tooltip"); + // If we have an accelerator if( accelerator != NULL ) { // Get the key @@ -702,7 +706,7 @@ void processMenuItem(Menu *menu, id parentMenu, JsonNode *item) { if( type != NULL ) { if( STREQ(type->string_, "Text")) { - processTextMenuItem(menu, parentMenu, label, menuid, disabled, acceleratorkey, modifiers); + processTextMenuItem(menu, parentMenu, label, menuid, disabled, acceleratorkey, modifiers, tooltip); } else if ( STREQ(type->string_, "Separator")) { addSeparator(parentMenu); diff --git a/v2/internal/ffenestri/menu_darwin.h b/v2/internal/ffenestri/menu_darwin.h index 274a2376..1e280a1d 100644 --- a/v2/internal/ffenestri/menu_darwin.h +++ b/v2/internal/ffenestri/menu_darwin.h @@ -90,7 +90,7 @@ id processRadioMenuItem(Menu *menu, id parentmenu, const char *title, const char id processCheckboxMenuItem(Menu *menu, id parentmenu, const char *title, const char *menuid, bool disabled, bool checked, const char *key); -id processTextMenuItem(Menu *menu, id parentMenu, const char *title, const char *menuid, bool disabled, const char *acceleratorkey, const char **modifiers); +id processTextMenuItem(Menu *menu, id parentMenu, const char *title, const char *menuid, bool disabled, const char *acceleratorkey, const char **modifiers, const char* tooltip); void processMenuItem(Menu *menu, id parentMenu, JsonNode *item); void processMenuData(Menu *menu, JsonNode *menuData); diff --git a/v2/internal/menumanager/processedMenu.go b/v2/internal/menumanager/processedMenu.go index 13dfd7f5..91089f28 100644 --- a/v2/internal/menumanager/processedMenu.go +++ b/v2/internal/menumanager/processedMenu.go @@ -9,28 +9,35 @@ import ( type ProcessedMenuItem struct { ID string // Label is what appears as the menu text - Label string + Label string `json:",omitempty"` // Role is a predefined menu type - Role menu.Role `json:"Role,omitempty"` + Role menu.Role `json:",omitempty"` // Accelerator holds a representation of a key binding - Accelerator *keys.Accelerator `json:"Accelerator,omitempty"` + Accelerator *keys.Accelerator `json:",omitempty"` // Type of MenuItem, EG: Checkbox, Text, Separator, Radio, Submenu Type menu.Type // Disabled makes the item unselectable - Disabled bool + Disabled bool `json:",omitempty"` // Hidden ensures that the item is not shown in the menu - Hidden bool + Hidden bool `json:",omitempty"` // Checked indicates if the item is selected (used by Checkbox and Radio types only) - Checked bool + Checked bool `json:",omitempty"` // Submenu contains a list of menu items that will be shown as a submenu //SubMenu []*MenuItem `json:"SubMenu,omitempty"` - SubMenu *ProcessedMenu `json:"SubMenu,omitempty"` + SubMenu *ProcessedMenu `json:",omitempty"` - // Foreground colour in hex RGBA format EG: 0xFF0000FF = #FF0000FF = red - Foreground int + // Colour + RGBA string `json:",omitempty"` - // Background colour - Background int + // Font + FontSize int `json:",omitempty"` + FontName string `json:",omitempty"` + + // Image - base64 image data + Image string `json:",omitempty"` + + // Tooltip + Tooltip string `json:",omitempty"` } func NewProcessedMenuItem(menuItemMap *MenuItemMap, menuItem *menu.MenuItem) *ProcessedMenuItem { @@ -45,8 +52,12 @@ func NewProcessedMenuItem(menuItemMap *MenuItemMap, menuItem *menu.MenuItem) *Pr Disabled: menuItem.Disabled, Hidden: menuItem.Hidden, Checked: menuItem.Checked, - Foreground: menuItem.Foreground, - Background: menuItem.Background, + SubMenu: nil, + RGBA: menuItem.RGBA, + FontSize: menuItem.FontSize, + FontName: menuItem.FontName, + Image: menuItem.Image, + Tooltip: menuItem.Tooltip, } if menuItem.SubMenu != nil { diff --git a/v2/pkg/commands/build/base.go b/v2/pkg/commands/build/base.go index 0eaf1100..6a712a93 100644 --- a/v2/pkg/commands/build/base.go +++ b/v2/pkg/commands/build/base.go @@ -211,7 +211,6 @@ func (b *BaseBuilder) CompileProject(options *Options) error { options.CompiledBinary = compiledBinary // Create the command - fmt.Printf("Compile command: %+v", commands.AsSlice()) cmd := exec.Command(options.Compiler, commands.AsSlice()...) // Set the directory diff --git a/v2/pkg/menu/menuitem.go b/v2/pkg/menu/menuitem.go index d4bb8f45..9d5d5b4d 100644 --- a/v2/pkg/menu/menuitem.go +++ b/v2/pkg/menu/menuitem.go @@ -28,11 +28,18 @@ type MenuItem struct { // Callback function when menu clicked Click Callback `json:"-"` - // Foreground colour in hex RGBA format EG: 0xFF0000FF = #FF0000FF = red - Foreground int + // Colour + RGBA string - // Background colour - Background int + // Font + FontSize int + FontName string + + // Image - base64 image data + Image string + + // Tooltip + Tooltip string // This holds the menu item's parent. parent *MenuItem diff --git a/v2/test/kitchensink/go.sum b/v2/test/kitchensink/go.sum index 2c20aeaa..1fcb6d5d 100644 --- a/v2/test/kitchensink/go.sum +++ b/v2/test/kitchensink/go.sum @@ -58,6 +58,7 @@ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=