Documentation ¶
Index ¶
- func SilentConsumer(*Area, events.Event) bool
- type Anchor
- func NewAbsoluteAnchor(value float32) Anchor
- func NewLimitedAnchor(from, to, reference Anchor) Anchor
- func NewOffsetAnchor(base Anchor, offset float32) Anchor
- func NewRelativeAnchor(from, to Anchor, fraction float32) Anchor
- func NewResolvingAnchor(resolver AnchorResolver) Anchor
- func ZeroAnchor() Anchor
- type AnchorResolver
- type Area
- func (area *Area) Bottom() Anchor
- func (area *Area) DispatchPositionalEvent(event events.PositionalEvent) (consumed bool)
- func (area *Area) HandleEvent(event events.Event) (consumed bool)
- func (area *Area) HasFocus() bool
- func (area *Area) IsVisible() bool
- func (area *Area) Left() Anchor
- func (area *Area) ReleaseFocus()
- func (area *Area) Remove()
- func (area *Area) Render()
- func (area *Area) RequestFocus()
- func (area *Area) Right() Anchor
- func (area *Area) Root() (root *Area)
- func (area *Area) SetVisible(visible bool)
- func (area *Area) Top() Anchor
- type AreaBuilder
- func (builder *AreaBuilder) Build() *Area
- func (builder *AreaBuilder) OnEvent(eventType events.EventType, handler EventHandler) *AreaBuilder
- func (builder *AreaBuilder) OnRender(render RenderFunction) *AreaBuilder
- func (builder *AreaBuilder) SetBottom(value Anchor) *AreaBuilder
- func (builder *AreaBuilder) SetLeft(value Anchor) *AreaBuilder
- func (builder *AreaBuilder) SetParent(parent *Area) *AreaBuilder
- func (builder *AreaBuilder) SetRight(value Anchor) *AreaBuilder
- func (builder *AreaBuilder) SetTop(value Anchor) *AreaBuilder
- func (builder *AreaBuilder) SetVisible(value bool) *AreaBuilder
- type EventHandler
- type RenderFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
NewAbsoluteAnchor returns an anchor with a determined value. Requests to set a new value are directly applied.
func NewLimitedAnchor ¶
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 ¶
NewOffsetAnchor returns an anchor with an absolute offset to another anchor. Requests to set a new value change the offset.
func NewRelativeAnchor ¶
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) 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 ¶
HandleEvent tries to process the given event. It returns true if the area consumed the event.
func (*Area) HasFocus ¶
HasFocus returns true if this area (or any child) currently has the focus. The root area always has focus.
func (*Area) ReleaseFocus ¶
func (area *Area) ReleaseFocus()
ReleaseFocus lets this area (and any of its children) lose focus.
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) SetVisible ¶
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.
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 ¶
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.