Documentation ¶
Overview ¶
Package menu provides menu-related structs for use in tabula. Specifically, the package provides Bar for a menu bar implementation and List for a menu entry container implementation. Bar and List satisfy the tabula.ui.Component interface.
Index ¶
- Constants
- type Bar
- func (b *Bar) Destroy()
- func (b *Bar) GetEntryAt(x int32, y int32) (*entry, error)
- func (b *Bar) InBoundary(pt sdl.Point) bool
- func (b *Bar) OnClick(evt *sdl.MouseButtonEvent) bool
- func (b *Bar) OnEnter()
- func (b *Bar) OnLeave()
- func (b *Bar) OnMotion(evt *sdl.MouseMotionEvent) bool
- func (b *Bar) OnResize(x, y int32)
- func (b *Bar) OnScroll(*sdl.MouseWheelEvent) bool
- func (b *Bar) Render()
- func (b *Bar) String() string
- type Button
- func (b *Button) Destroy()
- func (b *Button) InBoundary(pt sdl.Point) bool
- func (b *Button) OnClick(evt *sdl.MouseButtonEvent) bool
- func (b *Button) OnEnter()
- func (b *Button) OnLeave()
- func (b *Button) OnMotion(evt *sdl.MouseMotionEvent) bool
- func (b *Button) OnResize(x, y int32)
- func (b *Button) OnScroll(evt *sdl.MouseWheelEvent) bool
- func (b *Button) Render()
- func (b *Button) SetDefaultBackgroundColor(color [4]float32)
- func (b *Button) SetDefaultTextColor(color [4]float32)
- func (b *Button) SetHighlightBackgroundColor(color [4]float32)
- func (b *Button) SetHighlightTextColor(color [4]float32)
- func (b *Button) String() string
- type Definition
Constants ¶
const ErrNoEntryAtPosition log.ConstErr = "no entry at given position"
ErrNoEntryAtPosition indicates that no entry exists at a given position
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bar ¶
type Bar struct {
// contains filtered or unexported fields
}
Bar is a horizontal menu bar
func NewBar ¶
func NewBar(cfg *config.Config, menus []Definition) (*Bar, error)
NewBar returns the menubar matching the given definition
func (*Bar) GetEntryAt ¶
GetEntryAt returns the menu entry below the given mouse coordinates
func (*Bar) InBoundary ¶
InBoundary returns whether a point is handled by the menubar
func (*Bar) OnClick ¶
func (b *Bar) OnClick(evt *sdl.MouseButtonEvent) bool
OnClick updates the menubar for when the mouse clicks within its boundary
func (*Bar) OnEnter ¶
func (b *Bar) OnEnter()
OnEnter updates the menubar for when the mouse enters its boundary
func (*Bar) OnLeave ¶
func (b *Bar) OnLeave()
OnLeave updates the menubar for when the mouse leaves its boundary
func (*Bar) OnMotion ¶
func (b *Bar) OnMotion(evt *sdl.MouseMotionEvent) bool
OnMotion updates the menubar for when the mouse moves within its boundary
type Button ¶
type Button struct {
// contains filtered or unexported fields
}
Button defines an interactive button
func NewButton ¶
NewButton returns a pointer to a Button struct defaultColor and highlightColor default to light grey (0xD6CFCFFF) and blue (0X0046AFFF) respectively, if nil
func (*Button) Destroy ¶
func (b *Button) Destroy()
Destroy frees all assets obtained by the ui.Component
func (*Button) InBoundary ¶
InBoundary returns whether a point is in this ui.Component's bounds
func (*Button) OnClick ¶
func (b *Button) OnClick(evt *sdl.MouseButtonEvent) bool
OnClick is called when the user clicks within the ui.Component's region
func (*Button) OnEnter ¶
func (b *Button) OnEnter()
OnEnter is called when the cursor enters the ui.Component's region
func (*Button) OnLeave ¶
func (b *Button) OnLeave()
OnLeave is called when the cursor leaves the ui.Component's region
func (*Button) OnMotion ¶
func (b *Button) OnMotion(evt *sdl.MouseMotionEvent) bool
OnMotion is called when the cursor moves within the ui.Component's region
func (*Button) OnScroll ¶
func (b *Button) OnScroll(evt *sdl.MouseWheelEvent) bool
OnScroll is called when the user scrolls within the ui.Component's region
func (*Button) SetDefaultBackgroundColor ¶
SetDefaultBackgroundColor changes the default background color
func (*Button) SetDefaultTextColor ¶
SetDefaultTextColor changes the default text color
func (*Button) SetHighlightBackgroundColor ¶
SetHighlightBackgroundColor changes the highlight background color
func (*Button) SetHighlightTextColor ¶
SetHighlightTextColor changes the highlight text color
type Definition ¶
type Definition struct { Text string Children []Definition Action func() }
Definition defines menu bar menus