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
- func Init(canvasId string) error
- type CharEvent
- type Cursor
- type CursorEvent
- type CursorMode
- type IWindow
- type InputMode
- type Key
- type KeyEvent
- type KeyState
- type ModifierKey
- type MouseButton
- type MouseEvent
- type PosEvent
- type ScrollEvent
- type SizeEvent
- type WebGlCanvas
- func (w *WebGlCanvas) Canvas() js.Value
- func (w *WebGlCanvas) CreateCursor(imgFile string, xhot, yhot int) (Cursor, error)
- func (w *WebGlCanvas) Destroy()
- func (w *WebGlCanvas) DisposeAllCustomCursors()
- func (w *WebGlCanvas) FullScreen() bool
- func (w *WebGlCanvas) GetFramebufferSize() (width int, height int)
- func (w *WebGlCanvas) GetScale() (x float64, y float64)
- func (w *WebGlCanvas) GetSize() (width int, height int)
- func (w *WebGlCanvas) Gls() *gls.GLS
- func (w *WebGlCanvas) SetCursor(cursor Cursor)
- func (w *WebGlCanvas) SetFullScreen(full bool)
- func (w *WebGlCanvas) SetSize(width int, height int)
Constants ¶
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
const ( ModShift = ModifierKey(1 << iota) // Bitmask ModControl ModAlt ModSuper // Meta in Javascript )
Modifier keys
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
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
const ( CursorNormal = CursorMode(iota) CursorHidden CursorDisabled )
Cursor mode values
const ( ArrowCursor = Cursor(iota) IBeamCursor CrosshairCursor HandCursor HResizeCursor VResizeCursor DiagResize1Cursor DiagResize2Cursor CursorLast = DiagResize2Cursor )
Standard cursors for G3N.
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 ¶
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 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
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.
type ModifierKey ¶
type ModifierKey int
ModifierKey corresponds to a set of modifier keys (bitmask).
type MouseEvent ¶
type MouseEvent struct { Xpos float32 Ypos float32 Button MouseButton Mods ModifierKey }
MouseEvent describes a mouse event over the window
type ScrollEvent ¶
type ScrollEvent struct { Xoffset float32 Yoffset float32 Mods ModifierKey }
ScrollEvent describes a scroll 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.