ui

package
v0.0.0-...-1d09ed4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignUINode

func AlignUINode(uinode UINode, bounds pixel.Rect, valignment nodes.VerticalAlignment, halignment nodes.HorizontalAlignment)

Types

type Button

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

func NewButton

func NewButton(name string, w, h float64, text string) *Button

func (*Button) Enabled

func (b *Button) Enabled() bool

func (*Button) GetButtonStyles

func (b *Button) GetButtonStyles(state ButtonState) *nodes.Styles

func (*Button) GetOrigSize

func (b *Button) GetOrigSize() pixel.Vec

func (*Button) OnClick

func (b *Button) OnClick(fn func())

func (*Button) SetButtonStyles

func (b *Button) SetButtonStyles(state ButtonState, styles *nodes.Styles)

func (*Button) SetEnabled

func (b *Button) SetEnabled(enabled bool)

func (*Button) SetHAlignment

func (b *Button) SetHAlignment(h nodes.HorizontalAlignment)

func (*Button) SetSize

func (b *Button) SetSize(size pixel.Vec)

func (*Button) SetStyles

func (b *Button) SetStyles(styles *nodes.Styles)

func (*Button) SetText

func (b *Button) SetText(text string)

func (*Button) SetVAlignment

func (b *Button) SetVAlignment(v nodes.VerticalAlignment)

func (*Button) Update

func (b *Button) Update(dt float64)

func (*Button) UpdateFromTheme

func (b *Button) UpdateFromTheme(theme *nodes.Theme)

type ButtonGroup

type ButtonGroup struct {
	UIBase
	// contains filtered or unexported fields
}

func NewButtonGroup

func NewButtonGroup(name string, h float64) *ButtonGroup

func (*ButtonGroup) AddButton

func (g *ButtonGroup) AddButton(caption, value string, w float64)

func (*ButtonGroup) OnChange

func (g *ButtonGroup) OnChange(fn func(v string))

func (*ButtonGroup) SetAlignment

func (g *ButtonGroup) SetAlignment(a nodes.Alignment)

func (*ButtonGroup) SetStyles

func (g *ButtonGroup) SetStyles(styles *nodes.Styles)

type ButtonState

type ButtonState int
const (
	ButtonInit ButtonState = iota
	ButtonEnabled
	ButtonDisabled
	ButtonHover
	ButtonPressed
)

type CheckBox

type CheckBox struct {
	UIBase
	// contains filtered or unexported fields
}

func NewCheckBox

func NewCheckBox(name string, w, h float64, state bool) *CheckBox

func (*CheckBox) Init

func (c *CheckBox) Init()

func (*CheckBox) Mount

func (c *CheckBox) Mount()

func (*CheckBox) OnChange

func (c *CheckBox) OnChange(fn func(v bool))

func (*CheckBox) SetSize

func (c *CheckBox) SetSize(size pixel.Vec)

func (*CheckBox) SetState

func (c *CheckBox) SetState(state bool)

func (*CheckBox) State

func (c *CheckBox) State() bool

func (*CheckBox) Unmount

func (c *CheckBox) Unmount()

func (*CheckBox) Update

func (c *CheckBox) Update(dt float64)
type DropDown struct {
	UIBase
	// contains filtered or unexported fields
}

func NewDropDown

func NewDropDown(name, atlasname string, w, h, hdropdown float64) *DropDown

TODO: theme support

func (d *DropDown) AddValue(text, value string)
func (d *DropDown) ChangeValue(value, text string)
func (d *DropDown) Clear()
func (d *DropDown) HDropDown() float64
func (d *DropDown) Init()
func (d *DropDown) IterateEntries(fn func(value, text string))
func (d *DropDown) Mount()
func (d *DropDown) OnChange(fn func(string, string))
func (d *DropDown) RemoveValue(value string)
func (d *DropDown) SetHDropDown(h float64)
func (d *DropDown) SetSize(size pixel.Vec)
func (d *DropDown) SetValue(value string)
func (d *DropDown) Unmount()
func (d *DropDown) Update(dt float64)
func (d *DropDown) Value() string

