window

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package window abstracts a platform-specific window. Depending on the build tags it can be a GLFW desktop window or a browser WebGlCanvas.

Index

Constants

View Source
const (
	KeyUnknown = Key(iota)
	KeySpace
	KeyApostrophe
	KeyComma
	KeyMinus
	KeyPeriod
	KeySlash
	Key0
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
	KeySemicolon
	KeyEqual
	KeyA
	KeyB
	KeyC
	KeyD
	KeyE
	KeyF
	KeyG
	KeyH
	KeyI
	KeyJ
	KeyK
	KeyL
	KeyM
	KeyN
	KeyO
	KeyP
	KeyQ
	KeyR
	KeyS
	KeyT
	KeyU
	KeyV
	KeyW
	KeyX
	KeyY
	KeyZ
	KeyLeftBracket
	KeyBackslash
	KeyRightBracket
	KeyGraveAccent
	KeyWorld1
	KeyWorld2
	KeyEscape
	KeyEnter
	KeyTab
	KeyBackspace
	KeyInsert
	KeyDelete
	KeyRight
	KeyLeft
	KeyDown
	KeyUp
	KeyPageUp
	KeyPageDown
	KeyHome
	KeyEnd
	KeyCapsLock
	KeyScrollLock
	KeyNumLock
	KeyPrintScreen
	KeyPause
	KeyF1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyF13
	KeyF14
	KeyF15
	KeyF16
	KeyF17
	KeyF18
	KeyF19
	KeyF20
	KeyF21
	KeyF22
	KeyF23
	KeyF24
	KeyF25
	KeyKP0
	KeyKP1
	KeyKP2
	KeyKP3
	KeyKP4
	KeyKP5
	KeyKP6
	KeyKP7
	KeyKP8
	KeyKP9
	KeyKPDecimal
	KeyKPDivide
	KeyKPMultiply
	KeyKPSubtract
	KeyKPAdd
	KeyKPEnter
	KeyKPEqual
	KeyLeftShift
	KeyLeftControl
	KeyLeftAlt
	KeyLeftSuper // Meta in Javascript
	KeyRightShift
	KeyRightControl
	KeyRightAlt
	KeyRightSuper
	KeyMenu
	KeyLast
)

Keycodes

View Source
const (
	ModShift = ModifierKey(1 << iota) // Bitmask
	ModControl
	ModAlt
	ModSuper // Meta in Javascript
)

Modifier keys

View Source
const (
	//MouseButton1      = MouseButton(0)
	//MouseButton2      = MouseButton(0)
	//MouseButton3      = MouseButton(0)
	//MouseButton4      = MouseButton(0)
	//MouseButton5      = MouseButton(0)
	//MouseButton6      = MouseButton(0)
	//MouseButton7      = MouseButton(0)
	//MouseButton8      = MouseButton(0)
	//MouseButtonLast   = MouseButton(0)
	MouseButtonLeft   = MouseButton(0)
	MouseButtonRight  = MouseButton(2)
	MouseButtonMiddle = MouseButton(1)
)

Mouse buttons

View Source
const (
	CursorInputMode             = InputMode(iota) // See Cursor mode values
	StickyKeysInputMode                           // Value can be either 1 or 0
	StickyMouseButtonsInputMode                   // Value can be either 1 or 0
)

Input modes

View Source
const (
	CursorNormal = CursorMode(iota)
	CursorHidden
	CursorDisabled
)

Cursor mode values

View Source
const (
	ArrowCursor = Cursor(iota)
	IBeamCursor
	CrosshairCursor
	HandCursor
	HResizeCursor
	VResizeCursor
	DiagResize1Cursor
	DiagResize2Cursor
	CursorLast = DiagResize2Cursor
)

Standard cursors for G3N.

View Source
const (
	OnWindowPos  = "w.OnWindowPos"  //    x    |         |
	OnWindowSize = "w.OnWindowSize" //    x    |         |
	OnKeyUp      = "w.OnKeyUp"      //    x    |    x    |
	OnKeyDown    = "w.OnKeyDown"    //    x    |    x    |
	OnKeyRepeat  = "w.OnKeyRepeat"  //    x    |         |
	OnChar       = "w.OnChar"       //    x    |    x    |
	OnCursor     = "w.OnCursor"     //    x    |    x    |
	OnMouseUp    = "w.OnMouseUp"    //    x    |    x    |
	OnMouseDown  = "w.OnMouseDown"  //    x    |    x    |
	OnScroll     = "w.OnScroll"     //    x    |    x    |
)

Window event names. See availability per platform below ("x" indicates available).

Variables

This section is empty.

Functions

func Init added in v1.1.0

func Init(canvasId string) error

Init initializes the WebGlCanvas singleton. If canvasId is provided, the pre-existing WebGlCanvas with that id is used. If canvasId is the empty string then it creates a new WebGL canvas.

Types

type CharEvent

type CharEvent struct {
	Char rune
	Mods ModifierKey
}

CharEvent describes a window char event

