ui

package
v0.0.0-...-16f148f Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2018 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Tau = math.Pi * 2

Variables

This section is empty.

Functions

func Draw

func Draw(travCtx TraversalContext, root interface{}, ctx *Context2D)

func Edit

func Edit(base string, keycode string, key string) string

func IsVecOutside

func IsVecOutside(vec, size vec2.Vec2) bool

func NoopExit

func NoopExit(WidgetPath)

func PickOption

func PickOption(options []OptionContext, keycode string, key string) (WidgetPath, Option)

func ToLocal

func ToLocal(m TextMeasurer, path WidgetPath, v vec2.Vec2) vec2.Vec2

func Walk

func Walk(start interface{}, enter EnterCallback, exit ExitCallback)

func WalkAtPoint

func WalkAtPoint(m TextMeasurer, start interface{}, point vec2.Vec2, callback func(WidgetPath, vec2.Vec2) WalkAction)

Types

type Action

type Action interface {
	Move(TouchContext) Action
	End(TouchContext)
}

type Box

type Box struct {
	Top, Right, Bottom, Left float64
}

func (Box) Contains

func (box Box) Contains(v vec2.Vec2) bool

func (Box) Grow

func (box Box) Grow(x float64) Box

func (Box) Height

func (box Box) Height() float64

func (Box) Width

func (box Box) Width() float64

type Context2D

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

func MakeContext2D

func MakeContext2D(m TextMeasurer) Context2D

func (*Context2D) Arc

func (ctx *Context2D) Arc(x, y, r, alpha, beta float64, anticlockwise bool)

func (*Context2D) Arrow

func (ctx *Context2D) Arrow(size float64)

func (*Context2D) BeginPath

func (ctx *Context2D) BeginPath()

func (*Context2D) Circle

func (ctx *Context2D) Circle(pos vec2.Vec2, radius float64)

func (*Context2D) Clip

func (ctx *Context2D) Clip()

func (*Context2D) ClosePath

func (ctx *Context2D) ClosePath()

func (*Context2D) Ellipse

func (ctx *Context2D) Ellipse(x, y, rx, ry, rotation, alpha, beta float64, anticlockwise bool)

func (*Context2D) Fill

func (ctx *Context2D) Fill()

func (*Context2D) FillRect

func (ctx *Context2D) FillRect(x, y, w, h float64)

func (*Context2D) FillStyle

func (ctx *Context2D) FillStyle(fill string)

func (*Context2D) FillText

func (ctx *Context2D) FillText(text string, x, y float64)

func (*Context2D) Font

func (ctx *Context2D) Font(font string)

func (*Context2D) Hourglass

func (ctx *Context2D) Hourglass(color string)

func (*Context2D) LineTo

func (ctx *Context2D) LineTo(x, y float64)

func (*Context2D) LineTo2

func (ctx *Context2D) LineTo2(pos vec2.Vec2)

func (*Context2D) LineWidth

func (ctx *Context2D) LineWidth(w float64)

func (*Context2D) MarshalJSON

func (ctx *Context2D) MarshalJSON() ([]byte, error)

func (*Context2D) MeasureText

func (ctx *Context2D) MeasureText(text string) float64

func (*Context2D) MoveTo

func (ctx *Context2D) MoveTo(x, y float64)

func (*Context2D) MoveTo2

func (ctx *Context2D) MoveTo2(pos vec2.Vec2)

func (*Context2D) Rect

func (ctx *Context2D) Rect(x, y, w, h float64)

func (*Context2D) Rect2

func (ctx *Context2D) Rect2(box Box)

func (*Context2D) Restore

func (ctx *Context2D) Restore()

func (*Context2D) Rotate

func (ctx *Context2D) Rotate(alpha float64)

func (*Context2D) Save

func (ctx *Context2D) Save()

func (*Context2D) Scale

func (ctx *Context2D) Scale(s float64)

func (*Context2D) SetLineDash

func (ctx *Context2D) SetLineDash(pattern []float64)

func (*Context2D) Stroke

func (ctx *Context2D) Stroke()

func (*Context2D) StrokeStyle

func (ctx *Context2D) StrokeStyle(style string)

func (*Context2D) TextAlign

func (ctx *Context2D) TextAlign(align string)

func (*Context2D) TextBaseline

func (ctx *Context2D) TextBaseline(baseline string)

func (*Context2D) Transform

func (ctx *Context2D) Transform(m matrix.Matrix)

func (*Context2D) Translate

func (ctx *Context2D) Translate(x, y float64)

func (*Context2D) Translate2

func (ctx *Context2D) Translate2(pos vec2.Vec2)

type Drawable

type Drawable interface {
	Draw(*Context2D)
}

type EditOption

type EditOption struct {
	EditStatus EditStatus
	Editable   Editable
}

func (EditOption) Activate