type FloatInputBox

type FloatInputBox struct {
	InputBox
}

func NewFloatInputBox

func NewFloatInputBox(name string, w, h float64) *FloatInputBox

func (*FloatInputBox) FloatValue

func (f *FloatInputBox) FloatValue() (float64, error)

func (*FloatInputBox) SetFloatValue

func (f *FloatInputBox) SetFloatValue(v float64)

func (*FloatInputBox) Update

func (f *FloatInputBox) Update(dt float64)

type Grid

type Grid struct {
	UIBase
	// contains filtered or unexported fields
}

func NewGrid

func NewGrid(name string, cols int) *Grid

func (*Grid) AddChild

func (g *Grid) AddChild(child nodes.Node)

func (*Grid) ChildChanged

func (g *Grid) ChildChanged()

func (*Grid) Cols

func (g *Grid) Cols() int

func (*Grid) RemoveChild

func (g *Grid) RemoveChild(child nodes.Node)

func (*Grid) RemoveChildren

func (g *Grid) RemoveChildren()

func (*Grid) SetCols

func (g *Grid) SetCols(cols int)

func (*Grid) SetRecalc

func (g *Grid) SetRecalc(recalc bool)

func (*Grid) SetStyles

func (g *Grid) SetStyles(styles *nodes.Styles)

type HBox

type HBox struct {
	UIBase
	// contains filtered or unexported fields
}

func NewHBox

func NewHBox(name string) *HBox

func (*HBox) AddChild

func (h *HBox) AddChild(child nodes.Node)

func (*HBox) ChildChanged

func (h *HBox) ChildChanged()

func (*HBox) Init

func (h *HBox) Init()

func (*HBox) RemoveChild

func (h *HBox) RemoveChild(child nodes.Node)

func (*HBox) RemoveChildren

func (h *HBox) RemoveChildren()

func (*HBox) SetFixedSize

func (h *HBox) SetFixedSize(size pixel.Vec)

func (*HBox) SetStyles

func (h *HBox) SetStyles(styles *nodes.Styles)

type InputBox

type InputBox struct {
	UIBase
	// contains filtered or unexported fields
}

func NewInputBox

func NewInputBox(name string, w, h float64) *InputBox

func (*InputBox) Focus

func (i *InputBox) Focus()

func (*InputBox) Init

func (i *InputBox) Init()

func (*InputBox) OnChange

func (i *InputBox) OnChange(onchange func(string))

func (*InputBox) OnEnter

func (i *InputBox) OnEnter(onenter func(string))

func (*InputBox) SetSize

func (i *InputBox) SetSize(size pixel.Vec)

func (*InputBox) SetStyles

func (i *InputBox) SetStyles(styles *nodes.Styles)

func (*InputBox) SetValue

func (i *InputBox) SetValue(value string)

func (*InputBox) Update

func (i *InputBox) Update(dt float64)

func (*InputBox) UpdateFromTheme

func (i *InputBox) UpdateFromTheme(theme *nodes.Theme)

func (*InputBox) Value

func (i *InputBox) Value() string

type IntInputBox

type IntInputBox struct {
	InputBox
}

func NewIntInputBox

func NewIntInputBox(name string, w, h float64) *IntInputBox

func (*IntInputBox) IntValue

func (i *IntInputBox) IntValue() (int64, error)

func (*IntInputBox) SetIntValue

func (i *IntInputBox) SetIntValue(v int64)

func (*IntInputBox) Update

func (i *IntInputBox) Update(dt float64)
type Menu struct {
	VBox
	// contains filtered or unexported fields
}

func NewMenu

func NewMenu(name string, parent *Menu, menubar *MenuBar) *Menu
func (m *Menu) Activate(pos pixel.Vec)
func (m *Menu) SetItems(items []MenuItem)
func (m *Menu) Update(dt float64)
type MenuBar struct {
	HBox
	// contains filtered or unexported fields
}

