Documentation ¶
Overview ¶
Package op implements operations for updating a user interface.
Gio programs use operations, or ops, for describing their user interfaces. There are operations for drawing, defining input handlers, changing window properties as well as operations for controlling the execution of other operations.
Ops represents a list of operations. The most important use for an Ops list is to describe a complete user interface update to a ui/app.Window's Update method.
Drawing a colored square:
import "github.com/gop9/olt/gio/unit" import "github.com/gop9/olt/gio/app" import "github.com/gop9/olt/gio/op/paint" var w app.Window var e system.FrameEvent ops := new(op.Ops) ... ops.Reset() paint.ColorOp{Color: ...}.Add(ops) paint.PaintOp{Rect: ...}.Add(ops) e.Frame(ops)
State ¶
An Ops list can be viewed as a very simple virtual machine: it has an implicit mutable state stack and execution flow can be controlled with macros.
The StackOp saves the current state to the state stack and restores it later:
ops := new(op.Ops) var stack op.StackOp // Save the current state, in particular the transform. stack.Push(ops) // Apply a transform to subsequent operations. op.TransformOp{}.Offset(...).Add(ops) ... // Restore the previous transform. stack.Pop()
The CallOp invokes another operation list:
ops := new(op.Ops) ops2 := new(op.Ops) op.CallOp{Ops: ops2}.Add(ops)
The MacroOp records a list of operations to be executed later:
ops := new(op.Ops) var macro op.MacroOp macro.Record(ops) // Record operations by adding them. op.InvalidateOp{}.Add(ops) ... // End recording. macro.Stop() // replay the recorded operations by calling Add: macro.Add()
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallOp ¶
type CallOp struct { // Ops is the list of operations to invoke. Ops *Ops }
CallOp invokes all the operations from a separate operations list.
type InvalidateOp ¶
InvalidateOp requests a redraw at the given time. Use the zero value to request an immediate redraw.
func (InvalidateOp) Add ¶
func (r InvalidateOp) Add(o *Ops)
type MacroOp ¶
type MacroOp struct {
// contains filtered or unexported fields
}
MacroOp records a list of operations for later use.
type Ops ¶
type Ops struct {
// contains filtered or unexported fields
}
Ops holds a list of operations. Operations are stored in serialized form to avoid garbage during construction of the ops list.
type StackOp ¶
type StackOp struct {
// contains filtered or unexported fields
}
StackOp saves and restores the operation state in a stack-like manner.
type TransformOp ¶
type TransformOp struct {
// contains filtered or unexported fields
}
TransformOp applies a transform to the current transform.
func (TransformOp) Add ¶
func (t TransformOp) Add(o *Ops)
func (TransformOp) Multiply ¶
func (t TransformOp) Multiply(t2 TransformOp) TransformOp
Multiply by a transformation.
func (TransformOp) Offset ¶
func (t TransformOp) Offset(o f32.Point) TransformOp
Offset the transformation.