gesture

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT, Unlicense Imports: 12 Imported by: 64

Documentation

Overview

Package gesture implements common pointer gestures.

Gestures accept low level pointer Events from an event Queue and detect higher level actions such as clicks and scrolling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

type Axis uint8
const (
	Horizontal Axis = iota
	Vertical
	Both
)

func (Axis) String

func (a Axis) String() string

type Click

type Click struct {
	// contains filtered or unexported fields
}

Click detects click gestures in the form of ClickEvents.

func (*Click) Add

func (c *Click) Add(ops *op.Ops)

Add the handler to the operation list to receive click events.

func (*Click) Hovered

func (c *Click) Hovered() bool

Hovered returns whether a pointer is inside the area.

func (*Click) Pressed

func (c *Click) Pressed() bool

Pressed returns whether a pointer is pressing.

func (*Click) Update added in v0.4.0

func (c *Click) Update(q input.Source) (ClickEvent, bool)

Update state and return the next click events, if any.

type ClickEvent

type ClickEvent struct {
	Kind      ClickKind
	Position  image.Point
	Source    pointer.Source
	Modifiers key.Modifiers
	// NumClicks records successive clicks occurring
	// within a short duration of each other.
	NumClicks int
}

ClickEvent represent a click action, either a KindPress for the beginning of a click or a KindClick for a completed click.

func (ClickEvent) ImplementsEvent

func (ClickEvent) ImplementsEvent()

type ClickKind added in v0.4.0

type ClickKind uint8
const (
	// KindPress is reported for the first pointer
	// press.
	KindPress ClickKind = iota
	// KindClick is reported when a click action
	// is complete.
	KindClick
	// KindCancel is reported when the gesture is
	// cancelled.
	KindCancel
)

func (ClickKind) String added in v0.4.0

func (ct ClickKind) String() string

type Drag

type Drag struct {
	// contains filtered or unexported fields
}

Drag detects drag gestures in the form of pointer.Drag events.

func (*Drag) Add

func (d *Drag) Add(ops *op.Ops)

Add the handler to the operation list to receive drag events.

func (*Drag) Dragging

func (d *Drag) Dragging() bool

Dragging reports whether it is currently in use.

func (*Drag) Pressed

func (d *Drag) Pressed() bool

Pressed returns whether a pointer is pressing.

func (*Drag) Update added in v0.4.0

func (d *Drag) Update(cfg unit.Metric, q input.Source, axis Axis) (pointer.Event, bool)

Update state and return the next drag event, if any.

type Hover

type Hover struct {
	// contains filtered or unexported fields
}

Hover detects the hover gesture for a pointer area.

func (*Hover) Add

func (h *Hover) Add(ops *op.Ops)

Add the gesture to detect hovering over the current pointer area.

func (*Hover) Update added in v0.4.0

func (h *Hover) Update(q input.Source) bool

Update state and report whether a pointer is inside the area.

type Scroll

type Scroll struct {
	// contains filtered or unexported fields
}

Scroll detects scroll gestures and reduces them to scroll distances. Scroll recognizes mouse wheel movements as well as drag and fling touch gestures.

func (*Scroll) Add

func (s *Scroll) Add(ops *op.Ops)

Add the handler to the operation list to receive scroll events. The bounds variable refers to the scrolling boundaries as defined in pointer.Filter.

func (*Scroll) State

func (s *Scroll) State() ScrollState

State reports the scroll state.

func (*Scroll) Stop

func (s *Scroll) Stop()

Stop any remaining fling movement.

func (*Scroll) Update added in v0.4.0

func (s *Scroll) Update(cfg unit.Metric, q input.Source, t time.Time, axis Axis, bounds image.Rectangle) int

Update state and report the scroll distance along axis.

type ScrollState

type ScrollState uint8
const (
	// StateIdle is the default scroll state.
	StateIdle ScrollState = iota
	// StateDragging is reported during drag gestures.
	StateDragging
	// StateFlinging is reported when a fling is
	// in progress.
	StateFlinging
)

func (ScrollState) String

func (s ScrollState) String() string

Jump to

Keyboard shortcuts

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