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/Seikaijyu/gio/unit" import "github.com/Seikaijyu/gio/app" import "github.com/Seikaijyu/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 state such as transformation and color and execution flow can be controlled with macros.
Some state, such as the current color, is modified directly by operations with Add methods. Other state, such as transformation and clip shape, are represented by stacks.
This example sets the simple color state and pushes an offset to the transformation stack.
ops := new(op.Ops) // Set the color. paint.ColorOp{...}.Add(ops) // Apply an offset to subsequent operations. stack := op.Offset(...).Push(ops) ... // Undo the offset transformation. stack.Pop()
The MacroOp records a list of operations to be executed later:
ops := new(op.Ops) macro := op.Record(ops) // Record operations by adding them. op.InvalidateOp{}.Add(ops) ... // End recording. call := macro.Stop() // replay the recorded operations: call.Add(ops)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Defer ¶
Defer executes c after all other operations have completed, including previously deferred operations. Defer saves the transformation stack and pushes it prior to executing c. All other operation state is reset.
Note that deferred operations are executed in first-in-first-out order, unlike the Go facility of the same name.
Types ¶
type CallOp ¶
type CallOp struct {
// contains filtered or unexported fields
}
CallOp invokes the operations recorded by Record.
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 ¶
Ops holds a list of operations. Operations are stored in serialized form to avoid garbage during construction of the ops list.
type TransformOp ¶
type TransformOp struct {
// contains filtered or unexported fields
}
TransformOp represents a transformation that can be pushed on the transformation stack.
func Affine ¶
func Affine(a f32.Affine2D) TransformOp
Affine creates a TransformOp representing the transformation a.
func (TransformOp) Add ¶
func (t TransformOp) Add(o *Ops)
Add is like Push except it doesn't push the current transformation to the stack.
func (TransformOp) Push ¶
func (t TransformOp) Push(o *Ops) TransformStack
Push the current transformation to the stack and then multiply the current transformation with t.
type TransformStack ¶
type TransformStack struct {
// contains filtered or unexported fields
}
TransformStack represents a TransformOp pushed on the transformation stack.
func (TransformStack) Pop ¶
func (t TransformStack) Pop()
Directories ¶
Path | Synopsis |
---|---|
Package clip provides operations for defining areas that applies to operations such as paints and pointer handlers.
|
Package clip provides operations for defining areas that applies to operations such as paints and pointer handlers. |
Package paint provides drawing operations for 2D graphics.
|
Package paint provides drawing operations for 2D graphics. |