Documentation
¶
Overview ¶
Package chippy implements cross platform window management, and window rendering access.
Thread Safety ¶
Chippy is thread safe, and can be fully used from within multiple goroutines without any worry about operating system threads, or locks, etc.
It should be explicitly noted that while Chippy and it's API's are thread safe, anything to do with OpenGL needs special care regarding thread safety.
OpenGL Support ¶
Creating both new and old style OpenGL contexts is supported (this allows creating an OpenGL context of any version). Many platform specific OpenGL functions are abstracted away for you (such as WGL, GLX, etc extensions). Shared OpenGL contexts, multisampling, vertical sync toggling, etc are all supported.
Chippy works with all OpenGL wrappers, it does not provide any OpenGL wrappers itself (although azul3d.org/v1/native/gl has some good ones).
Although we handle the platform-specific parts of OpenGL for you, no magic is performed: OpenGL still uses thread local storage so when working with OpenGL's API you'll need to utilize runtime.LockOSThread() properly.
Microsoft Windows FAQ ¶
What versions of Windows are supported?
Chippy requires Windows XP or higher. It might also work on Windows 2000 Professional/Server editions, but support for these version is not tested actively.
How do I add an application icon to my program?
You can place .syso files with the source of your main package, and the 6l/8l linker will link that file with your program. Take an look at the "app.rc" file inside the chippy/tests/data folder for more information. Also look at the single window test located in the chippy/tests/chippy_window_single directory for an example of this.
How do I stop the command prompt from appearing when my application starts?
You can stop the terminal from appearing by using the 8l/6l linker flag "-H windowsgui" on your 'go install' command, like so: go install -ldflags "-H windowsgui" path/to/pkg
Linux-X11 FAQ ¶
What X extensions are needed?
GLX 1.4 (required, for OpenGL tasks, 1.4 is needed for multisampling) XRandR 1.2 (optional, used for screen-mode switching, etc) XInput 2.0 (required, for raw mouse input) XKB 1.0 (required, for keyboard input)
What about a pure Wayland client?
A pure Wayland implementation would be interesting and could be enabled using a build-tag until Wayland becomes more main-stream, but for now Wayland does have the ability to still run X applications so Chippy does still work on Wayland. A pure Wayland client is not a priority right now, but we are open to working with a contributor who would like to add this feature.
Index ¶
- Variables
- func DisplayName() string
- func Exit()
- func Init() error
- func IsInit() bool
- func MainLoop()
- func MainLoopFrames() chan func() bool
- func RefreshScreens()
- func SetDebugOutput(w io.Writer)
- func SetDisplayName(displayName string)
- type Blitable
- type CloseEvent
- type Cursor
- type CursorPositionEvent
- type CursorWithinEvent
- type DestroyedEvent
- type Event
- type FocusedEvent
- type GLConfig
- type GLContext
- type GLContextFlags
- type GLRenderable
- type MaximizedEvent
- type MinimizedEvent
- type NativeScreen
- type NativeScreenMode
- type NativeWindow
- func (w *NativeWindow) GLConfig() *GLConfig
- func (w *NativeWindow) GLConfigs() (configs []*GLConfig)
- func (w *NativeWindow) GLCreateContext(glVersionMajor, glVersionMinor uint, flags GLContextFlags, share GLContext) (GLContext, error)
- func (w *NativeWindow) GLDestroyContext(c GLContext)
- func (w *NativeWindow) GLMakeCurrent(c GLContext)
- func (w *NativeWindow) GLSetConfig(config *GLConfig)
- func (w *NativeWindow) GLSetVerticalSync(mode VSyncMode)
- func (w *NativeWindow) GLSwapBuffers()
- func (w *NativeWindow) GLVerticalSync() VSyncMode
- func (w *NativeWindow) PixelBlit(x, y uint, img *image.RGBA)
- func (w *NativeWindow) PixelClear(rect image.Rectangle)
- type PaintEvent
- type PositionEvent
- type ResizedEvent
- type Screen
- func (s *Screen) Equals(other *Screen) bool
- func (s *Screen) Mode() *ScreenMode
- func (s *Screen) Modes() []*ScreenMode
- func (s *Screen) Name() string
- func (s *Screen) OriginalMode() *ScreenMode
- func (s *Screen) PhysicalSize() (width float32, height float32)
- func (s *Screen) Restore()
- func (s *Screen) SetMode(newMode *ScreenMode) error
- func (s *Screen) String() string
- type ScreenChangedEvent
- type ScreenMode
- type VSyncMode
- type Window
- func (w *Window) AlwaysOnTop() bool
- func (w *Window) AspectRatio() float32
- func (w *Window) CloseEvents(ch chan Event)
- func (w *Window) Cursor() *Cursor
- func (w *Window) CursorGrabbed() bool
- func (w *Window) CursorPosition() (x, y int)
- func (w *Window) CursorWithin() bool
- func (w *Window) Decorated() bool
- func (w *Window) Destroy()
- func (w *Window) Destroyed() bool
- func (w *Window) Events() chan Event
- func (w *Window) EventsBuffer(bufferSize int) chan Event
- func (w *Window) Extents() (left, right, bottom, top int)
- func (w *Window) Focused() bool
- func (w *Window) FreeCursor(cursor *Cursor)
- func (w *Window) Fullscreen() bool
- func (w *Window) Icon() image.Image
- func (w *Window) Maximized() bool
- func (w *Window) MaximumSize() (width, height int)
- func (w *Window) Minimized() bool
- func (w *Window) MinimumSize() (width, height int)
- func (w *Window) Notify()
- func (w *Window) Open(screen *Screen) error
- func (w *Window) Opened() bool
- func (w *Window) OriginalScreen() *Screen
- func (w *Window) Position() (x, y int)
- func (w *Window) PrepareCursor(cursor *Cursor)
- func (w *Window) Screen() *Screen
- func (w *Window) SetAlwaysOnTop(alwaysOnTop bool)
- func (w *Window) SetAspectRatio(ratio float32)
- func (w *Window) SetCursor(cursor *Cursor)
- func (w *Window) SetCursorGrabbed(grabbed bool)
- func (w *Window) SetCursorPosition(x, y int)
- func (w *Window) SetDecorated(decorated bool)
- func (w *Window) SetFullscreen(fullscreen bool)
- func (w *Window) SetIcon(icon image.Image)
- func (w *Window) SetMaximized(maximized bool)
- func (w *Window) SetMaximumSize(width, height int)
- func (w *Window) SetMinimized(minimized bool)
- func (w *Window) SetMinimumSize(width, height int)
- func (w *Window) SetPosition(x, y int)
- func (w *Window) SetPositionCenter(screen *Screen)
- func (w *Window) SetSize(width, height int)
- func (w *Window) SetTitle(title string)
- func (w *Window) SetTransparent(transparent bool)
- func (w *Window) SetVisible(visible bool)
- func (w *Window) Size() (width, height int)
- func (w *Window) String() string
- func (w *Window) Title() string
- func (w *Window) Transparent() bool
- func (w *Window) Visible() bool
- type X11GLContext
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidGLXVersion = errors.New("GLX version 1.4 is required but not available.") ErrInvalidXKBVersion = errors.New(fmt.Sprintf("XKB version %d.%d is required but not available.", xkbMinMajor, xkbMinMinor)) )
var ( // Could happen due to lack of hardware support for the screen mode, or the driver may reject // the screen mode as well, really this could be generically anything but is typically an // hardware or driver issue using the screen mode. // // You should never take away the screen mode as an option from the user; as it is possible the // user may change an configuration setting of some sort with their operating system that will // allow the screen mode to be used properly. ErrBadScreenMode = errors.New("unable to switch screen mode; hardware or drivers do not support the mode.") // Only Microsoft Windows will ever return this error, systems that use DualView will sometimes // ignore screen mode change requests. ErrDualViewCapable = errors.New("unable to switch screen mode; the system is DualView capable.") )
var ( // Describes the worst possible OpenGL frame buffer configuration, this is // typically used as a parameter to GLChooseConfig. GLWorstConfig = &GLConfig{ Accelerated: false, Transparent: false, RedBits: 0, GreenBits: 0, BlueBits: 0, AlphaBits: 0, AccumRedBits: 0, AccumGreenBits: 0, AccumBlueBits: 0, AccumAlphaBits: 0, Samples: 0, AuxBuffers: 0, DepthBits: 0, StencilBits: 0, DoubleBuffered: false, StereoScopic: false, } // Describes the worst possible OpenGL frame buffer configuration while // still being hardware-accelerated by the graphics card, this is typically // used as a parameter to GLChooseConfig. GLWorstHWConfig = &GLConfig{ Accelerated: true, Transparent: false, RedBits: 0, GreenBits: 0, BlueBits: 0, AlphaBits: 0, AccumRedBits: 0, AccumGreenBits: 0, AccumBlueBits: 0, AccumAlphaBits: 0, Samples: 0, AuxBuffers: 0, DepthBits: 0, StencilBits: 0, DoubleBuffered: false, StereoScopic: false, } // Describes the best possible OpenGL frame buffer configuration that does // not have any transparency, this is typically used as a parameter to // GLChooseConfig. GLBestConfig = &GLConfig{ Accelerated: true, Transparent: true, RedBits: 255, GreenBits: 255, BlueBits: 255, AlphaBits: 255, AccumRedBits: 255, AccumGreenBits: 255, AccumBlueBits: 255, AccumAlphaBits: 255, Samples: 255, AuxBuffers: 255, DepthBits: 255, StencilBits: 255, DoubleBuffered: true, StereoScopic: false, } )
var (
ErrGLVersionNotSupported = errors.New("opengl version is not supported")
)
Functions ¶
func DisplayName ¶
func DisplayName() string
DisplayName returns the display_name string, as it was passed into SetDisplayName.
This function is only available on Linux.
func Exit ¶
func Exit()
Exit will exit the main loop previously entered via MainLoop(). All windows will be destroyed, etc.
You may call Init() again after calling this function should you want to re-gain access to the API.
func Init ¶
func Init() error
Init initializes Chippy, returning an error if there is a problem initializing some lower level part of Chippy, if an error was returned, it is disallowed to call any other Chippy functions. (And any attempt to do so will cause the program to panic.)
func IsInit ¶
func IsInit() bool
IsInit returns whether Chippy has been initialized via a previous call to Init().
IsInit() returns false if Destroy() was previously called.
func MainLoop ¶
func MainLoop()
MainLoop enters chippy's main loop.
This function *must* be called on the main thread (due to the restrictions that some platforms place, I.e. Cocoa on OS-X)
It's best to place this function inside either your init or main function.
This function will not return until chippy.Exit() is called.
If chippy is not initialized (via an previous call to the Init() function) then a panic will occur.
func MainLoopFrames ¶
func MainLoopFrames() chan func() bool
MainLoopFrames returns an channel of functions which return an boolean status as to whether you should continue running the 'main loop'.
Typically you would not use this function and would instead use the MainLoop() function.
This is for advanced users where the main loop is required to be shared with some other external library. I.e. this allows for communicative main loop handling.
See the MainLoop() function source code in chippy.go for an example of using this function properly.
This function should only really be called once (the same channel is always returned).
func RefreshScreens ¶
func RefreshScreens()
RefreshScreens queries for all available screens, and updates the internal cache returned by the Screens() function, such that the Screens() function returns new set of attatched/detatched Screen devices.
func SetDebugOutput ¶
SetDebugOutput specifies the io.Writer that debug output will be written to (ioutil.Discard by default).
func SetDisplayName ¶
func SetDisplayName(displayName string)
SetDisplayName sets the string that will be passed into XOpenDisplay; equivalent to the DISPLAY environment variable on posix complaint systems.
If set, this is used in place of the default DISPLAY environment variable.
This function is only available on Linux.
Types ¶
type CloseEvent ¶
CloseEvent is an event where the user attempted to close the window, using either the exit button, an quick-key combination like alt+F4, etc.
func (CloseEvent) String ¶
func (ev CloseEvent) String() string
String returns an string representation of this event.
func (CloseEvent) Time ¶
func (ev CloseEvent) Time() time.Time
Time implements the generic event interface.
type Cursor ¶
type Cursor struct { // Cursor image, internally it will be converted to an RGBA image. Image image.Image // Cursor Hotspot X, Y uint }
Cursor represents the image and hotspot of an graphical mouse cursor.
type CursorPositionEvent ¶
type CursorPositionEvent struct {
// Position of cursor relative to the window's client region.
X, Y float64
T time.Time
}
CursorPositionEvent is an event where the user moved the mouse cursor inside the window's client region.
func (CursorPositionEvent) String ¶
func (ev CursorPositionEvent) String() string
String returns an string representation of this event.
func (CursorPositionEvent) Time ¶
func (ev CursorPositionEvent) Time() time.Time
Time implements the generic event interface.
type CursorWithinEvent ¶
type CursorWithinEvent struct { // Weather the mouse cursor is within the window's client region or not. Within bool T time.Time }
CursorWithinEvent is an event where the user moved the mouse cursor inside or outside the window's client region.
func (CursorWithinEvent) String ¶
func (ev CursorWithinEvent) String() string
String returns an string representation of this event.
func (CursorWithinEvent) Time ¶
func (ev CursorWithinEvent) Time() time.Time
Time implements the generic event interface.
type DestroyedEvent ¶
DestroyedEvent is an event where the window was destroyed.
func (DestroyedEvent) String ¶
func (ev DestroyedEvent) String() string
String returns an string representation of this event.
func (DestroyedEvent) Time ¶
func (ev DestroyedEvent) Time() time.Time
Time implements the generic event interface.
type Event ¶
Event represents an event of some sort. The only requirement is that the event specify the point in time at which it happened.
Normally you will use an type assertion or type switch to retrieve more useful information from the underlying type.
type FocusedEvent ¶
FocusedEvent is an event where the user changed the focus of the window.
func (FocusedEvent) String ¶
func (ev FocusedEvent) String() string
String returns an string representation of this event.
func (FocusedEvent) Time ¶
func (ev FocusedEvent) Time() time.Time
Time implements the generic event interface.
type GLConfig ¶
type GLConfig struct { // Tells whether this configuration is hardware accelerated or uses some // software implementation version of OpenGL. // // Note: Most software implementations are very low OpenGL versions. (I.e. // GL 1.1) Accelerated bool // Tells whether or not this config will support the window being // transparent while using OpenGL rendering Transparent bool // The number of bits that represent an color per pixel in the frame buffer. RedBits, GreenBits, BlueBits, AlphaBits uint8 // The number of bits that represent an color per pixel in the accumulation // buffer. // // Note: GLSL shaders can perform an much better job of anything you would // be trying to do with the accumulation buffer. AccumRedBits, AccumGreenBits, AccumBlueBits, AccumAlphaBits uint8 // Number of Multi Sample Anti Aliasing samples this configuration supports // (e.g. 2 for 2x MSAA, 16 for 16x MSAA, etc) Samples uint8 // The number of auxiliary buffers available. // // Note: Auxiliary buffers are very rarely supported on most OpenGL // implementations (or choosing a configuration with them causes // non-accelerated rendering). // // For more information about this see the following forum URL: // http://www.opengl.org/discussion_boards/showthread.php/171060-auxiliary-buffers AuxBuffers uint8 // The number of bits that represent an pixel in the depth buffer. DepthBits uint8 // The number of bits that represent an pixel in the stencil buffer. StencilBits uint8 // Weather this frame buffer configuration is double buffered. DoubleBuffered bool // Weather this frame buffer configuration is stereoscopic capable. StereoScopic bool // contains filtered or unexported fields }
GLConfig represents an single opengl (frame buffer / pixel) configuration.
func GLChooseConfig ¶
GLChooseConfig chooses an appropriate configuration from the slice of possible configurations.
The returned configuration will have at least minConfig's attributes, or nil will be returned if there is no configuration that has at least minConfig's attributes.
The returned configuration will have no greater than maxConfig's attributes, or nil will be returned if there is no configuration that is below maxConfig's attributes.
After the selection process excludes configurations below minConfig and above maxConfig, the compatible configurations not excluded are sorted in order of closest-to maxConfig in the order of the following configuration attributes:
Accelerated RedBits, GreenBits, BlueBits, AlphaBits DoubleBuffered Samples DepthBits StencilBits StereoScopic Transparent AccumRedBits, AccumGreenBits, AccumBlueBits, AccumAlphaBits AuxBuffers
And the first configuration in the sorted list is returned. (I.e. you are most likely to recieve a Accelerated configuration, then one with high bytes per pixel, then one who is DoubleBuffered, Transparent, and so forth).
You may use the predefined GLWorstConfig and GLBestConfig variables if they suite your case.
type GLContext ¶
type GLContext interface { }
GLContext represents an OpenGL contect; although it represents any value it represents an important idea of what it's data actually is.
type GLContextFlags ¶
type GLContextFlags uint8
const ( GLDebug GLContextFlags = iota GLForwardCompatible GLCoreProfile GLCompatibilityProfile )
type GLRenderable ¶
type GLRenderable interface { // GLConfigs returns all possible OpenGL configurations, these are valid // configurations that may be used in an call to GLSetConfig. GLConfigs() []*GLConfig // GLSetConfig sets the OpenGL framebuffer configuration, unlike other // window management libraries, this action may be performed multiple // times. // // The config parameter must be an *GLConfig that originally came from the // GLConfigs() function mainly do to the fact that it must be initialized // internally. GLSetConfig(config *GLConfig) // GLConfig returns the currently in use *GLConfig or nil, as it was // previously set via an call to GLSetConfig() GLConfig() *GLConfig // GLCreateContext creates an OpenGL context for the specified OpenGL // version, or returns an error in the event that we cannot create an // context for that version. // // The flags parameter may be any combination of the predifined flags, as // follows: // // GLDebug, you will receive an OpenGL debug context. * // // GLForwardCompatible, you will receive an OpenGL forward compatible // context. * // // GLCoreProfile, you will receive an OpenGL core context. // // GLCompatibilityProfile, you will receive an OpenGL compatibility // context. // // Only one of GLCoreProfile or GLCompatibilityProfile should be present. // // GLCompatabilityProfile will be used if neither GLCoreProfile or // GLCompatibilityProfile are present, or if both are present. // // * = It is not advised to use this flag in production. // // You must call GLSetConfig() before calling this function. // // If the error returned is not nil, it will either be an undefined error // (which may indicate an error with the user's graphics card, or drivers), // or will be ErrGLVersionNotSupported, which indicates that the requested // OpenGL version is not available. GLCreateContext(major, minor uint, flags GLContextFlags, share GLContext) (GLContext, error) // GLDestroyContext destroys the specified OpenGL context. // // The context to destroy must not be active in any thread, period. GLDestroyContext(c GLContext) // GLMakeCurrent makes the specified context the current, active OpenGL // context in the current operating system thread. // // To make the OpenGL context inactive, you may call this function using // nil as the context, which will release the context. // // This function may be called from any thread, but an OpenGL context may // only be active inside one thread at an time. GLMakeCurrent(c GLContext) // GLSwapBuffers swaps the front and back buffers of this Renderable. // // This function may only be called in the presence of an active OpenGL // context. // // If the GLConfig set previously via GLSetConfig() is not DoubleBuffered, // then this function is no-op. GLSwapBuffers() // GLSetVerticalSync sets the vertical refresh rate sync mode (vsync). // // This function should only be called in the presence of an active OpenGL // context or else the call may fail due to drivers or platforms that // require an active context (e.g. Mesa). GLSetVerticalSync(mode VSyncMode) }
type MaximizedEvent ¶
type MaximizedEvent struct { // Weather or not the window is currently maximized. Maximized bool T time.Time }
MaximizedEvent is an event where the user maximized (or un-maximized) the window.
func (MaximizedEvent) String ¶
func (ev MaximizedEvent) String() string
String returns an string representation of this event.
func (MaximizedEvent) Time ¶
func (ev MaximizedEvent) Time() time.Time
Time implements the generic event interface.
type MinimizedEvent ¶
type MinimizedEvent struct { // Weather or not the window is currently minimized. Minimized bool T time.Time }
MinimizedEvent is an event where the user minimized (or un-minimized) the window.
func (MinimizedEvent) String ¶
func (ev MinimizedEvent) String() string
String returns an string representation of this event.
func (MinimizedEvent) Time ¶
func (ev MinimizedEvent) Time() time.Time
Time implements the generic event interface.
type NativeScreen ¶
type NativeScreen struct {
// contains filtered or unexported fields
}
type NativeScreenMode ¶
type NativeScreenMode struct {
// contains filtered or unexported fields
}
type NativeWindow ¶
type NativeWindow struct {
// contains filtered or unexported fields
}
func (*NativeWindow) GLConfig ¶
func (w *NativeWindow) GLConfig() *GLConfig
func (*NativeWindow) GLConfigs ¶
func (w *NativeWindow) GLConfigs() (configs []*GLConfig)
func (*NativeWindow) GLCreateContext ¶
func (w *NativeWindow) GLCreateContext(glVersionMajor, glVersionMinor uint, flags GLContextFlags, share GLContext) (GLContext, error)
func (*NativeWindow) GLDestroyContext ¶
func (w *NativeWindow) GLDestroyContext(c GLContext)
func (*NativeWindow) GLMakeCurrent ¶
func (w *NativeWindow) GLMakeCurrent(c GLContext)
func (*NativeWindow) GLSetConfig ¶
func (w *NativeWindow) GLSetConfig(config *GLConfig)
func (*NativeWindow) GLSetVerticalSync ¶
func (w *NativeWindow) GLSetVerticalSync(mode VSyncMode)
func (*NativeWindow) GLSwapBuffers ¶
func (w *NativeWindow) GLSwapBuffers()
func (*NativeWindow) GLVerticalSync ¶
func (w *NativeWindow) GLVerticalSync() VSyncMode
func (*NativeWindow) PixelClear ¶
func (w *NativeWindow) PixelClear(rect image.Rectangle)
type PaintEvent ¶
type PaintEvent struct { // Rectangle that needs to be redrawn / has been damaged. Rectangle image.Rectangle T time.Time }
PaintEvent is an event where the pixels inside the window's client region where damaged and need to be redrawn.
func (PaintEvent) String ¶
func (ev PaintEvent) String() string
String returns an string representation of this event.
func (PaintEvent) Time ¶
func (ev PaintEvent) Time() time.Time
Time implements the generic event interface.
type PositionEvent ¶
PositionEvent is an event where the user changed the position of the window.
func (PositionEvent) String ¶
func (ev PositionEvent) String() string
String returns an string representation of this event.
func (PositionEvent) Time ¶
func (ev PositionEvent) Time() time.Time
Time implements the generic event interface.
type ResizedEvent ¶
ResizedEvent is an event where the user changed the size of the window's client region.
func (ResizedEvent) String ¶
func (ev ResizedEvent) String() string
String returns an string representation of this event.
func (ResizedEvent) Time ¶
func (ev ResizedEvent) Time() time.Time
Time implements the generic event interface.
type Screen ¶
type Screen struct { *NativeScreen // contains filtered or unexported fields }
Screen represents an single physical screen device. It is only possible to get an screen from either the Screens or DefaultScreen functions.
func DefaultScreen ¶
func DefaultScreen() *Screen
DefaultScreen returns the 'default' screen, this is determined by either the window manager itself (as per an user's personal setup and configuration) or will be best-guessed by Chippy.
It is possible for this function to return nil, in the highly unlikely event that Screens() returns no screens at all, due to an user having none plugged in or activated.
func Screens ¶
func Screens() []*Screen
Screens returns all available, attached, and activated screens possible. Once this function is called, the result is cached such that future calls to this function are faster and return the cached result.
To update the internal screen cache, see the RefreshScreens function.
func (*Screen) Equals ¶
Equals compares this screen with the other screen, determining whether or not they are the same physical screen.
func (*Screen) Mode ¶
func (s *Screen) Mode() *ScreenMode
Mode returns the current screen mode in use by this screen, this will be either the last screen mode set via SetMode, or the original screen mode from OriginalMode in the event that no screen mode was previously set on this screen.
func (*Screen) Modes ¶
func (s *Screen) Modes() []*ScreenMode
Modes returns all available screen modes on this screen, sorted by highest resolution, then highest bytes per pixel, then highest refresh rate.
func (*Screen) Name ¶
Name returns an formatted string of the screens name, this is something that the user should be able to relate on their own to the actual physical screen device, this typically includes device brand name or model etc..
func (*Screen) OriginalMode ¶
func (s *Screen) OriginalMode() *ScreenMode
OriginalMode returns the original screen mode of this screen, as it was when this screen was created.
func (*Screen) PhysicalSize ¶
PhysicalSize returns the physical width and height of this screen, in millimeters, or zero as both width and height in the event there is no way to determine the physical size of this screen.
func (*Screen) Restore ¶
func (s *Screen) Restore()
Restore is short-hand for:
s.SetMode(s.OriginalMode())
func (*Screen) SetMode ¶
func (s *Screen) SetMode(newMode *ScreenMode) error
SetMode switches this screen to the specified screen mode, or returns an error in the event that we where unable to switch the screen to the specified screen mode.
The newMode parameter must be an screen mode that originally came from one of the methods Modes(), Mode(), or OriginalMode(), or else this function will panic.
If an error is returned, it will be either ErrBadScreenMode, or ErrDualViewCapable.
type ScreenChangedEvent ¶
type ScreenChangedEvent struct { // Screen that the window is located on. Screen *Screen T time.Time }
ScreenChangedEvent is an event where the user moved the window onto an different screen.
func (ScreenChangedEvent) String ¶
func (ev ScreenChangedEvent) String() string
String returns an string representation of this event.
func (ScreenChangedEvent) Time ¶
func (ev ScreenChangedEvent) Time() time.Time
Time implements the generic event interface.
type ScreenMode ¶
type ScreenMode struct { *NativeScreenMode // contains filtered or unexported fields }
ScreenMode represents an single, unique, screen mode, with an resolution, refresh rate, and bpp.
It is possible for multiple different ScreenMode's to exist with the same resolution, each with different refresh rates or bytes per pixel, respectively.
func (*ScreenMode) BytesPerPixel ¶
func (m *ScreenMode) BytesPerPixel() int
BytesPerPixel returns the number of bytes that represent an single pixel of this ScreenMode, or 0 if the bytes per pixel is unable to be determined.
func (*ScreenMode) Equals ¶
func (m *ScreenMode) Equals(other *ScreenMode) bool
Equals compares two ScreenMode(s) for equality. It does this by comparing resolutions, refresh rates, and bytes per pixels.
func (*ScreenMode) RefreshRate ¶
func (m *ScreenMode) RefreshRate() float32
RefreshRate returns the refresh rate of this ScreenMode, in hertz, or 0 if the refresh rate is unable to be determined.
func (*ScreenMode) Resolution ¶
func (m *ScreenMode) Resolution() (width, height int)
Resolution returns the width and height of this ScreenMode, in pixels.
func (*ScreenMode) String ¶
func (m *ScreenMode) String() string
String returns an nice string representing this ScreenMode
type VSyncMode ¶
type VSyncMode uint8
VSyncMode represents an single vertical reresh rate sync mode.
type Window ¶
type Window struct { *NativeWindow Keyboard *keyboard.Watcher Mouse *mouse.Watcher // contains filtered or unexported fields }
Window represents an single window, it will be non-visible untill the Open function is called.
func (*Window) AlwaysOnTop ¶
AlwaysOnTop tells whether the window is currently always on top of other windows, due to an previous call to the SetAlwaysOnTop function, or due to the user changing the always on top state directly through the window manager itself.
func (*Window) AspectRatio ¶
AspectRatio tells the aspect ratio that the window should try and keep when the user resizes the window, as previously set via SetAspectRatio, or the default of 0.
Note: If you want to determine the aspect ratio of the window, you should instead calculate it from the Size() function, by dividing width by height.
(Because if there was no previous call to SetAspectRatio, this function will return 0, which is not the actual window aspect ratio.)
func (*Window) CloseEvents ¶
CloseEvents stops the specified channel from receiving any more window events.
Call this function whenever you are done receiving window events from the given channel.
This is important for channels which have an very large buffer size to reduce memory consumption.
func (*Window) Cursor ¶
Cursor returns the currently in use cursor image, as previously set via an call to SetCursor.
Changes made to this Image *after* an initial call to SetCursor will not be reflected by the window unless you call SetCursor again.
func (*Window) CursorGrabbed ¶
CursorGrabbed tells whether the mouse cursor is currently grabbed, as previously set via an call to the SetCursorGrabbed function.
func (*Window) CursorPosition ¶
CursorPosition tells the current mouse cursor position, both x and y, relative to the client region of this window (specified in pixels)
func (*Window) CursorWithin ¶
CursorWithin tells whether the mouse cursor is inside the window's client region or not.
func (*Window) Decorated ¶
Decorations tells whether this window has window decorations on, as previously set by the SetDecorations function, or the default value of true (on).
func (*Window) Destroy ¶
func (w *Window) Destroy()
Destroy destroys the window. It is closed, and is then considered to be in an destroyed state.
After calling this function, the window is considered destroyed.
If the window is not currently open or is already destroyed then this function is no-op.
func (*Window) Destroyed ¶
Destroyed tells whether there was an previous call to the Destroy function.
func (*Window) EventsBuffer ¶
EventsBuffer returns an new read-only channel over which window events will be sent.
Events are sent in an non-blocking fashion. As such once the amount of buffered items in the channel reaches the maximum, then events will stop being sent.
You should ensure that the buffer size is large enough for you to read the events in an short amount of time.
func (*Window) Extents ¶
Extents returns how far the window region extends outward from the client region of this window, in pixels.
If the window's extents are unknown, [0, 0, 0, 0] is returned.
If the window is not open yet, [0, 0, 0, 0] is returned.
If the window is destroyed, [0, 0, 0, 0] is returned.
None of the extents will ever be less than zero.
func (*Window) Focused ¶
Focused tells whether this window currently has focus, and is therefor the current window that is being interacted with by the user.
func (*Window) FreeCursor ¶
FreeCursor removes the specified cursor from the internal cache. Cursors are cached because it allows for SetCursor() operations to perform more quickly without performing multiple copy operations underneath.
This allows you to simply use SetCursor() as often as you wish, for instance creating cursor animations and such.
If the specified cursor is nil; an panic will occur.
If the specified cursor is the active cursor (previously set via the SetCursor function); then the default cursor (nil) will be set and then the specified cursor free'd.
func (*Window) Fullscreen ¶
Fullscreen tells whether the window is currently full screen, as previously set by an call to the SetFullscreen function.
func (*Window) Icon ¶
Icon returns the currently in use icon image, as previously set via an call to SetIcon.
Changes made to this Image *after* an initial call to SetIcon will not be reflected by the window unless you call SetIcon again.
func (*Window) Maximized ¶
Maximized tells whether the window is currently maximized, as previously set via an call to the SetMaximized function, or due to the user changing the maximized status of the window directly through the window manager, or the default value of false.
func (*Window) MaximumSize ¶
MaximumSize tells the current maximum width and height of this windows client region, as set previously via the SetMaximumSize function, or the default values of width=0, height=0
Both width and height will be at least 1.
func (*Window) Minimized ¶
Minimized tells whether the window is currently minimized, as previously set via an call to the SetMinimized function, or due to the user changing the minimized status of the window directly through the window manager, or the default value of false.
func (*Window) MinimumSize ¶
MinimumSize tells the current minimum width and height of this windows client region, as set previously via the SetMinimumSize function, or the default values of width=150, height=150.
Both width and height will be at least 1.
func (*Window) Notify ¶
func (w *Window) Notify()
Notify causes the window to notify the user that an event has happened with the application, and they should look at the application.
Typically this is an small flashing animation, etc.
func (*Window) Open ¶
Open opens the window using the current settings, on the specified screen, or returns an error in the event that we are unable to open the window for some reason (the error will be descriptive).
If the window is already open this function is no-op.
If the window is destroyed, it's NativeWindow struct will be replaced with a new one and the window will become valid again.
func (*Window) Opened ¶
Opened tells whether the window is currently open.
If the window is destroyed, the returned value will be false.
func (*Window) OriginalScreen ¶
OriginalScreen returns the screen that this window was created on at the time Open() was called.
func (*Window) Position ¶
Position tells what the current x and y position of this window's client region.
func (*Window) PrepareCursor ¶
PrepareCursor prepares the specified cursor to be displayed, but does not display it. This is useful when you wish to load each frame for an cursor animation, but not cause the cursor to flicker while loading them into the internal cache.
If the specified cursor is nil; an panic will occur.
If the window is not open or is destroyed; the cursor cannot be prepared and this function is no-op.
func (*Window) Screen ¶
Screen returns the current screen that this window is currently residing on.
This function will return the original screen the window was created on in the event that we are unable to determine the current screen.
func (*Window) SetAlwaysOnTop ¶
SetAlwaysOnTop specifies whether the window should be always on top of other windows.
If the window is destroyed, this function will panic.
func (*Window) SetAspectRatio ¶
SetAspectRatio specifies the aspect ratio that the window should try to keep when the user resizes the window.
If the ratio is zero, then the window will be allowed to resize freely, without being restricted to an aspect ratio.
func (*Window) SetCursor ¶
SetCursor specifies the cursor to become the default cursor while the mouse is inside this window's client region.
If the cursor does not exist within the internal cache already -- it will be cached using PrepareCursor() automatically. Once you are done using the cursor, you should use the FreeCursor() function to remove the cursor from the internal cache (the cursor can still be displayed again after using FreeCursor(), it just will have to be loaded into the cache again).
func (*Window) SetCursorGrabbed ¶
SetCursorGrabbed specifies whether the mouse cursor should be grabbed, this means the cursor will be invisible, and will be forced to stay within the client region of the window. This behavior is the same as you would typically see in first person shooter games.
If the cursor is being released (false), then the original cursor position will be restored to where it was originally at the time of the last call to SetCursorGrabbed(true).
func (*Window) SetCursorPosition ¶
SetCursorPosition sets the mouse cursor to the new position x and y, specified in pixels relative to the client region of this window.
It is possible to move the cursor outside both the client region and window region, either by specifying an negative number, or an positive number larger than the window region.
func (*Window) SetDecorated ¶
SetDecorated specifies whether this window should have window decorations, this includes the title bar, exit buttons, borders, system menu buttons, icons, etc.
If the window is destroyed, this function will panic.
func (*Window) SetFullscreen ¶
SetFullscreen specifies whether the window should be full screen, consuming the entire screen's size, and being the only thing displayed on the screen.
If the window is destroyed, this function will panic.
func (*Window) SetIcon ¶
SetIcon specifies the window icon which should be displayed anywhere that an window icon is needed, this typically includes in the title bar decoration, or in the icon tray.
If the icon is nil; the default 'chippy' icon is restored.
func (*Window) SetMaximized ¶
SetMaximized specifies whether the window should currently be maximized.
func (*Window) SetMaximumSize ¶
SetMaximumSize specifies the maximum width and height that this windows client region is allowed to have, the user will be disallowed to resize the window any larger than this specified size.
If the size passed into both SetMaximumSize and SetMinimumSize are the same, then the window will be non-resizable.
If either width or height are zero, then there will be no maximum size restriction placed.
If the window is destroyed, this function will panic.
func (*Window) SetMinimized ¶
SetMinimized specifies whether the window should currently be minimized.
func (*Window) SetMinimumSize ¶
SetMinimumSize specifies the minimum width and height that this windows client region is allowed to have, the user will be disallowed to resize the window any smaller than this specified size.
If either width or height are zero, then there will be no maximum size restriction placed.
If the size passed into both SetMinimumSize and SetMaximumSize are the same, then the window will be non-resizable.
func (*Window) SetPosition ¶
SetPosition specifies the new x and y position of this window's client region, relative to the top-left corner of the screen, in pixels.
If the window is destroyed, this function will panic.
func (*Window) SetPositionCenter ¶
SetPositionCenter sets the window position such that it is perfectly in the center of the specified screen.
func (*Window) SetSize ¶
SetSize specifies the new width and height of this window's client region, in pixels.
The window's size will be clamped such that it is always 1px wide/tall; and never exceeds the bounds of the minimum or maximum size of the window if one is specified.
If w.Size() is later called, it will return the identical (non-clamped) values you provide here.
func (*Window) SetTitle ¶
SetTitle sets the title of the window, this is shown anywhere where there needs to be an string representation, typical places include the window's Title Bar decoration, and in the icon tray (which displays minimized windows, etc).
If the window is destroyed, this function will panic.
func (*Window) SetTransparent ¶
SetTransparent specifies whether this window should be transparent, used in things like splash screens, etc.
Default: false
func (*Window) SetVisible ¶
SetVisible specifies whether this window should be visibly seen by the user, if false the window will appear simply gone (even though it actually exists, and you may render to it, and at an later time show the window again).
If the window is destroyed, this function will panic.
func (*Window) Size ¶
Size tells the current width and height of this window, as set previously by an call to the SetSize function, or due to the user resizing the window through the window manager itself.
Both width and height will be at least 1.
func (*Window) Title ¶
Title returns the title of the window, as it was set by SetTitle, or the default title: "Chippy Window".
func (*Window) Transparent ¶
Transparent tells whether this window is transparent, via an previous call to SetTransparent()
type X11GLContext ¶
type X11GLContext struct {
// contains filtered or unexported fields
}