menu

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: MIT Imports: 6 Imported by: 8

Documentation

Overview

Package menu is a widget that presents a drop-down menu.

Index

Constants

This section is empty.

Variables

Functions

func OpenSimple added in v1.3.0

func OpenSimple(open bool, mu *Widget, site ISite, app gowid.IApp) bool

func Render

func Render(w IWidget, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

func UserInput

func UserInput(w IWidget, ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool

Types

type AutoCloserWidget

type AutoCloserWidget struct {
	gowid.IWidget
	// contains filtered or unexported fields
}

AutoCloserWidget is used to detect if a given menu is open when a widget responds to user input. Then some action can be taken after that user input (e.g. closing the menu)

func (*AutoCloserWidget) UserInput

func (w *AutoCloserWidget) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool

type CachedOverlay

type CachedOverlay struct {
	overlay.IWidget
	// contains filtered or unexported fields
}

func (*CachedOverlay) Bottom

func (w *CachedOverlay) Bottom() gowid.IWidget

func (*CachedOverlay) Render

func (w *CachedOverlay) Render(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

type CachedWidget

type CachedWidget struct {
	gowid.IWidget
	// contains filtered or unexported fields
}

func (*CachedWidget) Render

func (w *CachedWidget) Render(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

type IOpener added in v1.3.0

type IOpener interface {
	OpenMenu(*Widget, ISite, gowid.IApp) bool
	CloseMenu(*Widget, gowid.IApp)
}

type ISite

type ISite interface {
	Namer() ISiteName
	SetNamer(ISiteName, gowid.IApp)
}

type ISiteName

type ISiteName interface {
	Name() string
}

type IWidget

type IWidget interface {
	gowid.ICompositeWidget
	Overlay() overlay.IWidgetSettable
	Open(ISite, gowid.IApp)
	Close(gowid.IApp)
	IsOpen() bool
	CloseKeys() []gowid.IKey  // Keys that should close the current submenu (e.g. left arrow)
	IgnoreKeys() []gowid.IKey // Keys that shouldn't close submenu but should be passed back to main app
	AutoClose() bool
	SetAutoClose(bool, gowid.IApp)
	Width() gowid.IWidgetDimension
	SetWidth(gowid.IWidgetDimension, gowid.IApp)
	Name() string
}
type NavWrapperWidget struct {
	gowid.IWidget
	// contains filtered or unexported fields
}

NavWrapperWidget is used to detect if a given menu is open when a widget responds to user input. Then some action can be taken after that user input (e.g. closing the menu)

func (w *NavWrapperWidget) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool

type OpenerFunc added in v1.3.0

type OpenerFunc func(bool, *Widget, ISite, gowid.IApp) bool

Return false if it was already open

func (OpenerFunc) CloseMenu added in v1.3.0

func (m OpenerFunc) CloseMenu(mu *Widget, app gowid.IApp)

func (OpenerFunc) OpenMenu added in v1.3.0

func (m OpenerFunc) OpenMenu(mu *Widget, site ISite, app gowid.IApp) bool

type Options

type Options struct {
	CloseKeysProvided  bool
	CloseKeys          []gowid.IKey
	IgnoreKeysProvided bool
	IgnoreKeys         []gowid.IKey
	NoAutoClose        bool
	Modal              bool
	OpenCloser         IOpener
}

type SiteOptions

type SiteOptions struct {
	Namer   ISiteName
	XOffset int
	YOffset int
}

type SiteWidget

type SiteWidget struct {
	gowid.IWidget
	Options SiteOptions
}

SiteWidget is a zero-width widget which acts as the coordinates at which a submenu will open

func NewSite

func NewSite(opts ...SiteOptions) *SiteWidget

func (*SiteWidget) Namer

func (w *SiteWidget) Namer() ISiteName

func (*SiteWidget) Render

func (w *SiteWidget) Render(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

func (*SiteWidget) Selectable

func (w *SiteWidget) Selectable() bool

func (*SiteWidget) SetNamer

func (w *SiteWidget) SetNamer(m ISiteName, app gowid.IApp)

func (*SiteWidget) String

func (w *SiteWidget) String() string

type Widget

type Widget struct {
	Callbacks *gowid.Callbacks
	// contains filtered or unexported fields
}

Widget overlays one widget on top of another. The bottom widget is rendered without the focus at full size. The bottom widget is rendered between a horizontal and vertical padding widget set up with the sizes provided.

func New

func New(name string, menuw gowid.IWidget, width gowid.IWidgetDimension, opts ...Options) *Widget

New takes a widget, rather than a menu model, so that I can potentially style the menu. TODO - consider adding styling to menu model?

func (*Widget) AutoClose

func (w *Widget) AutoClose() bool

func (*Widget) Close

func (w *Widget) Close(app gowid.IApp)

func (*Widget) CloseImpl added in v1.3.0

func (w *Widget) CloseImpl(app gowid.IApp)

func (*Widget) CloseKeys

func (w *Widget) CloseKeys() []gowid.IKey

func (*Widget) Height added in v1.3.0

func (w *Widget) Height() gowid.IWidgetDimension

func (*Widget) IgnoreKeys

func (w *Widget) IgnoreKeys() []gowid.IKey

func (*Widget) IsOpen

func (w *Widget) IsOpen() bool

func (*Widget) Name

func (w *Widget) Name() string

func (*Widget) Open

func (w *Widget) Open(site ISite, app gowid.IApp)

func (*Widget) OpenImpl added in v1.3.0

func (w *Widget) OpenImpl(site ISite, app gowid.IApp)

func (*Widget) Overlay

func (w *Widget) Overlay() overlay.IWidgetSettable

func (*Widget) Render

func (w *Widget) Render(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

func (*Widget) RenderSize

func (w *Widget) RenderSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderBox

func (*Widget) Selectable

func (w *Widget) Selectable() bool

func (*Widget) SetAutoClose

func (w *Widget) SetAutoClose(autoClose bool, app gowid.IApp)

func (*Widget) SetHeight added in v1.3.0

func (w *Widget) SetHeight(width gowid.IWidgetDimension, app gowid.IApp)

func (*Widget) SetSubWidget

func (w *Widget) SetSubWidget(widget gowid.IWidget, app gowid.IApp)

func (*Widget) SetWidth

func (w *Widget) SetWidth(width gowid.IWidgetDimension, app gowid.IApp)

func (*Widget) String

func (w *Widget) String() string

func (*Widget) SubWidget

func (w *Widget) SubWidget() gowid.IWidget

func (*Widget) SubWidgetSize

func (w *Widget) SubWidgetSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderSize

func (*Widget) UserInput

func (w *Widget) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool

func (*Widget) Width

func (w *Widget) Width() gowid.IWidgetDimension

Jump to

Keyboard shortcuts

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