type Cursor added in v1.1.0

type Cursor int

Cursor corresponds to a g3n standard or user-created cursor icon.

type CursorEvent

type CursorEvent struct {
	Xpos float32
	Ypos float32
	Mods ModifierKey
}

CursorEvent describes a cursor position changed event

type CursorMode

type CursorMode int

InputMode corresponds to an input mode.

type IWindow

type IWindow interface {
	core.IDispatcher
	Gls() *gls.GLS
	GetFramebufferSize() (width int, height int)
	GetSize() (width int, height int)
	GetScale() (x float64, y float64)
	CreateCursor(imgFile string, xhot, yhot int) (Cursor, error)
	SetCursor(cursor Cursor)
	DisposeAllCustomCursors()
	Destroy()
}

IWindow is the interface for all windows

func Get added in v1.1.0

func Get() IWindow

Get returns the IWindow singleton.

type InputMode

type InputMode int

InputMode corresponds to an input mode.

type Key

type Key int

Key corresponds to a keyboard key.

type KeyEvent

type KeyEvent struct {
	Key  Key
	Mods ModifierKey
}

KeyEvent describes a window key event

type KeyState added in v1.1.0

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

KeyState keeps track of the state of all keys.

func NewKeyState added in v1.1.0

func NewKeyState(win core.IDispatcher) *KeyState

NewKeyState returns a new KeyState object.

func (*KeyState) Dispose added in v1.1.0

func (ks *KeyState) Dispose()

Dispose unsubscribes from the window events.

func (*KeyState) Pressed added in v1.1.0

func (ks *KeyState) Pressed(k Key) bool

Pressed returns whether the specified key is currently pressed.

type ModifierKey

type ModifierKey int

ModifierKey corresponds to a set of modifier keys (bitmask).

type MouseButton

type MouseButton int

MouseButton corresponds to a mouse button.

type MouseEvent

type MouseEvent struct {
	Xpos   float32
	Ypos   float32
	Button MouseButton
	Mods   ModifierKey
}

MouseEvent describes a mouse event over the window

type PosEvent

type PosEvent struct {
	Xpos int
	Ypos int
}

PosEvent describes a windows position changed event

type ScrollEvent

type ScrollEvent struct {
	Xoffset float32
	Yoffset float32
	Mods    ModifierKey
}

ScrollEvent describes a scroll event

type SizeEvent

type SizeEvent struct {
	Width  int
	Height int
}

SizeEvent describers a window size changed event

type WebGlCanvas added in v1.1.0

type WebGlCanvas struct {
	core.Dispatcher // Embedded event dispatcher
	// contains filtered or unexported fields
}

WebGlCanvas is a browser-based WebGL canvas.

func (*WebGlCanvas) Canvas added in v1.1.0

func (w *WebGlCanvas) Canvas() js.Value

Canvas returns the associated WebGL WebGlCanvas.

func (*WebGlCanvas) CreateCursor added in v1.1.0

func (w *WebGlCanvas) CreateCursor(imgFile string, xhot, yhot int) (Cursor, error)

CreateCursor creates a new custom cursor and returns an int handle.

func (*WebGlCanvas) Destroy added in v1.1.0

func (w *WebGlCanvas) Destroy()

Destroy destroys the WebGL canvas and removes all event listeners.

func (*WebGlCanvas) DisposeAllCustomCursors added in v1.1.0

func (w *WebGlCanvas) DisposeAllCustomCursors()

DisposeAllCursors deletes all existing custom cursors.

func (*WebGlCanvas) FullScreen added in v1.1.0

func (w *WebGlCanvas) FullScreen() bool

FullScreen returns whether this canvas is fullscreen

func (*WebGlCanvas) GetFramebufferSize added in v1.1.0

func (w *WebGlCanvas) GetFramebufferSize() (width int, height int)

GetFramebufferSize returns the framebuffer size.

func (*WebGlCanvas) GetScale added in v1.1.0

func (w *WebGlCanvas) GetScale() (x float64, y float64)

Scale returns this window's DPI scale factor (FramebufferSize / Size)

func (*WebGlCanvas) GetSize added in v1.1.0

func (w *WebGlCanvas) GetSize() (width int, height int)

GetSize returns this window's size in screen coordinates.

func (*WebGlCanvas) Gls added in v1.1.0

func (w *WebGlCanvas) Gls() *gls.GLS

Gls returns the associated OpenGL state

func (*WebGlCanvas) SetCursor added in v1.1.0

func (w *WebGlCanvas) SetCursor(cursor Cursor)

SetCursor sets the window's cursor to a standard one

func (*WebGlCanvas) SetFullScreen added in v1.1.0

func (w *WebGlCanvas) SetFullScreen(full bool)

SetFullScreen sets this window full screen state for the primary monitor

func (*WebGlCanvas) SetSize added in v1.1.0

func (w *WebGlCanvas) SetSize(width int, height int)

SetSize sets the size, in screen coordinates, of the canvas.

Jump to

Keyboard shortcuts

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