zoom

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package zoom contains code that tracks the current zoom level.

Index

Constants

View Source
const DefaultScrollStep = 10

DefaultScrollStep is the default value for the ScrollStep option.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is used to provide options.

func ScrollStep

func ScrollStep(perc int) Option

ScrollStep sets the amount of zoom in or out on a single mouse scroll event. This is set as a percentage of the current value size of the X axis. Must be a value in range 0 < value <= 100. Defaults to DefaultScrollStep.

type Range

type Range struct {
	// Start is the start of the range.
	Start int
	// End is the end of the range.
	End int
	// contains filtered or unexported fields
}

Range represents a range of values. The range includes all values x such that Start <= x < End.

type Tracker

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

Tracker tracks the state of mouse selection on the linechart and stores requests for zoom. This object is not thread-safe.

func New

func New(baseX *axes.XDetails, cvsAr, graphAr image.Rectangle, opts ...Option) (*Tracker, error)

New returns a new zoom tracker that tracks zoom requests within the provided graph area. The cvsAr argument indicates size of the entire canvas available to the widget.

func (*Tracker) Highlight

func (t *Tracker) Highlight() (bool, *Range)

Highlight returns true if a range on the graph area should be highlighted because the user is holding down the left mouse button and dragging mouse across the graph area. The returned range indicates the range of X cell coordinates within the graph area provided to New or Update. These are the columns that should be highlighted. Returns false of no area should be highlighted, in which case the state of the Range return value is undefined.

func (*Tracker) Mouse

func (t *Tracker) Mouse(m *terminalapi.Mouse) error

Mouse is used to forward mouse events to the zoom tracker.

func (*Tracker) Update

func (t *Tracker) Update(baseX *axes.XDetails, cvsAr, graphAr image.Rectangle) error

Update is used to inform the zoom tracker about the base X axis and the graph area. Should be called each time the widget redraws.

func (*Tracker) Zoom

func (t *Tracker) Zoom() *axes.XDetails

Zoom returns an adjusted X axis if zoom is applied, or the same axis as was provided to New or Update.

Jump to

Keyboard shortcuts

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