gyro

package module
v0.0.0-...-485fd5b Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2018 License: MIT Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterBackend

func RegisterBackend(backend Backend)

func Run

func Run(f AppInitFunc) error

Run is a shorthand for NewApp & Run.

Types

type App

type App interface {
	Run() error

	Close() error
	CloseChan() <-chan struct{}
	IsClosed() bool

	Sync(f func())
	Lock()
	Unlock()
}

func CApp

func CApp() App

CApp returns the current application. There is only one application at a time.

func NewApp

func NewApp(f AppInitFunc) (App, error)

type AppInitFunc

type AppInitFunc func() error

type Backend

type Backend interface {
	App() App
	NewApp(f AppInitFunc) (App, error)
	NewWindow(title string, width, height int) (Window, error)
	NewRect() Rect
	NewText() Text
}

Panic on methods without error return value.

type Color

type Color struct {
	R uint8 // the red component in the range 0-255
	G uint8 // the green component in the range 0-255
	B uint8 // the blue component in the range 0-255
	A uint8 // the alpha component in the range 0-255
}

func RGBA

func RGBA(r, g, b, a uint8) Color

type MouseButton

type MouseButton int
const (
	MouseButtonLeft MouseButton = iota
	MouseButtonMiddle
	MouseButtonRight
)

type MouseState

type MouseState int
const (
	MouseStatePressed MouseState = iota
	MouseStateReleased
)

type Rect

type Rect interface {
	AddWidget(w Widget)

	X() int
	SetX(x int)

	Y() int
	SetY(y int)

	Width() int
	SetWidth(w int)

	Height() int
	SetHeight(h int)

	Right() int
	Bottom() int

	Radius() int
	SetRadius(r int)

	Border() int
	SetBorder(b int)

	Color() Color
	SetColor(c Color)

	BorderColor() Color
	SetBorderColor(c Color)
}

func NewRect

func NewRect() Rect

type Text

type Text interface {
	X() int
	SetX(x int)

	Y() int
	SetY(y int)

	Width() int
	Height() int

	Right() int
	Bottom() int

	Color() Color
	SetColor(c Color)

	Text() string
	SetText(t string)

	FontSize() int
	SetFontSize(s int)

	WrapLen() int
	SetWrapLen(l int)

	MouseHovered() bool

	OnMouseMove(f func(x, y int))
	OnMouseEnter(f func())
	OnMouseLeave(f func())
	OnMouseButton(f func(b MouseButton, s MouseState, x, y int))
}

func NewText

func NewText() Text

type Widget

type Widget interface {
	X() int
	SetX(x int)

	Y() int
	SetY(y int)

	Width() int
	SetWidth(w int)

	Height() int
	SetHeight(h int)

	Right() int
	Bottom() int
}

type Window

type Window interface {
	Close() error
	CloseChan() <-chan struct{}
	IsClosed() bool

	AddWidget(w Widget)
}

func NewWindow

func NewWindow(title string, width, height int) (Window, error)

NewWindow create a window.

Jump to

Keyboard shortcuts

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