gui/pkg/menu/platform.go
Virgil 0423f3058d
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
chore(gui): add AX usage examples
2026-04-02 19:54:47 +00:00

42 lines
1 KiB
Go

// pkg/menu/platform.go
package menu
// Platform abstracts the menu backend.
// Use: var platform menu.Platform = backend
type Platform interface {
NewMenu() PlatformMenu
SetApplicationMenu(menu PlatformMenu)
}
// PlatformMenu is a live menu handle.
// Use: var root menu.PlatformMenu = platform.NewMenu()
type PlatformMenu interface {
Add(label string) PlatformMenuItem
AddSeparator()
AddSubmenu(label string) PlatformMenu
// Roles — macOS menu roles
AddRole(role MenuRole)
}
// PlatformMenuItem is a single menu item.
// Use: var item menu.PlatformMenuItem = root.Add("Quit")
type PlatformMenuItem interface {
SetAccelerator(accel string) PlatformMenuItem
SetTooltip(text string) PlatformMenuItem
SetChecked(checked bool) PlatformMenuItem
SetEnabled(enabled bool) PlatformMenuItem
OnClick(fn func()) PlatformMenuItem
}
// MenuRole is a predefined platform menu role.
// Use: role := menu.RoleFileMenu
type MenuRole int
const (
RoleAppMenu MenuRole = iota
RoleFileMenu
RoleEditMenu
RoleViewMenu
RoleWindowMenu
RoleHelpMenu
)