gui

package
v0.0.0-...-bb8a734 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2015 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySpace        = 32
	KeyApostrophe   = 39
	KeyComma        = 44
	KeyMinus        = 45
	KeyPeriod       = 46
	KeySlash        = 47
	Key0            = 48
	Key1            = 49
	Key2            = 50
	Key3            = 51
	Key4            = 52
	Key5            = 53
	Key6            = 54
	Key7            = 55
	Key8            = 56
	Key9            = 57
	KeySemicolon    = 59
	KeyEqual        = 61
	KeyA            = 65
	KeyB            = 66
	KeyC            = 67
	KeyD            = 68
	KeyE            = 69
	KeyF            = 70
	KeyG            = 71
	KeyH            = 72
	KeyI            = 73
	KeyJ            = 74
	KeyK            = 75
	KeyL            = 76
	KeyM            = 77
	KeyN            = 78
	KeyO            = 79
	KeyP            = 80
	KeyQ            = 81
	KeyR            = 82
	KeyS            = 83
	KeyT            = 84
	KeyU            = 85
	KeyV            = 86
	KeyW            = 87
	KeyX            = 88
	KeyY            = 89
	KeyZ            = 90
	KeyLeftBracket  = 91
	KeyBackslash    = 92
	KeyRightBracket = 93
	KeyGraveAccent  = 96
	KeyEscape       = 256
	KeyEnter        = 257
	KeyTab          = 258
	KeyBackspace    = 259
	KeyInsert       = 260
	KeyDelete       = 261
	KeyRight        = 262
	KeyLeft         = 263
	KeyDown         = 264
	KeyUp           = 265
	KeyPageUp       = 266
	KeyPageDown     = 267
	KeyHome         = 268
	KeyEnd          = 269
	KeyCapsLock     = 280
	KeyScrollLock   = 281
	KeyNumLock      = 282
	KeyPrintScreen  = 283
	KeyPause        = 284
	KeyF1           = 290
	KeyF2           = 291
	KeyF3           = 292
	KeyF4           = 293
	KeyF5           = 294
	KeyF6           = 295
	KeyF7           = 296
	KeyF8           = 297
	KeyF9           = 298
	KeyF10          = 299
	KeyF11          = 300
	KeyF12          = 301
	KeyF13          = 302
	KeyF14          = 303
	KeyF15          = 304
	KeyF16          = 305
	KeyF17          = 306
	KeyF18          = 307
	KeyF19          = 308
	KeyF20          = 309
	KeyF21          = 310
	KeyF22          = 311
	KeyF23          = 312
	KeyF24          = 313
	KeyF25          = 314
	KeyKP0          = 320
	KeyKP1          = 321
	KeyKP2          = 322
	KeyKP3          = 323
	KeyKP4          = 324
	KeyKP5          = 325
	KeyKP6          = 326
	KeyKP7          = 327
	KeyKP8          = 328
	KeyKP9          = 329
	KeyKPDecimal    = 330
	KeyKPDivide     = 331
	KeyKPMultiply   = 332
	KeyKPSubtract   = 333
	KeyKPAdd        = 334
	KeyKPEnter      = 335
	KeyKPEqual      = 336
	KeyLeftShift    = 340
	KeyLeftControl  = 341
	KeyLeftAlt      = 342
	KeyLeftSuper    = 343
	KeyRightShift   = 344
	KeyRightControl = 345
	KeyRightAlt     = 346
	KeyRightSuper   = 347
	KeyMenu         = 348
	KeyLast         = KeyMenu
)

Variables

This section is empty.

Functions

func Do

func Do(v View, f func())

func DoChan

func DoChan(v View) chan<- func()

func DrawBezier

func DrawBezier(ctrlPts ...Point)

func DrawLine

func DrawLine(p1, p2 Point)

func DrawPoint

func DrawPoint(p Point)

func DrawPolygon

func DrawPolygon(pts ...Point)

func DrawRect

func DrawRect(r Rectangle)

func FillPolygon

func FillPolygon(pts ...Point)

func FillRect

func FillRect(r Rectangle)

func Height

func Height(v View) float64

func Hide

func Hide(v View)

func Lower

func Lower(v View)

func MouseParent

func MouseParent(v View, m MouseEvent)

func MoveCenter

func MoveCenter(v View, p Point)

func MoveOrigin

func MoveOrigin(v View, p Point)

func NewWindow

func NewWindow(self View, title string, init func(w *Window))

func NumChildren

func NumChildren(v View) int

func Pan

func Pan(v View, p Point)

func Quit

func Quit()

func Raise

func Raise(v View)

func Repaint

func Repaint(v View)

func Resize

func Resize(v View, s Point)

func ResizeToFit

func ResizeToFit(v View, margin float64)

func Rotate

