ui

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2018 License: BSD-3-Clause Imports: 1 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SilentConsumer

func SilentConsumer(*Area, events.Event) bool

SilentConsumer is an event consumer always returning true.

Types

type Anchor

type Anchor interface {
	// Value returns the current value of the anchor.
	Value() float32

	// RequestValue suggests a new value for the anchor. Depending on the implementation,
	// the provided value may be taken over, a nearest approximation be used, or
	// ignored alltogether.
	RequestValue(newValue float32)
}

Anchor provides an absolute value based on some reference. It is used for placement and sizing in a visual layout.

func NewAbsoluteAnchor

func NewAbsoluteAnchor(value float32) Anchor

NewAbsoluteAnchor returns an anchor with a determined value. Requests to set a new value are directly applied.

func NewLimitedAnchor

func NewLimitedAnchor(from, to, reference Anchor) Anchor

NewLimitedAnchor returns an anchor which limits the value of another anchor within two reference anchors. Requests to set a new value are forwarded to the reference anchor if the new value is within the allowed limits.

func NewOffsetAnchor

func NewOffsetAnchor(base Anchor, offset float32) Anchor

NewOffsetAnchor returns an anchor with an absolute offset to another anchor. Requests to set a new value change the offset.

func NewRelativeAnchor

func NewRelativeAnchor(from, to Anchor, fraction float32) Anchor

NewRelativeAnchor returns an anchor which derives a value from a fraction between two other anchors. Requests to set a new value update the fraction value.

func NewResolvingAnchor

func NewResolvingAnchor(resolver AnchorResolver) Anchor

NewResolvingAnchor returns an anchor resolving to another anchor via a resolver function. Requests to set a new value are forwarded.

func ZeroAnchor

func ZeroAnchor() Anchor

ZeroAnchor returns an anchor with the static value 0. Requests to set a new value are ignored.

type AnchorResolver

type AnchorResolver func() Anchor

AnchorResolver is a function returning another anchor.

type Area

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

Area specifies one rectangular area within the user-interface stack.

func (*Area) Bottom

func (area *Area) Bottom() Anchor

Bottom returns the bottom anchor.

func (*Area) DispatchPositionalEvent

func (area *Area) DispatchPositionalEvent(event events.PositionalEvent) (consumed bool)

DispatchPositionalEvent tries to find an event handler in this areas UI tree at the position of the event. The event is tried depth-first, before trying to handle it within this area.

func (*Area) HandleEvent

func (area *Area) HandleEvent(event events.Event) (consumed bool)

HandleEvent tries to process the given event. It returns true if the area consumed the event.

func (*Area) HasFocus

func (area *Area) HasFocus() bool

HasFocus returns true if this area (or any child) currently has the focus. The root area always has focus.

func (*Area) IsVisible

func (area *Area) IsVisible() bool

IsVisible returns true if the area is currently visible.

func (*Area) Left

func (area *Area) Left() Anchor

Left returns the left anchor.

func (*Area) ReleaseFocus

func (area *Area) ReleaseFocus()

ReleaseFocus lets this area (and any of its children) lose focus.

func (*Area) Remove

func (area *Area) Remove()

Remove removes the area from the parent.

func (*Area) Render

func (area *Area) Render()

Render first renders this area, then sequentially all children.

func (*Area) RequestFocus

func (area *Area) RequestFocus()

RequestFocus sets this area (and all of its parents) first in receiving events. Any previously focused area not in the parent list of this area will lose its focus.

func (*Area) Right

func (area *Area) Right() Anchor

Right returns the right anchor.

func (*Area) Root

func (area *Area) Root() (root *Area)

Root returns the area at the base of the UI tree.

func (*Area) SetVisible

func (area *Area) SetVisible(visible bool)

SetVisible determines whether the area (and all of its children) shall be visible and target for events. Invisible areas are not rendered and will not handle any events.

func (*Area) Top

func (area *Area) Top() Anchor

Top returns the top anchor.

type AreaBuilder

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

AreaBuilder is used to create a new user-interface area.

func NewAreaBuilder

func NewAreaBuilder() *AreaBuilder

NewAreaBuilder returns a new instance of a builder for creating areas.

func (*AreaBuilder) Build

func (builder *AreaBuilder) Build() *Area

Build creates a new area instance based on the currently set properties.

func (*AreaBuilder) OnEvent

func (builder *AreaBuilder) OnEvent(eventType events.EventType, handler EventHandler) *AreaBuilder

OnEvent sets an event handler for given event type.

func (*AreaBuilder) OnRender

func (builder *AreaBuilder) OnRender(render RenderFunction) *AreaBuilder

OnRender sets the function for rendering the area. By default, an area has no own presentation.

func (*AreaBuilder) SetBottom

func (builder *AreaBuilder) SetBottom(value Anchor) *AreaBuilder

SetBottom sets the bottom anchor. Default: ZeroAnchor

func (*AreaBuilder) SetLeft

func (builder *AreaBuilder) SetLeft(value Anchor) *AreaBuilder

SetLeft sets the left anchor. Default: ZeroAnchor

func (*AreaBuilder) SetParent

func (builder *AreaBuilder) SetParent(parent *Area) *AreaBuilder

SetParent sets the parent area. By default, the builder has no parent set and the created area will be a root area.

func (*AreaBuilder) SetRight

func (builder *AreaBuilder) SetRight(value Anchor) *AreaBuilder

SetRight sets the right anchor. Default: ZeroAnchor

func (*AreaBuilder) SetTop

func (builder *AreaBuilder) SetTop(value Anchor) *AreaBuilder

SetTop sets the top anchor. Default: ZeroAnchor

func (*AreaBuilder) SetVisible

func (builder *AreaBuilder) SetVisible(value bool) *AreaBuilder

SetVisible sets the initial visibility.

type EventHandler

type EventHandler func(*Area, events.Event) bool

EventHandler is called for events dispatched to the area.

type RenderFunction

type RenderFunction func(*Area)

RenderFunction is called when an area wants to render its content.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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