Documentation
¶
Index ¶
- Variables
- type Action
- type ActiveController
- func (c *ActiveController) Ack() EventEmitter
- func (c *ActiveController) Color() color.RGBA
- func (c *ActiveController) Disable()
- func (c *ActiveController) Enable()
- func (c *ActiveController) IsActive() bool
- func (c *ActiveController) Label() string
- func (c *ActiveController) Set(active bool)
- func (c *ActiveController) Trigger() EventReceiver
- type CompoundElement
- type Container
- type Control
- type DynamicElement
- type Event
- type EventEmitter
- type EventReceiver
- type EventType
- type Events
- type RawCompoundElement
- type RawDynamicElement
Constants ¶
This section is empty.
Variables ¶
var DrawAction = func(gtx *layout.Context, th *material.Theme) func(element gui.Item) (bool, error) { return func(element gui.Item) (bool, error) { if el, ok := element.(gui.DrawItem); ok { err := el.Draw(gtx, th) if err != nil { return false, err } } return true, nil } }
DrawFunction is a helper method to invoke the Draw method on an elements
var EventAction = func(pointer f32.Point) func(element gui.Item) (bool, error) { return func(element gui.Item) (bool, error) { var active bool if el, ok := element.(DynamicElement); ok { a, err := el.Event(pointer) if err != nil { return false, err } if a { active = true } } return active, nil } }
EventAction is a helper method to invoke the Event method on an elements
Functions ¶
This section is empty.
Types ¶
type ActiveController ¶
type ActiveController struct { }
ActiveController is a dummy always 'active' controller
func (*ActiveController) Ack ¶
func (c *ActiveController) Ack() EventEmitter
func (*ActiveController) Color ¶
func (c *ActiveController) Color() color.RGBA
func (*ActiveController) Disable ¶
func (c *ActiveController) Disable()
func (*ActiveController) Enable ¶
func (c *ActiveController) Enable()
func (*ActiveController) IsActive ¶
func (c *ActiveController) IsActive() bool
func (*ActiveController) Label ¶
func (c *ActiveController) Label() string
func (*ActiveController) Set ¶
func (c *ActiveController) Set(active bool)
func (*ActiveController) Trigger ¶
func (c *ActiveController) Trigger() EventReceiver
type CompoundElement ¶
type CompoundElement interface { Add(element gui.Item, controller Control) Remove(id uint32) Elements(gtx *layout.Context, apply Action) (bool, error) }
TODO : replace with items abstraction CompoundElement represents an element that can have children
type Container ¶
type Container struct { *gui.InteractiveElement CompoundElement }
Container represents a ui scene
func NewContainer ¶
NewContainer creates a new scene
type Control ¶
type Control interface { Label() string Color() color.RGBA Disable() Enable() IsActive() bool Set(active bool) Trigger() EventReceiver Ack() EventEmitter }
Control is an interface for a controller on the elements behavior
type DynamicElement ¶
type DynamicElement interface { gui.Area Event(pointer f32.Point) (bool, error) Activate() error Reset() error IsActive() bool }
DynamicElement represents an interactive UI element
type EventEmitter ¶
type EventEmitter chan<- Event
type EventReceiver ¶
type EventReceiver <-chan Event
type RawCompoundElement ¶
type RawCompoundElement struct {
// contains filtered or unexported fields
}
RawCompundElement is the base implementation for a compund element
func NewCompoundElement ¶
func NewCompoundElement() *RawCompoundElement
NewCompoundElement creates a new compound element
func (*RawCompoundElement) Add ¶
func (s *RawCompoundElement) Add(element gui.Item, controller Control)
Add adds a new element to the group
func (*RawCompoundElement) Remove ¶
func (s *RawCompoundElement) Remove(id uint32)
Remove removes an element by id from the group
func (*RawCompoundElement) Size ¶
func (s *RawCompoundElement) Size() int
Size returns the number of child elements
type RawDynamicElement ¶
RawDynamicElement is the base implementation of a dynamic element
func NewDynamicElement ¶
func NewDynamicElement(rect *f32.Rectangle) *RawDynamicElement
NewDynamicElement creates a new dynamic element
func (*RawDynamicElement) Activate ¶
func (s *RawDynamicElement) Activate() error
Activate triggers the activation of a dynamic element
func (*RawDynamicElement) Event ¶
func (s *RawDynamicElement) Event(pointer f32.Point) (bool, error)
Event propagates the scene event to the element
func (*RawDynamicElement) IsActive ¶
func (s *RawDynamicElement) IsActive() bool
IsActive returns the activation status of a dynamic element
func (*RawDynamicElement) Reset ¶
func (s *RawDynamicElement) Reset() error
Reset resets the state of an dynamic element