gui/pkg/menu/platform.go

43 lines
1 KiB
Go
Raw Permalink Normal View History

// pkg/menu/platform.go
package menu
// Platform abstracts the menu backend.
2026-04-02 19:54:47 +00:00
// Use: var platform menu.Platform = backend
type Platform interface {
NewMenu() PlatformMenu
SetApplicationMenu(menu PlatformMenu)
}
// PlatformMenu is a live menu handle.
2026-04-02 19:54:47 +00:00
// 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.
2026-04-02 19:54:47 +00:00
// 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.
2026-04-02 19:54:47 +00:00
// Use: role := menu.RoleFileMenu
type MenuRole int
const (
RoleAppMenu MenuRole = iota
RoleFileMenu
RoleEditMenu
RoleViewMenu
RoleWindowMenu
RoleHelpMenu
)