func (o EditOption) Activate(TouchContext) Action

func (EditOption) IsEditing

func (o EditOption) IsEditing() bool

func (EditOption) Keycode

func (EditOption) Keycode() string

func (EditOption) Name

func (EditOption) Name() string

type EditStatus

type EditStatus interface {
	IsEditing(Editable) bool
	ToggleEditing(Editable)
}

type Editable

type Editable interface {
	Sized
	GetText() string
	SetText(string)
}

type EnterCallback

type EnterCallback func(WidgetPath) WalkAction

type ExitCallback

type ExitCallback func(WidgetPath)
type Menu struct {
	// contains filtered or unexported fields
}
func (m *Menu) ChooseOption(angle float64) Option
func (m *Menu) Draw(ctx *Context2D)
func (m *Menu) End(ctx TouchContext)
func (m *Menu) LoopOptions(cb func(o Option, alpha, beta float64))

alpha ∈ [0,Tau); beta > alpha

func (m *Menu) Move(ctx TouchContext) Action
func (m *Menu) Transform(TextMeasurer) matrix.Matrix
type MenuLayer struct {
	// contains filtered or unexported fields
}

func MakeMenuLayer

func MakeMenuLayer() MenuLayer
func (l *MenuLayer) Children() (children []interface{})
func (l *MenuLayer) OpenMenu(ctx TouchContext, opts []OptionContext) *Menu
type MenuRoot interface {
	GetMenuLayer() *MenuLayer
}

type Option

type Option interface {
	Name() string
	Keycode() string
	Activate(TouchContext) Action
}

type OptionContext

type OptionContext struct {
	Path    WidgetPath
	Options []Option
}

func QueryOptions

func QueryOptions(travCtx TraversalContext, root interface{}, v vec2.Vec2) []OptionContext

type Parent

type Parent interface {
	Children() []interface{} // stable back-to-front order
}

type PostDrawable

type PostDrawable interface {
	PostDraw(*Context2D)
}

type PreMoveAction

type PreMoveAction interface {
	PreMove(TouchContext)
}

type Sized

type Sized interface {
	Size(TextMeasurer) Box
}

type Spring

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

func MakeSpring

func MakeSpring(initialValue, target, speed float64) Spring

func (*Spring) Update

func (s *Spring) Update()

func (*Spring) Value

func (s *Spring) Value() float64

type TextMeasurer

type TextMeasurer interface {
	MeasureText(text string) float64
}

type Touch

type Touch struct {
	Curr  vec2.Vec2
	Last  vec2.Vec2
	Wheel float64
	// contains filtered or unexported fields
}

func MakeTouch

func MakeTouch(pos vec2.Vec2) *Touch

func (*Touch) EndAction

func (t *Touch) EndAction(m TextMeasurer)

func (*Touch) Move

func (t *Touch) Move(m TextMeasurer, curr vec2.Vec2)

func (*Touch) OpenMenu

func (t *Touch) OpenMenu(queryCtx TraversalContext, root MenuRoot)

func (*Touch) Position

func (t *Touch) Position(m TextMeasurer, w interface{}) vec2.Vec2

func (*Touch) StartAction

func (t *Touch) StartAction(queryCtx TraversalContext, root interface{}, keycode string, key string)

type TouchContext

type TouchContext struct {
	Touch *Touch
	Path  WidgetPath
	// contains filtered or unexported fields
}

func (TouchContext) At

func (ctx TouchContext) At(check func(interface{}) bool) TouchContext

func (TouchContext) AtTopBlueprint

func (ctx TouchContext) AtTopBlueprint() TouchContext

func (TouchContext) Delta

func (ctx TouchContext) Delta() vec2.Vec2

func (TouchContext) Position

func (ctx TouchContext) Position() vec2.Vec2

func (TouchContext) Query

func (ctx TouchContext) Query(callback func(WidgetPath, vec2.Vec2) WalkAction)

type Transformed

type Transformed interface {
	Transform(TextMeasurer) matrix.Matrix
}

type TraversalContext

type TraversalContext interface {
	TextMeasurer
	EditStatus
}

type TypeOption

type TypeOption struct {
	Editable Editable
	// contains filtered or unexported fields
}

func (TypeOption) Activate

func (t TypeOption) Activate(TouchContext) Action

func (TypeOption) Keycode

func (TypeOption) Keycode() string

func (TypeOption) Name

func (TypeOption) Name() string

type WalkAction

type WalkAction int
const (
	Explore WalkAction = iota
	Avoid
	Return
)

func WalkWithin

func WalkWithin(path WidgetPath, enter EnterCallback, exit ExitCallback) WalkAction

type Widget

type Widget interface {
	Options(vec2.Vec2) []Option
}

type WidgetPath

type WidgetPath []interface{} // root-to-child

Jump to

Keyboard shortcuts

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