gui/pkg/menu/platform.go
Snider 12a612bba0 feat(menu): add Manager with platform abstraction and builder
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 12:15:32 +00:00

38 lines
858 B
Go

// pkg/menu/platform.go
package menu
// Platform abstracts the menu backend.
type Platform interface {
NewMenu() PlatformMenu
SetApplicationMenu(menu PlatformMenu)
}
// PlatformMenu is a live menu handle.
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.
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.
type MenuRole int
const (
RoleAppMenu MenuRole = iota
RoleFileMenu
RoleEditMenu
RoleViewMenu
RoleWindowMenu
RoleHelpMenu
)