menu

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: BSD-2-Clause-Views Imports: 6 Imported by: 1

README

The Menu package provides for simple menus built on top
of sketch.

A "menu set" is created and the user programme can add
one or more menus to the set.  Each menu may be anchored
by a button which is always visible (akin to the 'file' 
pull down on many popular GUI applications), or can be
'popped up' at the desire of the user programme. 

Each menu is a set of 3-D buttons. When the mouse 
pointer is positioned on a button, and a mouse button
is depressed and released, and event percolates through
the menu system to generate an event structure onto the
channel whch has been associated with the button. 

The user application can associate one channel per menu, 
one channel for all menus, or even one channel per button
as is desired. Each menu button is given a unique ID when
created, so any combination of the above is possible.

Menu buttons can be a set of radio buttons, sticky (click
once to depress, click a second time to release), or
spring buttons (button never stays depressed). The 
buttons in a single menu may be a combination of these
variouse types (though only one group of radio buttons
per menu is permitted).


The property menu is an extension to a normal menu which
allows the user programme to define the menu with a 
set of Json, and then can query the state of each of the 
properties maintains.  Properties are simple boolean (on
or off) settings and are represnted in the list by
sticky buttons which can be set to on/off when the menu
is created; allowing the user programme the ability to 
load and set the initial state. 

Documentation

Overview

Mnemonic: button.go Abstract: Support for an individual menu button. Date: 12 December 2018 Author: E. Scott Daniels

Mnemonic: menu.go Abstract: Struct and functions to manage a single set of menu buttons. Date: 12 December 2018 Author: E. Scott Daniels

Notes: Buttons are automatically drawn into the double buffer window before

the buffer is swapped.
Subpage background colour is automatically set, and the sp cleared
with each call to the page's show().
All visible menu subpages should be painted without special call
to any function here.

Menu provides a sketch API based simple menu, button and mouse event event interface.

Mnemonic: prop_menu.go Abstract: A "property" and related menu manger. Properties are binary (true/false).

The user programme must establish and initialse the sketch xigo environment
and supply the graphcs context at initialisation. The user programme is also
expected to execute the Drive() function of the gc in order to drive the
event manager.

Date: 16 December 2018 Author: E. Scott Daniels

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Default_entry

type Default_entry struct {
	Colour string
	Kind   string
	Action string // close or set
}

Structs to bash json definition into

type Definition

type Definition struct {
	Defaults Default_entry
	Entries  []Prop_entry
}
type Menu_mgr struct {
	// contains filtered or unexported fields
}

Menu manager, manages a set of menus.

func Mk_menu_set

func Mk_menu_set(gc sketch.Graphics_api, x float64, y float64, height float64, width float64, colour string,
	txt_colour string, align_vert bool) *Menu_mgr

Mk_menu_set will create a menu system for the currently active subpage in gc. User programme must first create an Xigo sketch graphics context (gc) which will also be used by the menus.

func (mm *Menu_mgr) Add_anchor(name string, label string, height float64, width float64, page_colour string, uchan chan *Mevent) (bid int)

Add_anchor allows the user programme to add an anchored menu with out automatially adding any buttons to the menu. Buttons can be added later allowing each to be coloured differently, or to have different properties.

func (mm *Menu_mgr) Add_button(menu_name string, label string, colour string, txt_colour string, kind int, pressed bool, uchan chan *Mevent) (bid int)

Add_button allows a single button to be added to a menu. The button ID is automatically assigned, but user control over colour and type is allowed. Button height and width are taken from the menu definition set when the anchor was created.

func (mm *Menu_mgr) Add_menu(name string, anchor_label string, height float64, width float64,
	bcolour string, txt_colour string, labels []string, uchan chan *Mevent) (start_bid int)

Add_menu provides a 'one stop shopping' experience allowing the user programme to add a complete menu to the mix. Menu button labels are expected as an array of strings, button IDs are sequentially assigned, and button colours are all the same. Further, all buttons created "point" at the same user menu event channel. In the end, the user has less control, but the overall code in the user programme is likely more simple.

func (mm *Menu_mgr) Add_nab_menu(name string, x float64, y float64, height float64, width float64, page_colour string, uchan chan *Mevent)

Add_nab_menu adds a menu which has no anchor button. The user is responsible for causing the menu to be opened and closed. The x,y is used as the location to place the menu when displayed.

func (mm *Menu_mgr) Display_menu(name string)

Display menu causes the named menu's display state to be turned on. If it is already visible, no change is made.

func (mm *Menu_mgr) Hide_menu(name string)

Hide menu causes the named menu's display state to be turned off. If it is already hidden, no change is made.

func (mm *Menu_mgr) Toggle_menu(name string)

Toggle menu causes the named menu's display state to be flipped.

type Mevent

type Mevent struct {
	Bid   int  // button ID affected
	Is_in bool // button state - true if button is 'depressed'
}

Menu event sent to to user on their channel.

type Prop_entry

type Prop_entry struct {
	Colour     string // button colour for this setting
	Kind       string // button kind (should be sticky except for the close button)
	Name       string // property name Used to lookup
	Label      string // button label
	Action     string // button action (set causes value toggle, close causes menu hide)
	Init_state bool   // initial state (true == 'depressed')
}

type Properties

type Properties struct {
	// contains filtered or unexported fields
}

Manage a set of properties.

func Mk_prop_menu

func Mk_prop_menu(mm *Menu_mgr, name string, x float64, y float64, height float64, width float64, def string) (p *Properties)

Create a property menu. The menu is NOT anchored, and thus the user programme must cause it to be displayed directly (probably tied to a button click in an anchored menu).

func (*Properties) Destroy

func (p *Properties) Destroy()

Completely destroy the menu.

func (*Properties) Is_set

func (p *Properties) Is_set(pname string) bool

Is_set will return true of the named property is set.

Jump to

Keyboard shortcuts

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