components

package
v0.0.0-...-d623aaa Latest Latest
Warning

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

Go to latest
Published: May 28, 2018 License: ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIndexOutOfBounds  = errors.New("index out of bounds")
	ErrComponentNotFound = errors.New("component not found in list")
)

Component handling errors

Functions

This section is empty.

Types

type Attribute

type Attribute string

Attribute is a single componment attribute

func (Attribute) Float32

func (a Attribute) Float32() (float32, error)

Float32 tries to parse an attribute as a float32 number

func (Attribute) Int

func (a Attribute) Int() (int, error)

Int tries to parse an attribute as an integer number

func (Attribute) String

func (a Attribute) String() string

String returns the underlying unparsed string value of the attribute

type AttributeList

type AttributeList map[string]Attribute

AttributeList is a list of attributes for a component, divided by key

func (AttributeList) Get

func (a AttributeList) Get(name string, def string) Attribute

Get returns either the requested attribute or a default value

type Base

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

Base is the common parent of all components

func (*Base) AppendChild

func (c *Base) AppendChild(component Component)

AppendChild adds a component at the end of the list

func (*Base) Bounds

func (c *Base) Bounds() Bounds

func (*Base) Children

func (c *Base) Children() ComponentList

Children returns the list of all children components

func (*Base) ChildrenStr

func (c *Base) ChildrenStr() (out string)

ChildrenStr calls String() on each children and indents the results

func (*Base) ClearFlags

func (c *Base) ClearFlags()

func (*Base) Draw

func (c *Base) Draw()

func (*Base) FindChildIndex

func (c *Base) FindChildIndex(component Component) int

FindChildIndex finds a component's index in the list

func (*Base) InsertChild

func (c *Base) InsertChild(component Component, index int) error

InsertChild inserts a component in one index of the list, moving all other components forward

func (*Base) Parent

func (c *Base) Parent() Component

func (*Base) PrependChild

func (c *Base) PrependChild(component Component)

PrependChild inserts a component at the beginning of the list

func (*Base) RemoveChild

func (c *Base) RemoveChild(component Component) error

RemoveChild removes a component from the list

func (*Base) RemoveChildByIndex

func (c *Base) RemoveChildByIndex(i int) error

RemoveChildByIndex removes the ith component from the list

func (*Base) Root

func (c *Base) Root() Component

func (*Base) SetBounds

func (c *Base) SetBounds(bounds Bounds)

func (*Base) SetRedraw

func (c *Base) SetRedraw()

func (*Base) ShouldDraw

func (c *Base) ShouldDraw() bool

type Bounds

type Bounds struct {
	Position
	Size
}

func BoundsFromRect

func BoundsFromRect(rect image.Rectangle) Bounds

func (Bounds) Scale

func (b Bounds) Scale(s Size) Bounds

func (Bounds) String

func (b Bounds) String() string

type Component

type Component interface {
	Draw()
	ShouldDraw() bool

	Bounds() Bounds
	SetBounds(Bounds)

	Parent() Component
	Children() ComponentList
	Root() Component

	AppendChild(Component)
	InsertChild(Component, int) error
	PrependChild(Component)
	RemoveChild(Component) error
	FindChildIndex(Component) int
	RemoveChildByIndex(int) error
	// contains filtered or unexported methods
}

Component is a renderable UI component that can optionally hold children

type ComponentList

type ComponentList []Component

ComponentList is a modifiable, ordered list of components

type ComponentProvider

type ComponentProvider func(AttributeList) (Component, error)

ComponentProvider is a function that takes a list of attributes and creates a component with the attributes applied

type Drawable

type Drawable struct {
	Base
	Mesh *opengl.Mesh
}

func (*Drawable) Draw

func (c *Drawable) Draw()

type Position

type Position struct {
	X, Y float32
}

func (Position) Scale

func (p Position) Scale(s Size) Position

func (Position) String

func (p Position) String() string

type Size

type Size struct {
	Width, Height float32
}

func (Size) Inverse

func (s Size) Inverse() Size

func (Size) Scale

func (s Size) Scale(z Size) Size

func (Size) String

func (s Size) String() string

type Text

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

Text is a common parent of all text-based components

func (*Text) ClearFlags

func (c *Text) ClearFlags()

func (*Text) Draw

func (c *Text) Draw()

func (*Text) SetFontFace

func (c *Text) SetFontFace(name string)

func (*Text) SetFontSize

func (c *Text) SetFontSize(size float64)

func (*Text) SetText

func (c *Text) SetText(str string)

SetText changes the text content of the text control

func (*Text) ShouldDraw

func (c *Text) ShouldDraw() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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