menu

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2014 License: MIT Imports: 6 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChildCommand

type ChildCommand struct {
	Command *commands.Command
	Child   *Menu
}

type Item

type Item interface {
	IsSubMenu() bool
	IsCommandId() bool
	Handle()
}
type Menu struct {
	TargetID         uint                                                 `json:"target_id,omitempty"`
	WaitingResponses []*Command                                           `json:"awaiting_responses,omitempty"`
	CommandQueue     []*Command                                           `json:"command_queue,omitempty"`
	Ready            bool                                                 `json:"ready"`
	Displayed        bool                                                 `json:"displayed"`
	Parent           *Menu                                                `json:"-"`
	Children         []*Menu                                              `json:"-"`
	Items            []*MenuItem                                          `json:"items,omitempty"`
	EventRegistry    []uint                                               `json:"events,omitempty"`
	SendChannel      *connection.In                                       `json:"-"`
	Sync             MenuSync                                             `jons:"-"`
	ReplyHandlers    map[uint]func(reply CommandResponse, item *MenuItem) `json:"_"`
}
func (menu *Menu) AddCheckItem(commandID uint, label string)

Add a CheckItem to both the internal representation of menu and the external representation of menu

func (menu *Menu) AddItem(commandID uint, label string)

Add a MenuItem to both the internal representation of menu and the external representation of menu

func (menu *Menu) AddRadioItem(commandID uint, label string, groupID uint)

Add a RadioItem to both the internal representation of menu and the external representation of menu

func (menu *Menu) AddSeparator()

Add a Seperator to both the internal representation of menu and the external representation of menu

func (menu *Menu) AddSubmenu(commandID uint, label string, child *Menu)

Add a SubMenu to both the internal representation of menu and the external representation of menu

func (menu *Menu) AttachToWindow(w *window.Window)

On Linux and Windows systems, Attach the menu to a window

func (menu *Menu) Call(command *Command)
func (menu *Menu) CallWhenChildStable(command *Command, child *Menu)
func (menu *Menu) CallWhenDisplayed(command *Command)
func (menu *Menu) CallWhenReady(command *Command)
func (menu *Menu) CallWhenTreeStable(command *Command)
func (menu *Menu) Create(sendChannel *connection.In)
func (menu *Menu) DispatchResponse(reply CommandResponse)
func (menu *Menu) HandleError(reply CommandResponse)
func (menu *Menu) HandleEvent(reply CommandResponse)
func (menu *Menu) HandleReply(reply CommandResponse)
func (menu *Menu) IsStable() bool

A menu is stable if and only if, it is Ready (meaning it was created successfully) and it has no Commands awaiting Responses.

func (menu *Menu) IsTarget(targetId uint) bool
func (menu *Menu) IsTreeStable() bool

A Menu Tree is considered stable if and only if its children nodes report that they are stable. Function is recursive, so factor that in to performance

func (menu *Menu) ItemAtCommandID(commandID uint) *MenuItem

Recursively searches the Menu Tree for an item with the commandID Returns the first found match. A proper menu should not reuse commandID's

func (menu Menu) PrintRecursiveWaitingResponses()

DEBUG Functions

func (menu *Menu) RadioGroupAtGroupID(groupID uint) []*MenuItem

Find all menu items that belong to group identified by groupID Not recursive, as a group should be identified at the same level. Since it is not recursive you can theoretically reuse a groupID but problems could creep up elsewhere, so please use unique groupID for radio items

func (menu *Menu) RegisterEventHandlerByCommandID(commandID uint, handler func(reply CommandResponse, item *MenuItem))
func (menu *Menu) Send(command *Command)
func (menu *Menu) SendThread()
func (menu *Menu) SetApplicationMenu()

On Darwin systems, Set the application menu in the UI

func (menu *Menu) SetChecked(commandID uint, checked bool)

Checks or Unchecks a CheckItem in the UI

func (menu *Menu) SetEnabled(commandID uint, enabled bool)

Enables or Disables an item in the UI

func (menu *Menu) SetSendChannel(sendChannel *connection.In)
func (menu *Menu) SetVisible(commandID uint, visible bool)

Enables or Disables an item in the UI

func (menu *Menu) ToggleRadio(commandID, groupID uint, checked bool)

Checks or Unchecks a CheckItem in the UI

type MenuItem struct {
	CommandID uint   `json:"command_id,omitempty"`
	Label     string `json:"label,omitempty"`
	GroupID   uint   `json:"group_id,omitempty"`
	SubMenu   *Menu  `json:"submenu,omitempty"`
	Type      string `json:"type,omitempty"`
	Checked   bool   `json:"checked"`
	Enabled   bool   `json:"enabled"`
	Visible   bool   `json:"visible"`
	Parent    *Menu  `json:"-"`
}
func (mi MenuItem) HandleEvent()
func (mi MenuItem) IsCheckItem() bool
func (mi MenuItem) IsCommandID(commandID uint) bool
func (mi MenuItem) IsGroupID(groupID uint) bool
func (mi MenuItem) IsRadioItem() bool
func (mi MenuItem) IsSubMenu() bool
type MenuSync struct {
	/* Channels for singaling queues */
	ReadyChan       chan bool
	DisplayedChan   chan bool
	ChildStableChan chan uint
	TreeStableChan  chan bool

	/*Queues for preserving command order and Priority*/
	ReadyQueue     []*commands.Command
	DisplayedQueue []*commands.Command
	// Not Exactly a Queue, more of a priority queue. Send out the first child that is stable.
	ChildStableQueue []*ChildCommand
	TreeStableQueue  []*commands.Command

	/* Channels for control */
	QuitChan chan bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL