context

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2021 License: Unlicense Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// Constraints track the constraints for the active widget or
	// layout.
	Constraints constraints.Constraints

	Metric unit.Metric
	// By convention, a nil Queue is a signal to widgets to draw themselves in a
	// disabled state.
	Queue event.Queue
	// Now is the animation time.
	Now time.Time

	*op.Ops
}

Context carries the state needed by almost all layouts and widgets. A zero value Context never returns events, map units to pixels with a scale of 1.0, and returns the zero time from Now.

func NewContext

func NewContext(ops *op.Ops, e system.FrameEvent) Context

NewContext is a shorthand for

Context{
  Ops: ops,
  Now: e.Now,
  Queue: e.Queue,
  Config: e.Config,
  Constraints: Exact(e.Size),
}

NewContext calls ops.Reset and adjusts ops for e.Insets.

func (Context) Disabled

func (c Context) Disabled() Context

Disabled returns a copy of this context with a nil Queue, blocking events to widgets using it.

By convention, a nil Queue is a signal to widgets to draw themselves in a disabled state.

func (Context) Events

func (c Context) Events(k event.Tag) []event.Event

Events return the events available for the key. If no queue is configured, Events returns nil.

func (Context) Px

func (c Context) Px(v unit.Value) int

Px maps the value to pixels.

Jump to

Keyboard shortcuts

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