func Rotate(rot float64)

func Run

func Run(init func()) error

must be called on the main goroutine, which will run on the main thread because glfw calls runtime.LockOSThread()

func SetColor

func SetColor(c Color)

func SetKeyFocus

func SetKeyFocus(v View)

func SetLineWidth

func SetLineWidth(x float64)

func SetMouser

func SetMouser(m MouserView, button int)

func SetPointSize

func SetPointSize(x float64)

func Show

func Show(v View)

func Width

func Width(v View) float64

Types

type AggregateMouser

type AggregateMouser []Mouser

func (AggregateMouser) Mouse

func (a AggregateMouser) Mouse(m MouseEvent)

type Clicker

type Clicker func(MouseEvent)

func NewClickFocuser

func NewClickFocuser(view View) Clicker

func (Clicker) Mouse

func (c Clicker) Mouse(m MouseEvent)

type Color

type Color struct{ R, G, B, A float64 }

type KeyEvent

type KeyEvent struct {
	Key int

	Repeat                  bool
	Text                    string // only present on Press and Repeat, not Release
	Shift, Ctrl, Alt, Super bool
	Command                 bool // platform-independent command key (Super on OS X, Ctrl elsewhere)
	// contains filtered or unexported fields
}

type MouseEvent

type MouseEvent struct {
	Pos                        Point
	Enter, Leave               bool
	Move, Press, Release, Drag bool
	Button                     int
}

type Mouser

type Mouser interface {
	Mouse(MouseEvent)
}

type MouserView

type MouserView interface {
	Mouser
	View
}

type Mover

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

func NewMover

func NewMover(v View) *Mover

func (*Mover) Mouse

func (d *Mover) Mouse(m MouseEvent)

type Panner

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

func NewPanner

func NewPanner(v View) *Panner

func (*Panner) Mouse

func (p *Panner) Mouse(m MouseEvent)

type Point

type Point struct {
	X, Y float64
}

A Point is an X, Y coordinate pair. The axes increase right and down.

var ZP Point

ZP is the zero Point.

func Center

func Center(v View) Point

func CenterInParent

func CenterInParent(v View) Point

func LineToLine

func LineToLine(p, p2, q, q2 Point) (z, z2 Point)

LineToLine returns the Points z and z2 on line segments (p, p2) and (q, q2), respectively, such that the distance from z to z2 is minimized.

func Map

func Map(p Point, from, to View) Point

func MapFromParent

func MapFromParent(p Point, v View) Point

func MapToParent

func MapToParent(p Point, v View) Point

func PointToLine

func PointToLine(p, x, y Point) Point

PointToLine returns the Point on line segment (x, y) that is nearest to p.

func Pos

func Pos(v View) Point

func Pt

func Pt(X, Y float64) Point

Pt is shorthand for Point{X, Y}.

func Size

func Size(v View) Point

func (Point) Add

func (p Point) Add(q Point) Point

Add returns the vector p+q.

func (Point) Angle

func (p Point) Angle() float64

func (Point) Cross

func (p Point) Cross(q Point) float64

func (Point) Div

func (p Point) Div(k float64) Point

Div returns the vector p/k.

func (Point) Dot

func (p Point) Dot(q Point) float64

func (Point) Eq

func (p Point) Eq(q Point) bool

Eq returns whether p and q are equal.

func (Point) In

func (p Point) In(r Rectangle) bool

In returns whether p is in r.

func (Point) Len

func (p Point) Len() float64

func (Point) Mod

func (p Point) Mod(r Rectangle) Point

Mod returns the point q in r such that p.X-q.X is a multiple of r's width and p.Y-q.Y is a multiple of r's height.

func (Point) Mul

func (p Point) Mul(k float64) Point

Mul returns the vector p*k.

func (Point) String

func (p Point) String() string

String returns a string representation of p like "(3,4)".

func (Point) Sub

func (p Point) Sub(q Point) Point

Sub returns the vector p-q.

func (Point) XY

func (p Point) XY() (float64, float64)

type Rectangle

type Rectangle struct {
	Min, Max Point
}

A Rectangle contains the points with Min.X <= X < Max.X, Min.Y <= Y < Max.Y. It is well-formed if Min.X <= Max.X and likewise for Y. Points are always well-formed. A rectangle's methods always return well-formed outputs for well-formed inputs.

var ZR Rectangle

ZR is the zero Rectangle.

func Rect

func Rect(v View) Rectangle

func RectInParent

func RectInParent(v View) Rectangle

func (Rectangle) Add

func (r Rectangle) Add(p Point) Rectangle

Add returns the rectangle r translated by p.

func (Rectangle) Canon

func (r Rectangle) Canon() Rectangle

Canon returns the canonical version of r. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.

func (Rectangle) Center

func (r Rectangle) Center() Point