func NewMenuBar

func NewMenuBar(name string) *MenuBar
func (m *MenuBar) OnSelect(fn func(v string))
func (m *MenuBar) SetItems(items []MenuItem)
func (m *MenuBar) SetMenuItemEnabled(value string, enabled bool)
func (m *MenuBar) SetWidth(w float64)
type MenuItem struct {
	Title   string
	Value   string
	SubMenu []MenuItem
	// contains filtered or unexported fields
}

type SelectList

type SelectList struct {
	UIBase
	// contains filtered or unexported fields
}

func NewSelectList

func NewSelectList(name string, w, h float64, multiselect bool) *SelectList

func (*SelectList) AddEntry

func (s *SelectList) AddEntry(text string, value string, content interface{})

func (*SelectList) ChangeEntry

func (s *SelectList) ChangeEntry(oldvalue string, text string, value string, content interface{})

func (*SelectList) Clear

func (s *SelectList) Clear()

func (*SelectList) Count

func (s *SelectList) Count() int

func (*SelectList) Init

func (s *SelectList) Init()

func (*SelectList) IterateEntries

func (s *SelectList) IterateEntries(fn func(value string, content interface{}))

func (*SelectList) MultiSelect

func (s *SelectList) MultiSelect() bool

func (*SelectList) OnSelect

func (s *SelectList) OnSelect(onselect func(v string, content interface{}))

func (*SelectList) OnUnselect

func (s *SelectList) OnUnselect(onunselect func(v string, content interface{}))

func (*SelectList) RemoveEntry

func (s *SelectList) RemoveEntry(value string)

func (*SelectList) Selected

func (s *SelectList) Selected() []SelectListSelection

func (*SelectList) SetMultiSelect

func (s *SelectList) SetMultiSelect(ms bool)

func (*SelectList) SetSize

func (s *SelectList) SetSize(size pixel.Vec)

func (*SelectList) SetStyles

func (s *SelectList) SetStyles(styles *nodes.Styles)

func (*SelectList) UnselectAll

func (s *SelectList) UnselectAll()

type SelectListSelection

type SelectListSelection struct {
	Value   string
	Content interface{}
}

type Slider

type Slider struct {
	UIBase
	// contains filtered or unexported fields
}

func NewSlider

func NewSlider(name string, min, max, current float32) *Slider

func (*Slider) Draw

func (s *Slider) Draw(win pixel.Target, mat pixel.Matrix)

func (*Slider) Init

func (s *Slider) Init()

func (*Slider) Mounted

func (s *Slider) Mounted()

func (*Slider) OnChange

func (s *Slider) OnChange(fn func(v float32))

func (*Slider) SetStyles

func (s *Slider) SetStyles(styles *nodes.Styles)

func (*Slider) SetValue

func (s *Slider) SetValue(v float32)

func (*Slider) Unmounted

func (s *Slider) Unmounted()

func (*Slider) Update

func (s *Slider) Update(dt float64)

func (*Slider) Value

func (s *Slider) Value() float32

type Text

type Text struct {
	UIBase
	// contains filtered or unexported fields
}

func NewText

func NewText(name string) *Text

func NewTextCustom

func NewTextCustom(name, atlasname string, textcolor color.Color) *Text

func (*Text) Clear

func (t *Text) Clear()

func (*Text) Draw

func (t *Text) Draw(win pixel.Target, mat pixel.Matrix)

func (*Text) GetContent

func (t *Text) GetContent() string

func (*Text) Printf

func (t *Text) Printf(format string, a ...interface{})

func (*Text) SetStyles

func (t *Text) SetStyles(styles *nodes.Styles)

func (*Text) Text

func (t *Text) Text() *text.Text

func (*Text) UpdateFromTheme

func (t *Text) UpdateFromTheme(theme *nodes.Theme)

type UIBase

type UIBase struct {
	nodes.BaseNode

	UISelf UINode
	// contains filtered or unexported fields
}

