menu

package
v0.0.0-...-c744f44 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 10 Imported by: 0

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

View Source
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) Destroy

func (b *Bar) Destroy()

Destroy tears down the menubar's state

func (*Bar) GetEntryAt

func (b *Bar) GetEntryAt(x int32, y int32) (*entry, error)

GetEntryAt returns the menu entry below the given mouse coordinates

func (*Bar) InBoundary

func (b *Bar) InBoundary(pt sdl.Point) bool

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

func (*Bar) OnResize

func (b *Bar) OnResize(x, y int32)

OnResize updates the menubar for when the window is resized

func (*Bar) OnScroll

func (b *Bar) OnScroll(*sdl.MouseWheelEvent) bool

OnScroll updates the menubar for when the mouse scrolls within its boundary

func (*Bar) Render

func (b *Bar) Render()

Render renders the menubar and all its components

func (*Bar) String

func (b *Bar) String() string

String returns the name of the component type

type Button

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

Button defines an interactive button

func NewButton

func NewButton(area *sdl.Rect, cfg *config.Config, text string, action func()) (*Button, error)

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

func (b *Button) InBoundary(pt sdl.Point) bool

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) OnResize

func (b *Button) OnResize(x, y int32)

OnResize is called when the user resizes the window

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) Render

func (b *Button) Render()

Render draws the ui.Component

func (*Button) SetDefaultBackgroundColor

func (b *Button) SetDefaultBackgroundColor(color [4]float32)

SetDefaultBackgroundColor changes the default background color

func (*Button) SetDefaultTextColor

func (b *Button) SetDefaultTextColor(color [4]float32)

SetDefaultTextColor changes the default text color

func (*Button) SetHighlightBackgroundColor

func (b *Button) SetHighlightBackgroundColor(color [4]float32)

SetHighlightBackgroundColor changes the highlight background color

func (*Button) SetHighlightTextColor

func (b *Button) SetHighlightTextColor(color [4]float32)

SetHighlightTextColor changes the highlight text color

func (*Button) String

func (b *Button) String() string

String returns the name of the component type

type Definition

type Definition struct {
	Text     string
	Children []Definition
	Action   func()
}

Definition defines menu bar menus

Jump to

Keyboard shortcuts

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