func (Rectangle) Dx

func (r Rectangle) Dx() float64

Dx returns r's width.

func (Rectangle) Dy

func (r Rectangle) Dy() float64

Dy returns r's height.

func (Rectangle) Empty

func (r Rectangle) Empty() bool

Empty returns whether the rectangle contains no points.

func (Rectangle) Eq

func (r Rectangle) Eq(s Rectangle) bool

Eq returns whether r and s are equal.

func (Rectangle) In

func (r Rectangle) In(s Rectangle) bool

In returns whether every point in r is in s.

func (Rectangle) Inset

func (r Rectangle) Inset(n float64) Rectangle

Inset returns the rectangle r inset by n, which may be negative. If either of r's dimensions is less than 2*n then an empty rectangle near the center of r will be returned.

func (Rectangle) Intersect

func (r Rectangle) Intersect(s Rectangle) Rectangle

Intersect returns the largest rectangle contained by both r and s. If the two rectangles do not overlap then the zero rectangle will be returned.

func (Rectangle) Overlaps

func (r Rectangle) Overlaps(s Rectangle) bool

Overlaps returns whether r and s have a non-empty intersection.

func (Rectangle) Size

func (r Rectangle) Size() Point

Size returns r's width and height.

func (Rectangle) String

func (r Rectangle) String() string

String returns a string representation of r like "(3,4)-(6,5)".

func (Rectangle) Sub

func (r Rectangle) Sub(p Point) Rectangle

Sub returns the rectangle r translated by -p.

func (Rectangle) Union

func (r Rectangle) Union(s Rectangle) Rectangle

Union returns the smallest rectangle that contains both r and s.

type ScrollEvent

type ScrollEvent struct {
	Pos, Delta Point
}

type Scroller

type Scroller interface {
	Scroll(ScrollEvent)
}

type ScrollerView

type ScrollerView interface {
	Scroller
	View
}

type Text

type Text struct {
	*ViewBase

	Validate            func(*string) bool
	Accept, TextChanged func(string)
	Reject              func()
	// contains filtered or unexported fields
}

func NewText

func NewText(text string) *Text

func (*Text) KeyPress

func (t *Text) KeyPress(event KeyEvent)

func (*Text) LostKeyFocus

func (t *Text) LostKeyFocus()

func (*Text) Paint

func (t *Text) Paint()

func (*Text) SetBackgroundColor

func (t *Text) SetBackgroundColor(c Color)

func (*Text) SetFrameColor

func (t *Text) SetFrameColor(c Color)

func (*Text) SetFrameSize

func (t *Text) SetFrameSize(size float64)

func (*Text) SetText

func (t *Text) SetText(text string)

func (*Text) SetTextColor

func (t *Text) SetTextColor(c Color)

func (Text) Text

func (t Text) Text() string

func (*Text) TookKeyFocus

func (t *Text) TookKeyFocus()

type View

type View interface {
	Add(View)
	Remove(View)
	Close()

	Move(Point)
	SetRect(Rectangle)

	TookKeyFocus()
	LostKeyFocus()

	KeyPress(KeyEvent)
	KeyRelease(KeyEvent)

	Paint()
	// contains filtered or unexported methods
}

func Child

func Child(v View, i int) View

func KeyFocus

func KeyFocus(v View) View

func Parent

func Parent(v View) View

func ViewAt

func ViewAt(v View, p Point) View

type ViewBase

type ViewBase struct {
	Self View
	// contains filtered or unexported fields
}

func NewView

func NewView(self View) *ViewBase

func (*ViewBase) Add

func (v *ViewBase) Add(u View)

func (*ViewBase) Close

func (v *ViewBase) Close()

func (*ViewBase) KeyPress

func (v *ViewBase) KeyPress(event KeyEvent)

func (*ViewBase) KeyRelease

func (v *ViewBase) KeyRelease(event KeyEvent)

func (*ViewBase) LostKeyFocus

func (v *ViewBase) LostKeyFocus()

func (*ViewBase) Move

func (v *ViewBase) Move(p Point)

func (ViewBase) Paint

func (v ViewBase) Paint()

func (*ViewBase) Remove

func (v *ViewBase) Remove(u View)

func (*ViewBase) SetRect

func (v *ViewBase) SetRect(r Rectangle)

func (*ViewBase) TookKeyFocus

func (v *ViewBase) TookKeyFocus()

type Window

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

func (*Window) Close

func (w *Window) Close()

func (*Window) Do

func (w *Window) Do(f func())

func (*Window) KeyPress

func (w *Window) KeyPress(k KeyEvent)

func (*Window) SetCentralView

func (w *Window) SetCentralView(v View)

func (*Window) SetTitle

func (w *Window) SetTitle(s string)

Jump to

Keyboard shortcuts

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