func NewUIBase

func NewUIBase(name string) *UIBase

func (*UIBase) Alignment

func (ui *UIBase) Alignment() nodes.Alignment

func (*UIBase) Contains

func (ui *UIBase) Contains(point pixel.Vec) bool

Contains returns whether the given point (in local coordinates) lies within the boundaries of this UI element

func (*UIBase) GetOrigPos

func (ui *UIBase) GetOrigPos() pixel.Vec

func (*UIBase) HAlignment

func (ui *UIBase) HAlignment() nodes.HorizontalAlignment

func (*UIBase) IsStylesOverridden

func (ui *UIBase) IsStylesOverridden() bool

func (*UIBase) KeepOnScreen

func (ui *UIBase) KeepOnScreen()

func (*UIBase) OverrideStyles

func (ui *UIBase) OverrideStyles(styles *nodes.Styles)

func (*UIBase) SetAlignment

func (ui *UIBase) SetAlignment(a nodes.Alignment)

func (*UIBase) SetHAlignment

func (ui *UIBase) SetHAlignment(h nodes.HorizontalAlignment)

func (*UIBase) SetOrigin

func (ui *UIBase) SetOrigin(origin pixel.Vec)

func (*UIBase) SetPos

func (ui *UIBase) SetPos(pos pixel.Vec)

func (*UIBase) SetSize

func (ui *UIBase) SetSize(size pixel.Vec)

func (*UIBase) SetStyles

func (ui *UIBase) SetStyles(styles *nodes.Styles)

func (*UIBase) SetStylesOverridden

func (ui *UIBase) SetStylesOverridden(overridden bool)

func (*UIBase) SetVAlignment

func (ui *UIBase) SetVAlignment(v nodes.VerticalAlignment)

func (*UIBase) Size

func (ui *UIBase) Size() pixel.Vec

func (*UIBase) VAlignment

func (ui *UIBase) VAlignment() nodes.VerticalAlignment

type UINode

type UINode interface {
	nodes.Node
	GetOrigPos() pixel.Vec
	Size() pixel.Vec
	Alignment() nodes.Alignment
	SetAlignment(a nodes.Alignment)
	OverrideStyles(styles *nodes.Styles)
	HAlignment() nodes.HorizontalAlignment
	SetHAlignment(h nodes.HorizontalAlignment)
	VAlignment() nodes.VerticalAlignment
	SetVAlignment(v nodes.VerticalAlignment)
	IsStylesOverridden() bool
	SetStylesOverridden(overridden bool)
}

type VBox

type VBox struct {
	UIBase
	// contains filtered or unexported fields
}

func NewVBox

func NewVBox(name string) *VBox

func (*VBox) AddChild

func (v *VBox) AddChild(child nodes.Node)

func (*VBox) ChildChanged

func (v *VBox) ChildChanged()

func (*VBox) Init

func (v *VBox) Init()

func (*VBox) RemoveChild

func (v *VBox) RemoveChild(child nodes.Node)

func (*VBox) RemoveChildren

func (v *VBox) RemoveChildren()

func (*VBox) SetHAlignment

func (v *VBox) SetHAlignment(val nodes.HorizontalAlignment)

func (*VBox) SetStyles

func (v *VBox) SetStyles(styles *nodes.Styles)

type VScroll

type VScroll struct {
	UIBase
	// contains filtered or unexported fields
}

func NewVScroll

func NewVScroll(name string, w, h float64) *VScroll

func (*VScroll) Init

func (v *VScroll) Init()

func (*VScroll) Scroll

func (v *VScroll) Scroll() float64

func (*VScroll) SetInner

func (v *VScroll) SetInner(inner UINode)

func (*VScroll) SetScroll

func (v *VScroll) SetScroll(scroll float64)

func (*VScroll) SetSize

func (v *VScroll) SetSize(size pixel.Vec)

func (*VScroll) Update

func (v *VScroll) Update(dt float64)

Jump to

Keyboard shortcuts

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