ui

package
v0.0.0-...-a463a72 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package ui defines some rudimentary UI components.

Index

Constants

View Source
const (
	ZoomMin     = 1
	ZoomMax     = 30
	ZoomDefault = 15
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Canvas

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

Canvas facilitates panning and zooming and tracks mouse input.

func NewCanvas

func NewCanvas() *Canvas

NewCanvas creates a new canvas

func (*Canvas) Draw

func (c *Canvas) Draw(mp *util.Mat4)

func (*Canvas) MouseDelta

func (c *Canvas) MouseDelta() (int, int)

MouseDelta returns the current mouse delta.

func (*Canvas) MouseMove

func (c *Canvas) MouseMove(x, y float64)

func (*Canvas) MousePosition

func (c *Canvas) MousePosition() (int, int)

MousePosition returns the current mouse position.

func (*Canvas) Resize

func (c *Canvas) Resize(w, h int)

func (*Canvas) Scroll

func (c *Canvas) Scroll(x, y float64)

func (*Canvas) ScrollTo

func (c *Canvas) ScrollTo(x, y int)

ScrollTo scrolls the viewport to the given, absolute position.

func (*Canvas) SetPanning

func (c *Canvas) SetPanning(v bool)

SetPanning sets the panning flag. Meaning we are either dragging the scene around or not.

func (*Canvas) SetZoom

func (c *Canvas) SetZoom(v int)

SetZoom sets the current zoom factor.

func (*Canvas) Viewport

func (c *Canvas) Viewport() (int, int)

Viewport returns the viewport width and height.

func (*Canvas) Zoom

func (c *Canvas) Zoom() int

Zoom returns the current zoom factor.

type CellSelector

type CellSelector struct {
	*Grid
	// contains filtered or unexported fields
}

CellSelector facilitates the selection of one or more cells. It maintains the current selection and provides facilities to draw the selection and the selection rectangle, if it is being drawn. It builds on the CellRenderer functionality.

func NewCellSelector

func NewCellSelector() *CellSelector

NewCellSelector creates a new cell selector ontop of a cell renderer.

func (*CellSelector) Draw

func (c *CellSelector) Draw(mp *util.Mat4)

func (*CellSelector) HoverTarget

func (c *CellSelector) HoverTarget() (int32, int32)

HoverTarget returns the cell coordinates at the current mouse cursor position.

func (*CellSelector) MouseButton

func (c *CellSelector) MouseButton(button glfw.MouseButton, action glfw.Action, mod glfw.ModifierKey)

func (*CellSelector) MouseMove

func (c *CellSelector) MouseMove(x, y float64)

func (*CellSelector) Scroll

func (c *CellSelector) Scroll(x, y float64)

func (*CellSelector) SelectAll

func (c *CellSelector) SelectAll()

SelectAll selects all cells.

func (*CellSelector) SelectionClear

func (c *CellSelector) SelectionClear()

SelectionClear clears the current selection.

func (*CellSelector) SelectionDelete

func (c *CellSelector) SelectionDelete()

SelectionDelete deletes the current selection from the simulation.

func (*CellSelector) SelectionMove

func (c *CellSelector) SelectionMove(x, y int)

SelectionMove moves the currently selected area up/down, left or right by some amount of cells as denoted by x and y. These can be be negative for left/up, positive for right/down and zero to not move at all.

func (*CellSelector) SetAddSelection

func (c *CellSelector) SetAddSelection(v bool)

SetAddSelection signals the type that we are adding to an existing selection instead of creating a new one.

type Clipboard

type Clipboard struct {
	*CellSelector
	// contains filtered or unexported fields
}

Clipboard extends a cell selector by providing clipboard functionality. It implements cut, copy and paste.

func NewClipboard

func NewClipboard() *Clipboard

NewClipboard creates a new clipboard ontop of a cell selector.

func (*Clipboard) ClipboardClear

func (c *Clipboard) ClipboardClear()

ClipboardClear empties the clipboard.

func (*Clipboard) ClipboardCopy

func (c *Clipboard) ClipboardCopy()

ClipboardCopy copies the current cell selection to the clipboard.

func (*Clipboard) ClipboardCut

func (c *Clipboard) ClipboardCut()

ClipboardCut copies the current selection to the clipboard and then deletes the selected cells from the simulation.

func (*Clipboard) ClipboardPaste

func (c *Clipboard) ClipboardPaste()

ClipboardPaste pastes the current cell selection from the clipboard, to the simulation at the current cursor position.

func (*Clipboard) Draw

func (c *Clipboard) Draw(mp *util.Mat4)

func (*Clipboard) MouseMove

func (c *Clipboard) MouseMove(x, y float64)

func (*Clipboard) Scroll

func (c *Clipboard) Scroll(x, y float64)

func (*Clipboard) SetPanning

func (c *Clipboard) SetPanning(v bool)

func (*Clipboard) ToggleDrawClipboard

func (c *Clipboard) ToggleDrawClipboard()

ToggleDrawClipboard toggles drawing of the clipboard contents.

type Grid

type Grid struct {
	*Canvas
	// contains filtered or unexported fields
}

Grid extends a canvas with grid rendering and snapping functionality.

func NewGrid

func NewGrid() *Grid

NewGrid creates a new grid ontop of a canvas

func (*Grid) Draw

func (g *Grid) Draw(mp *util.Mat4)

func (*Grid) Resize

func (g *Grid) Resize(w, h int)

func (*Grid) Scroll

func (g *Grid) Scroll(x, y float64)

func (*Grid) SetPanning

func (g *Grid) SetPanning(v bool)

func (*Grid) ToggleGridVisible

func (g *Grid) ToggleGridVisible() bool

ToggleGridVisible toggles visibility of the grid background. Returns the new state.

type InfoPanel

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

InfoPanel defines a rectangular panel with debug information.

func NewInfoPanel

func NewInfoPanel() *InfoPanel

NewPanel creates a new debug info panel.

func (*InfoPanel) Clear

func (p *InfoPanel) Clear()

Clear clears all panel contents.

func (*InfoPanel) Draw

func (p *InfoPanel) Draw(mp *util.Mat4)

func (*InfoPanel) Print

func (p *InfoPanel) Print(line int, v string, argv ...interface{})

Print sets the given line to the specified formatted content.

func (*InfoPanel) Release

func (p *InfoPanel) Release()

func (*InfoPanel) Resize

func (p *InfoPanel) Resize(x, y, w, h int)

Resize resizes and positions the button.

type Window

type Window struct {
	*glfw.Window
}

Canvas creates a GLFW and OpenGL context and facilitates handling of user input.

func CreateWindow

func CreateWindow(width, height int, fullscreen bool) (*Window, error)

CreateWindow creates a new window with the given configuration.

func (*Window) Release

func (w *Window) Release()

Release releases all GLFW and OpenGL resources.

func (*Window) SetTitle

func (w *Window) SetTitle(f string, argv ...interface{})

SetTitle sets the window title.

func (*Window) Update

func (w *Window) Update() bool

Update calls PollEvents, swaps the buffers and returns true if the window is to be closed.

Jump to

Keyboard shortcuts

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