editor

package
v0.0.0-...-e04bdec Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2015 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

A quick (and dirty!) editor for SPLICE drum patterns.

Index

Constants

View Source
const (
	CBlack   termbox.Attribute = termbox.ColorBlack
	CWhite   termbox.Attribute = termbox.ColorWhite
	CRed     termbox.Attribute = termbox.ColorRed
	CBlue    termbox.Attribute = termbox.ColorBlue
	CGreen   termbox.Attribute = termbox.ColorGreen
	CMagenta termbox.Attribute = termbox.ColorMagenta
	CYellow  termbox.Attribute = termbox.ColorYellow
	CDefault termbox.Attribute = termbox.ColorDefault
	ABold    termbox.Attribute = termbox.AttrBold
)

Variables

View Source
var (
	ScrW, ScrH   int
	ScrHW, ScrHH int
)

Functions

func Editor

func Editor(p *drum.Pattern)

Open the provided pattern in a new editor.

func MessageBox

func MessageBox(title, msg string, bg termbox.Attribute)

Open a popup Window with a message.

func Prompt

func Prompt(title, msg, placeholder string) string

Open a popup Window with primitive prompt. Returns an empty string if the user closes the Prompt (i.e. pressing <ESC>).

Types

type Box

type Box struct {
	X          int
	Y          int
	Width      int
	Height     int
	Foreground termbox.Attribute
	Background termbox.Attribute
}

A simple Box.

func BoxNew

func BoxNew(win *Window, x, y, w, h int) *Box

Create a new Box (and listen to callbacks on the provided Window).

func (*Box) Draw

func (b *Box) Draw()

Draw the Box (by filling cells with spaces).

func (*Box) Inside

func (b *Box) Inside(x, y int) bool

Check if a point is inside the Box.

func (*Box) SetColor

func (b *Box) SetColor(fg, bg termbox.Attribute) *Box

Set the foreground and background color of the Box.

type Label

type Label struct {
	X          int
	Y          int
	Text       string
	Foreground termbox.Attribute
	Background termbox.Attribute
}

A simple text label.

func LabelNew

func LabelNew(w *Window, x, y int, text string) *Label

Create a new Label (and listen for events on the provided Window).

func (*Label) Draw

func (l *Label) Draw()

Draw the Label. Note that Label's text is centered.

func (*Label) SetColor

func (l *Label) SetColor(fg, bg termbox.Attribute) *Label

Set foreground and background color of the Label.

type Led

type Led struct {
	X int
	Y int
	// contains filtered or unexported fields
}

Led is used to indicate which step the editor is on.

func LedNew

func LedNew(w *Window, x, y, step int, currStep *int) *Led

Create a new Led, assiged to the provided step.

func (*Led) Draw

func (l *Led) Draw()

Draw the Led. It will «light» if the current step is the step this Led is assigned to.

type StepButton

type StepButton struct {
	Box
	// contains filtered or unexported fields
}

Represents a step in a Track.

func StepButtonNew

func StepButtonNew(w *Window, x, y int, stepRef *bool) *StepButton

Create a new StepButton, with a reference to the step it is «assigned» to. The StepButton will also listen for mouse click events on the Window to handle toggling.

type Window

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

A Window simply handles the termbox event loop.

func WindowNew

func WindowNew(popup bool) *Window

Create a new Window. A popup Window differs in that it doesn't clear the whole screen before drawing.

func (*Window) Close

func (w *Window) Close()

Stop the event loop.

func (*Window) Listen

func (w *Window) Listen(e string, f func(args ...interface{}))

Register a listener for the event (e.g. "draw", "click", "exit").

func (*Window) Loop

func (w *Window) Loop()

Start the event loop.

func (*Window) Trigger

func (w *Window) Trigger(e string, args ...interface{})

Trigger an event (i.e. call all listeners) with the provided arguments.

Jump to

Keyboard shortcuts

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