cursor

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: BSD-3-Clause Imports: 5 Imported by: 2

Documentation

Overview

Package cursor defines the oswin cursor interface and standard system cursors that are supported across platforms

Index

Constants

This section is empty.

Variables

View Source
var Drags = map[Shapes]struct{}{
	DragCopy: {},
	DragMove: {},
	DragLink: {},
}

Drags is a map-set of cursors used for signaling dragging events.

View Source
var KiT_Shapes = kit.Enums.AddEnum(ShapesN, kit.NotBitFlag, nil)

Functions

This section is empty.

Types

type Cursor

type Cursor interface {

	// Current returns the current shape of the cursor.
	Current() Shapes

	// Push pushes a new active cursor.
	Push(sh Shapes)

	// PushIfNot pushes a new active cursor if it is not already set to given shape.
	PushIfNot(sh Shapes) bool

	// Pop pops cursor off the stack and restores the previous cursor -- an
	// error message is emitted if no more cursors on the stack (programming
	// error).
	Pop()

	// PopIf pops cursor off the stack and restores the previous cursor if the
	// current cursor is the given shape.
	PopIf(sh Shapes) bool

	// Set sets the active cursor, without reference to the cursor stack --
	// generally not recommended for direct use -- prefer Push / Pop.
	Set(sh Shapes)

	// IsVisible returns whether cursor is currently visible (according to Hide / show actions)
	IsVisible() bool

	// Hide hides the cursor if it is not already hidden.
	Hide()

	// Show shows the cursor after a hide if it is hidden.
	Show()

	// IsDrag returns true if the current cursor is used for signaling dragging events.
	IsDrag() bool
}

Cursor manages the mouse cursor / pointer appearance. Currently only a fixed set of standard cursors are supported, but in the future it will be possible to set the cursor from an image / svg.

type CursorBase

type CursorBase struct {

	// Stack is the stack of shapes from push / pop actions.
	Stack []Shapes

	// Cur is current shape -- maintained by std methods.
	Cur Shapes

	// Vis is visibility: be sure to initialize to true!
	Vis bool
}

CursorBase provides the common infrastructure for Cursor interface.

func (*CursorBase) Current

func (c *CursorBase) Current() Shapes

func (*CursorBase) IsDrag

func (c *CursorBase) IsDrag() bool

func (*CursorBase) IsVisible

func (c *CursorBase) IsVisible() bool

func (*CursorBase) PeekStack

func (c *CursorBase) PeekStack() Shapes

PeekStack returns top item on the stack (default Arrow if nothing on stack)

func (*CursorBase) PopStack

func (c *CursorBase) PopStack() (Shapes, error)

PopStack pops item off the stack, returning 2nd-to-last item on stack

func (*CursorBase) PushStack

func (c *CursorBase) PushStack(sh Shapes)

PushStack pushes item on the stack

type Shapes

type Shapes int32

Shapes are the standard cursor shapes available on all platforms

const (
	// Arrow is the standard arrow pointer
	Arrow Shapes = iota

	// Cross is a crosshair plus-like cursor -- typically used for precise actions.
	Cross

	// DragCopy indicates that the current drag operation will copy the dragged items
	DragCopy

	// DragMove indicates that the current drag operation will move the dragged items
	DragMove

	// DragLink indicates that the current drag operation will link the dragged items
	DragLink

	// HandPointing is a hand with a pointing index finger -- typically used
	// to indicate a link is clickable.
	HandPointing

	// HandOpen is an open hand -- typically used to indicate ability to click
	// and drag to move something.
	HandOpen

	// HandClosed is a closed hand -- typically used to indicate a dragging
	// operation involving scrolling.
	HandClosed

	// Help is an arrow and question mark indicating help is available.
	Help

	// IBeam is the standard text-entry symbol like a capital I.
	IBeam

	// Not is a slashed circle indicating operation not allowed (NO).
	Not

	// UpDown is Double-pointed arrow pointing up and down (SIZENS).
	UpDown

	// LeftRight is a Double-pointed arrow pointing west and east (SIZEWE).
	LeftRight

	// UpRight is a Double-pointed arrow pointing up-right and down-left (SIZEWE).
	UpRight

	// UpLeft is a Double-pointed arrow pointing up-left and down-right (SIZEWE).
	UpLeft

	// AllArrows is all four directions of arrow pointing.
	AllArrows

	// Wait is a system-dependent busy / wait cursor (typically an hourglass).
	Wait

	// ShapesN is number of standard cursor shapes
	ShapesN
)

func (*Shapes) FromString

func (i *Shapes) FromString(s string) error

func (Shapes) String

func (i Shapes) String() string

Jump to

Keyboard shortcuts

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