wde

package module
v0.0.0-...-fbbb5eb Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

README

go.wde GoDoc Go Report Card codebeat badge

(W)indows, (d)rawing and (e)vents for Go.

Works on linux, windows, and os x with no setup beyond "go get".

Forked from skelterjohn/go.wde

Documentation

Index

Constants

View Source
const (
	KeyFunction     = "function"
	KeyLeftSuper    = "left_super"
	KeyRightSuper   = "right_super"
	KeyLeftAlt      = "left_alt"
	KeyRightAlt     = "right_alt"
	KeyLeftControl  = "left_control"
	KeyRightControl = "right_control"
	KeyLeftShift    = "left_shift"
	KeyRightShift   = "right_shift"
	KeyUpArrow      = "up_arrow"
	KeyDownArrow    = "down_arrow"
	KeyLeftArrow    = "left_arrow"
	KeyRightArrow   = "right_arrow"
	KeyInsert       = "insert"
	KeyTab          = "tab"
	KeySpace        = "space"
	KeyA            = "a"
	KeyB            = "b"
	KeyC            = "c"
	KeyD            = "d"
	KeyE            = "e"
	KeyF            = "f"
	KeyG            = "g"
	KeyH            = "h"
	KeyI            = "i"
	KeyJ            = "j"
	KeyK            = "k"
	KeyL            = "l"
	KeyM            = "m"
	KeyN            = "n"
	KeyO            = "o"
	KeyP            = "p"
	KeyQ            = "q"
	KeyR            = "r"
	KeyS            = "s"
	KeyT            = "t"
	KeyU            = "u"
	KeyV            = "v"
	KeyW            = "w"
	KeyX            = "x"
	KeyY            = "y"
	KeyZ            = "z"
	Key1            = "1"
	Key2            = "2"
	Key3            = "3"
	Key4            = "4"
	Key5            = "5"
	Key6            = "6"
	Key7            = "7"
	Key8            = "8"
	Key9            = "9"
	Key0            = "0"
	KeyPadEnd       = "kp_end"
	KeyPadDown      = "kp_down"
	KeyPadNext      = "kp_next"
	KeyPadLeft      = "kp_left"
	KeyPadBegin     = "kp_begin"
	KeyPadRight     = "kp_right"
	KeyPadHome      = "kp_home"
	KeyPadUp        = "kp_up"
	KeyPadPrior     = "kp_prior"
	KeyPadInsert    = "kp_insert"
	KeyPadSlash     = "kp_slash"
	KeyPadStar      = "kp_star"
	KeyPadMinus     = "kp_minus"
	KeyPadPlus      = "kp_plus"
	KeyPadDot       = "kp_dot"
	KeyPadEqual     = "kp_equal"
	KeyPadEnter     = "kp_enter"
	KeyBackTick     = "`"
	KeyF1           = "f1"
	KeyF2           = "f2"
	KeyF3           = "f3"
	KeyF4           = "f4"
	KeyF5           = "f5"
	KeyF6           = "f6"
	KeyF7           = "f7"
	KeyF8           = "f8"
	KeyF9           = "f9"
	KeyF10          = "f10"
	KeyF11          = "f11"
	KeyF12          = "f12"
	KeyF13          = "f13"
	KeyF14          = "f14"
	KeyF15          = "f15"
	KeyF16          = "f16"
	KeyMinus        = "-"
	KeyEqual        = "="
	KeyLeftBracket  = "["
	KeyRightBracket = "]"
	KeyBackslash    = `\`
	KeySemicolon    = ";"
	KeyQuote        = "'"
	KeyComma        = ","
	KeyPeriod       = "."
	KeySlash        = "/"
	KeyReturn       = "return"
	KeyEscape       = "escape"
	KeyNumlock      = "numlock"
	KeyDelete       = "delete"
	KeyBackspace    = "backspace"
	KeyHome         = "home"
	KeyEnd          = "end"
	KeyPrior        = "prior"
	KeyNext         = "next"
	KeyCapsLock     = "caps"
)

Variables

View Source
var BackendNewWindow = func(width, height int) (Window, error) {
	panic("no wde backend imported")
}

BackendNewWindow throws a panic if no backend were imported. It's overwritten by backends.

View Source
var BackendRun = func() {
	panic("no wde backend imported")
}

BackendRun throws a panic if no backend were imported. It's overwritten by backends.

View Source
var BackendStop = func() {
	panic("no wde backend imported")
}

BackendStop throws a panic if no backend were imported. It's overwritten by backends.

Functions

func ConstructChord

func ConstructChord(keys map[string]bool) (chord string)

func Run

func Run()

Run needs to be called in the main thread to make your code as cross-platform as possible.

Some wde backends (cocoa) require that this function be called in the main thread. To make your code as cross-platform as possible, it is recommended that your main function look like the the code below.

func main() {
	go theRestOfYourProgram()
	wde.Run()
}

wde.Run() will return when wde.Stop() is called.

For this to work, you must import one of the go.wde backends. For instance,

import _ "github.com/kirillDanshin/go-wde/xgb"

or

import _ "github.com/kirillDanshin/go-wde/win"

or

import _ "github.com/kirillDanshin/go-wde/cocoa"

will register a backend with go.wde, allowing you to call wde.Run(), wde.Stop() and wde.NewWindow() without referring to the backend explicitly.

If you pupt the registration import in a separate file filtered for the correct platform, your project will work on all three major platforms without configuration.

That is, if you import go.wde/xgb in a file named "wde_linux.go", go.wde/win in a file named "wde_windows.go" and go.wde/cocoa in a file named "wde_darwin.go", the go tool will import the correct one.

func Stop

func Stop()

Stop trigger. Call this when you want wde.Run() to return. Usually to allow your program to exit gracefully.

Types

type Button

type Button int
const (
	LeftButton Button = 1 << iota
	MiddleButton
	RightButton
	WheelUpButton
	WheelDownButton
)

type ChordSorter

type ChordSorter []string

func (ChordSorter) Len

func (c ChordSorter) Len() int

func (ChordSorter) Less

func (c ChordSorter) Less(i, j int) (less bool)

func (ChordSorter) Swap

func (c ChordSorter) Swap(i, j int)

type CloseEvent

type CloseEvent struct{}

CloseEvent is for when the window is closed.

type Cursor

type Cursor int
const (
	NoneCursor Cursor = iota
	NormalCursor
	ResizeNCursor
	ResizeECursor
	ResizeSCursor
	ResizeWCursor
	ResizeEWCursor
	ResizeNSCursor
	ResizeNECursor
	ResizeSECursor
	ResizeSWCursor
	ResizeNWCursor
	CrosshairCursor
	IBeamCursor
	GrabHoverCursor
	GrabActiveCursor
	NotAllowedCursor
)

type CursorCtl

type CursorCtl interface {
	Set(id Cursor)
	Hide()
	Show()
}

type Event

type Event int

type Image

type Image interface {
	draw.Image
	// CopyRGBA() copies the source image to this image, translating
	// the source image to the provided bounds.
	CopyRGBA(src *image.RGBA, bounds image.Rectangle)
}

Image interface describes API for backend's Image struct

type KeyDownEvent

type KeyDownEvent KeyEvent

KeyDownEvent is for when a key is pressed.

type KeyEvent

type KeyEvent struct {
	Key string
}

KeyEvent is used for data common to all key events, and should not appear as an event received by the caller program.

type KeyTypedEvent

type KeyTypedEvent struct {
	KeyEvent
	/*
		The glyph is the string corresponding to what the user wants to have typed in
		whatever data entry is active.
	*/
	Glyph string
	/*
		The "+" joined set of keys (not glyphs) participating in the chord completed
		by this key event. The keys will be in a consistent order, no matter what
		order they are pressed in.
	*/
	Chord string
}

KeyTypedEvent is for when a key is typed.

type KeyUpEvent

type KeyUpEvent KeyEvent

KeyUpEvent is for when a key is unpressed.

type MagnifyEvent

type MagnifyEvent struct {
	Event
	Where         image.Point
	Magnification float64 // the multiplicative scale factor
}

MagnifyEvent is used to represent a magnification gesture.

type MouseButtonEvent

type MouseButtonEvent struct {
	MouseEvent
	Which Button
}

MouseButtonEvent is used for data common to all mouse button events, and should not appear as an event received by the caller program.

type MouseDownEvent

type MouseDownEvent MouseButtonEvent

MouseDownEvent is for when the mouse is clicked within the window.

type MouseDraggedEvent

type MouseDraggedEvent struct {
	MouseMovedEvent
	Which Button
}

MouseDraggedEvent is for when the mouse is moved while a button is pressed.

type MouseEnteredEvent

type MouseEnteredEvent MouseMovedEvent

MouseEnteredEvent is for when the mouse enters a window.

type MouseEvent

type MouseEvent struct {
	Event
	Where image.Point
}

MouseEvent is used for data common to all mouse events, and should not appear as an event received by the caller program.

type MouseExitedEvent

type MouseExitedEvent MouseMovedEvent

MouseExitedEvent is for when the mouse exits a window.

type MouseMovedEvent

type MouseMovedEvent struct {
	MouseEvent
	From image.Point
}

MouseMovedEvent is for when the mouse moves within the window.

type MouseUpEvent

type MouseUpEvent MouseButtonEvent

MouseUpEvent is for when the mouse is unclicked within the window.

type ResizeEvent

type ResizeEvent struct {
	Width, Height int
}

ResizeEvent is for when the window changes size.

type RotateEvent

type RotateEvent struct {
	Event
	Where    image.Point
	Rotation float64 // measured in degrees; positive == clockwise
}

RotateEvent is used to represent a rotation gesture.

type ScrollEvent

type ScrollEvent struct {
	Event
	Where image.Point
	Delta image.Point
}

Scroll Event is used to represent a scrolling gesture.

type Window

type Window interface {
	SetTitle(title string)
	SetSize(width, height int)
	Size() (width, height int)
	LockSize(lock bool)
	Show()
	Screen() (im Image)
	FlushImage(bounds ...image.Rectangle)
	EventChan() (events <-chan interface{})
	Close() (err error)
	SetCursor(cursor Cursor)
}

Window interface describes API for backend's Window struct

func NewWindow

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

NewWindow creates a new window with the specified width and height.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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