Documentation ¶
Index ¶
- Constants
- Variables
- func Register(d Driver)
- type Actor
- type Application
- func (app *Application) Activate(actor Actor)
- func (app *Application) Activated(actor Actor) bool
- func (app *Application) AddActor(actor Actor, rect Rect)
- func (app *Application) Close()
- func (app *Application) Done() <-chan struct{}
- func (app *Application) Event() Eventer
- func (app *Application) NewMenu(label string) *Menu
- func (app *Application) NewWindow(rect Rect, color Color) *Window
- func (app *Application) OnEvent(event Eventer, handler func())
- func (app *Application) RemoveActor(actor Actor)
- func (app *Application) Size(rect Rect)
- func (app *Application) Start(f func())
- func (app *Application) Title(title string)
- func (app *Application) Wait()
- type ButtonEvent
- type Color
- type Driver
- type Eventer
- type Font
- type Fonter
- type GeneralEvent
- type Image
- type Imager
- type KeyboardEvent
- type Menu
- type MenuEvent
- type Menuer
- type MotionEvent
- type Painter
- type Point
- type Rect
- type Size
- type Window
- func (w *Window) Clear()
- func (w *Window) Drop()
- func (w *Window) Fill(rect Rect, color Color)
- func (w *Window) Image(from Point, img *Image)
- func (w *Window) Line(from Point, to Point, color Color)
- func (w *Window) Raise()
- func (w *Window) Show()
- func (w *Window) Size(rect Rect)
- func (w *Window) Text(text string, font *Font, from Point, color Color)
Constants ¶
const ( GeneralEventType = 10 KeyboardEventType = 20 ButtonEventType = 30 MotionEventType = 40 MenuEventType = 50 )
Event types
const ( ButtonActionPress = 4 ButtonActionDouble = 5 ButtonActionTriple = 6 ButtonActionRelease = 7 )
Button action type
const ( ButtonLeft = 1 ButtonMiddle = 2 ButtonRight = 3 )
Button number
Variables ¶
var ( UnknownEvent = GeneralEvent{Event: 0} DestroyEvent = GeneralEvent{Event: 1} DoneEvent = GeneralEvent{Event: 2} ActivatedEvent = GeneralEvent{Event: 3} DeactivatedEvent = GeneralEvent{Event: 4} )
Signal events
var ( KeyLeft = KeyboardEvent{Name: "Left"} KeyRight = KeyboardEvent{Name: "Right"} KeyUp = KeyboardEvent{Name: "Up"} KeyDown = KeyboardEvent{Name: "Down"} KeyEnter = KeyboardEvent{Rune: 13, Name: "Return"} KeyBackSpace = KeyboardEvent{Rune: 8, Name: "BackSpace"} )
Keyboard events
var ( KeySave = KeyboardEvent{Rune: 115, Name: "s", Control: true} KeyExit = KeyboardEvent{Rune: 119, Name: "w", Control: true} )
Platform specified keyboard events
Functions ¶
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application represents application top level window
func NewApplication ¶
func NewApplication(rect Rect, title string) *Application
NewApplication creates main application window
func (*Application) Activate ¶
func (app *Application) Activate(actor Actor)
Activate sets the active event receiver under mutex protection
func (*Application) Activated ¶
func (app *Application) Activated(actor Actor) bool
Activated returns true when the actor is an active recipient
func (*Application) AddActor ¶
func (app *Application) AddActor(actor Actor, rect Rect)
AddActor adds actor for rect
func (*Application) Close ¶
func (app *Application) Close()
Close makes invocation of the main loop return
func (*Application) Done ¶
func (app *Application) Done() <-chan struct{}
Done returns a channel that's closed when the application is stopped
func (*Application) Event ¶
func (app *Application) Event() Eventer
Event returns next application event
func (*Application) NewMenu ¶ added in v0.1.7
func (app *Application) NewMenu(label string) *Menu
NewMenu returns a new top-level menu node
func (*Application) NewWindow ¶
func (app *Application) NewWindow(rect Rect, color Color) *Window
NewWindow creates new inner window with a specified size and background color
func (*Application) OnEvent ¶
func (app *Application) OnEvent(event Eventer, handler func())
OnEvent connects function call back to an event
func (*Application) RemoveActor ¶
func (app *Application) RemoveActor(actor Actor)
RemoveActor removes actor from actor list
func (*Application) Size ¶
func (app *Application) Size(rect Rect)
Size sets application window size
func (*Application) Start ¶
func (app *Application) Start(f func())
Start starts the specified func but does not wait for it to complete
func (*Application) Title ¶
func (app *Application) Title(title string)
Title sets application window title
func (*Application) Wait ¶
func (app *Application) Wait()
Wait waits for main application loop to complete
type ButtonEvent ¶
ButtonEvent is mouse button event
type Color ¶
type Color struct {
R, G, B int
}
Color represents a 24-bit color, having 8 bits for each of red, green, blue.
type Driver ¶
type Driver interface { Init() Done() Title(title string) Size(rect Rect) NewWindow(rect Rect, color Color) Painter NewFont(font *Font) (Fonter, error) NewImage(img *Image) (Imager, error) NewMenu(label string) Menuer Chan() <-chan Eventer }
Driver is the interface to a application level functions
type Eventer ¶
type Eventer interface {
Type() int
}
Eventer is the interface that groups GUI events
type Font ¶
type Font struct { Fonter Fonter Height int Baseline int Ascent int Descent int Attr map[string]string }
Font represents a font selection
type GeneralEvent ¶
type GeneralEvent struct {
Event int
}
GeneralEvent is a general purpose notification
type Image ¶
Image represents a draw-ready image
type KeyboardEvent ¶
KeyboardEvent is a keyboard event
func (KeyboardEvent) IsGraphic ¶
func (e KeyboardEvent) IsGraphic() bool
IsGraphic tests printable rune
type Menu ¶ added in v0.1.7
type Menu struct {
// contains filtered or unexported fields
}
Menu represents any menu node
func (*Menu) NewItemFunc ¶ added in v0.1.7
NewItemFunc adds a item with callback func to menu node
type MenuEvent ¶ added in v0.1.7
type MenuEvent struct {
Action string
}
MenuEvent is menu action event
func NewMenuEvent ¶ added in v0.1.7
NewMenuEvent returns a menu action event
type MotionEvent ¶
MotionEvent is mouse motion event
type Painter ¶
type Painter interface { Drop() Size(rect Rect) Raise() Clear() Show() Fill(rect Rect, color Color) Line(from Point, to Point, color Color) Image(from Point, img *Image) Text(text string, font *Font, from Point, color Color) }
Painter is the interface to a window functions
type Point ¶
type Point struct {
X, Y int
}
A Point is an X, Y coordinate pair. The axes increase right and down.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window represents inner window
func (*Window) Drop ¶
func (w *Window) Drop()
Drop deletes window Note that a dropped window can no longer be used