class Espresso::WindowBuilder

Overview

Simplifies creation of windows with the numerous options (hints) available.

Included Modules

Defined in:

espresso/window_builder.cr

Instance Method Summary

Instance Method Detail

def accum_alpha_bits=(value) #

Specifies the desired bit depths of the alpha component of the accumulation buffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).

Accumulation buffers are a legacy OpenGL feature and should not be used in new code.


[View source]
def accum_blue_bits=(value) #

Specifies the desired bit depths of the blue component of the accumulation buffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).

Accumulation buffers are a legacy OpenGL feature and should not be used in new code.


[View source]
def accum_green_bits=(value) #

Specifies the desired bit depths of the green component of the accumulation buffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).

Accumulation buffers are a legacy OpenGL feature and should not be used in new code.


[View source]
def accum_red_bits=(value) #

Specifies the desired bit depths of the red component of the accumulation buffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).

Accumulation buffers are a legacy OpenGL feature and should not be used in new code.


[View source]
def alpha_bits=(value) #

Specifies the desired bit depth of the alpha color component for the default framebuffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).


[View source]
def auto_iconify #

Specifies whether the full screen window will automatically iconify and restore the previous video mode on input focus loss. Possible values are true and false. This hint is ignored for windowed mode windows.


[View source]
def auto_iconify=(flag) #

Specifies whether the full screen window will automatically iconify and restore the previous video mode on input focus loss. Possible values are true and false. This hint is ignored for windowed mode windows.


[View source]
def aux_buffers=(value) #

Specifies the desired number of auxiliary buffers. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).

Auxiliary buffers are a legacy OpenGL feature and should not be used in new code.


[View source]
def blue_bits=(value) #

Specifies the desired bit depth of the blue color component for the default framebuffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).


[View source]
def build(width, height, title, share) #

Creates the window with all previously specified hints.

The width argument is the desired width, in screen coordinates, of the window. This must be greater than zero. The height argument is the desired height, in screen coordinates, of the window. This must be greater than zero. The title is the initial, UTF-8 encoded window title. The share argument is the window shose context to share resources with.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build(width, height, title) #

Creates the window with all previously specified hints.

The width argument is the desired width, in screen coordinates, of the window. This must be greater than zero. The height argument is the desired height, in screen coordinates, of the window. This must be greater than zero. The title is the initial, UTF-8 encoded window title.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build(width, height, title, share, &) #

Creates the window with all previously specified hints. The window is yielded to the block and automatically destroyed when the block completes. Additionally, the window's context is made current on the calling thread.

The width argument is the desired width, in screen coordinates, of the window. This must be greater than zero. The height argument is the desired height, in screen coordinates, of the window. This must be greater than zero. The title is the initial, UTF-8 encoded window title. The share argument is the window shose context to share resources with.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build(width, height, title, &) #

Creates the window with all previously specified hints. The window is yielded to the block and automatically destroyed when the block completes. Additionally, the window's context is made current on the calling thread.

The width argument is the desired width, in screen coordinates, of the window. This must be greater than zero. The height argument is the desired height, in screen coordinates, of the window. This must be greater than zero. The title is the initial, UTF-8 encoded window title.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String, monitor : Monitor, width : Int32, height : Int32, &) #

Creates the window as full screen with all previously specified hints. The window is yielded to the block and automatically destroyed when the block completes. Additionally, the window's context is made current on the calling thread.

The title is the initial, UTF-8 encoded window title. The monitor is the display device to place the fullscreen window on. The width and height specify the desired size of the window on the monitor.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String, monitor : Monitor, width : Int32, height : Int32, share : Window) #

Creates the window as full screen with all previously specified hints.

The title is the initial, UTF-8 encoded window title. The monitor is the display device to place the fullscreen window on. The width and height specify the desired size of the window on the monitor. The share argument is the window whose context to share resources with.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String, monitor : Monitor, width : Int32, height : Int32) #

Creates the window as full screen with all previously specified hints.

The title is the initial, UTF-8 encoded window title. The monitor is the display device to place the fullscreen window on. The width and height specify the desired size of the window on the monitor.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String, monitor : Monitor, share : Window) #

Creates the window as full screen with all previously specified hints.

The title is the initial, UTF-8 encoded window title. The monitor is the display device to place the fullscreen window on. The share argument is the window whose context to share resources with.

The width and height of the window match the size of the monitor's current display mode.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String, monitor : Monitor) #

Creates the window as full screen with all previously specified hints.

The title is the initial, UTF-8 encoded window title. The monitor is the display device to place the fullscreen window on.

The width and height of the window match the size of the monitor's current display mode.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String) #

Creates the window as full screen with all previously specified hints.

The title is the initial, UTF-8 encoded window title.

The primary monitor is used for the fullscreen window. The width and height of the window match the size of the monitor's current display mode.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String, monitor : Monitor, width : Int32, height : Int32, share : Window, &) #

Creates the window as full screen with all previously specified hints. The window is yielded to the block and automatically destroyed when the block completes. Additionally, the window's context is made current on the calling thread.

The title is the initial, UTF-8 encoded window title. The monitor is the display device to place the fullscreen window on. The width and height specify the desired size of the window on the monitor. The share argument is the window whose context to share resources with.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String, monitor : Monitor, share : Window, &) #

Creates the window as full screen with all previously specified hints. The window is yielded to the block and automatically destroyed when the block completes. Additionally, the window's context is made current on the calling thread.

The title is the initial, UTF-8 encoded window title. The monitor is the display device to place the fullscreen window on. The share argument is the window whose context to share resources with.

The width and height of the window match the size of the monitor's current display mode.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String, &) #

Creates the window as full screen with all previously specified hints. The window is yielded to the block and automatically destroyed when the block completes. Additionally, the window's context is made current on the calling thread.

The title is the initial, UTF-8 encoded window title.

The primary monitor is used for the fullscreen window. The width and height of the window match the size of the monitor's current display mode.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def build_full_screen(title : String, monitor : Monitor, &) #

Creates the window as full screen with all previously specified hints. The window is yielded to the block and automatically destroyed when the block completes. Additionally, the window's context is made current on the calling thread.

The title is the initial, UTF-8 encoded window title. The monitor is the display device to place the fullscreen window on.

The width and height of the window match the size of the monitor's current display mode.

Possible errors that could be raised are: NotInitializedError, InvalidEnumError, InvalidValueError, APIUnavailableError, VersionUnavailableError, FormatUnavailableError, and PlatformError.


[View source]
def center_cursor #

Specifies whether the cursor should be centered over newly created full screen windows. Possible values are true and false. This hint is ignored for windowed mode windows.


[View source]
def center_cursor=(flag) #

Specifies whether the cursor should be centered over newly created full screen windows. Possible values are true and false. This hint is ignored for windowed mode windows.


[View source]
def client_api=(value : ClientAPI) #

Specifies which client API to create the context for. Possible values are in the ClientAPI enum. This is a hard constraint.


[View source]
def cocoa_frame_name=(value) #

Specifies the UTF-8 encoded name to use for autosaving the window frame, or if empty disables frame autosaving for the window. This is applicable only on macOS platforms.


[View source]
def cocoa_graphics_switching #

Specifies whether to in Automatic Graphics Switching, i.e. to allow the system to choose the integrated GPU for the OpenGL context and move it between GPUs if necessary or whether to force it to always run on the discrete GPU. This only affects systems with both integrated and discrete GPUs. Possible values are true and false. This is applicable only on macOS platforms.

Simpler programs and tools may want to enable this to save power, while games and other applications performing advanced rendering will want to leave it disabled.

A bundled application that wishes to participate in Automatic Graphics Switching should also declare this in its Info.plist by setting the NSSupportsAutomaticGraphicsSwitching key to true.


[View source]
def cocoa_graphics_switching=(flag) #

Specifies whether to in Automatic Graphics Switching, i.e. to allow the system to choose the integrated GPU for the OpenGL context and move it between GPUs if necessary or whether to force it to always run on the discrete GPU. This only affects systems with both integrated and discrete GPUs. Possible values are true and false. This is applicable only on macOS platforms.

Simpler programs and tools may want to enable this to save power, while games and other applications performing advanced rendering will want to leave it disabled.

A bundled application that wishes to participate in Automatic Graphics Switching should also declare this in its Info.plist by setting the NSSupportsAutomaticGraphicsSwitching key to true.


[View source]
def cocoa_retina_framebuffer #

Specifies whether to use full resolution framebuffers on Retina displays. Possible values are true and false. This is applicable only on macOS platforms.


[View source]
def cocoa_retina_framebuffer=(flag) #

Specifies whether to use full resolution framebuffers on Retina displays. Possible values are true and false. This is applicable only on macOS platforms.


[View source]
def context_creation_api=(value : ContextCreationAPI) #

Specifies which context creation API to use to create the context. Possible values are in the ContextCreationAPI enum. This is a hard constraint. If no client API is requested (via #client_api), this hint is ignored.

macOS: The EGL API is not available on this platform and requests to use it will fail.

Wayland: The EGL API is the native context creation API, so this hint will have no effect.

OSMesa: As its name implies, an OpenGL context created with OSMesa does not update the window contents when its buffers are swapped. Use OpenGL functions or the OSMesa native access functions glfwGetOSMesaColorBuffer and glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.


[View source]
def context_no_error #

Specifies whether errors should be generated by the context. Possible values are true and false. If enabled, situations that would have generated errors instead cause undefined behavior.


[View source]
def context_no_error=(flag) #

Specifies whether errors should be generated by the context. Possible values are true and false. If enabled, situations that would have generated errors instead cause undefined behavior.


[View source]
def context_release_behavior=(value : ReleaseBehavior) #

Specifies the release behavior to be used by the context. Possible values are in the ReleaseBehavior enum.


[View source]
def context_robustness=(value : ContextRobustness) #

Specifies the robustness strategy to be used by the context. This can be one of values from the ContextRobustness enum.


[View source]
def context_version(major, minor) : Nil #

Specifies the client API version that the created context must be compatible with. The exact behavior of these hints depend on the request client API.

OpenGL: These hints are not hard constraints, but creation will fail if the OpenGL version of the created context is less than the one requested. It is therefore perfectly safe to use the default of version 1.0 for legacy code and you will still get backwards-compatible contexts of version 3.0 and above when available.

While there is no way to ask the driver for a context of the highest supported version, GLFW will attempt to provide this when you ask for a version 1.0 context, which is the default for these hints.

OpenGL ES: These hints are not hard constraints, but creation will fail if the OpenGL ES version of the created context is less than the one requested. Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested, and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x.


[View source]
def decorated #

Specifies whether the windowed mode window will have window decorations such as a border, a close widget, etc. An undecorated window will not be resizable by the user, but will still allow the user to generate close events on some platforms. Possible values are true and false. This hint is ignored for full screen windows.


[View source]
def decorated=(flag) #

Specifies whether the windowed mode window will have window decorations such as a border, a close widget, etc. An undecorated window will not be resizable by the user, but will still allow the user to generate close events on some platforms. Possible values are true and false. This hint is ignored for full screen windows.


[View source]
def depth_bits=(value) #

Specifies the desired bits used for the depth buffer of the default framebuffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).


[View source]
def double_buffer #

Specifies whether the framebuffer should be double buffered. You nearly always want to use double buffering. This is a hard constraint. Possible values are true and false.


[View source]
def double_buffer=(flag) #

Specifies whether the framebuffer should be double buffered. You nearly always want to use double buffering. This is a hard constraint. Possible values are true and false.


[View source]
def floating #

Specifies whether the windowed mode window will be floating above other regular windows, also called topmost or always-on-top. This is intended primarily for debugging purposes and cannot be used to implement proper full screen windows. Possible values are true and false. This hint is ignored for full screen windows.


[View source]
def floating=(flag) #

Specifies whether the windowed mode window will be floating above other regular windows, also called topmost or always-on-top. This is intended primarily for debugging purposes and cannot be used to implement proper full screen windows. Possible values are true and false. This hint is ignored for full screen windows.


[View source]
def focus_on_show #

Specifies whether the window will be given input focus when Window#show is called. Possible values are true and false.


[View source]
def focus_on_show=(flag) #

Specifies whether the window will be given input focus when Window#show is called. Possible values are true and false.


[View source]
def focused #

Specifies whether the windowed mode window will be given input focus when created. Possible values are true and false. This hint is ignored for full screen and initially hidden windows.


[View source]
def focused=(flag) #

Specifies whether the windowed mode window will be given input focus when created. Possible values are true and false. This hint is ignored for full screen and initially hidden windows.


[View source]
def green_bits=(value) #

Specifies the desired bit depth of the green color component for the default framebuffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).


[View source]
def maximized #

Specifies whether the windowed mode window will be maximized when created. Possible values are true and false. This hint is ignored for full screen windows.


[View source]
def maximized=(flag) #

Specifies whether the windowed mode window will be maximized when created. Possible values are true and false. This hint is ignored for full screen windows.


[View source]
def opengl_debug_context #

Specifies whether to create a debug OpenGL context, which may have additional error and performance issue reporting functionality. Possible values are true and false. If OpenGL ES is requested, this hint is ignored.


[View source]
def opengl_debug_context=(flag) #

Specifies whether to create a debug OpenGL context, which may have additional error and performance issue reporting functionality. Possible values are true and false. If OpenGL ES is requested, this hint is ignored.


[View source]
def opengl_forward_compat #

Specifies whether the OpenGL context should be forward-compatible, i.e. one where all functionality deprecated in the requested version of OpenGL is removed. This must only be used if the requested OpenGL version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.


[View source]
def opengl_forward_compat=(flag) #

Specifies whether the OpenGL context should be forward-compatible, i.e. one where all functionality deprecated in the requested version of OpenGL is removed. This must only be used if the requested OpenGL version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.


[View source]
def opengl_profile=(value : OpenGLProfile) #

Specifies which OpenGL profile to create the context for. Possible values are in the OpenGLProfile enum. If requesting an OpenGL version below 3.2, OpenGLProfile::Any must be used. If OpenGL ES is requested, this hint is ignored.


[View source]
def red_bits=(value) #

Specifies the desired bit depth of the red color component for the default framebuffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).


[View source]
def refresh_rate=(value) #

Specifies the desired refresh rate for full screen windows. A value of nil means the highest available refresh rate will be used. This hint is ignored for windowed mode windows.


[View source]
def resizable #

Specifies whether the windowed mode window will be resizable by the user. The window will still be resizable using the Window.size= setter. Possible values are true and false. This hint is ignored for full screen and undecorated windows.


[View source]
def resizable=(flag) #

Specifies whether the windowed mode window will be resizable by the user. The window will still be resizable using the Window.size= setter. Possible values are true and false. This hint is ignored for full screen and undecorated windows.


[View source]
def samples=(value) #

Specifies the desired number of samples to use for multisampling. Zero disables multisampling. A value of nil means the application has no preference (don't care).


[View source]
def scale_to_monitor #

Specifies whether the window content area should be resized based on the monitor content scale of any monitor it is placed on. This includes the initial placement when the window is created. Possible values are true and false.

This hint only has an effect on platforms where screen coordinates and pixels always map 1:1 such as Windows and X11. On platforms like macOS the resolution of the framebuffer is changed independently of the window size.


[View source]
def scale_to_monitor=(flag) #

Specifies whether the window content area should be resized based on the monitor content scale of any monitor it is placed on. This includes the initial placement when the window is created. Possible values are true and false.

This hint only has an effect on platforms where screen coordinates and pixels always map 1:1 such as Windows and X11. On platforms like macOS the resolution of the framebuffer is changed independently of the window size.


[View source]
def srgb_capable #

Specifies whether the framebuffer should be sRGB capable. Possible values are true and false.

OpenGL: If enabled and supported by the system, the GL_FRAMEBUFFER_SRGB enable will control sRGB rendering. By default, sRGB rendering will be disabled.

OpenGL ES: If enabled and supported by the system, the context will always have sRGB rendering enabled.


[View source]
def srgb_capable=(flag) #

Specifies whether the framebuffer should be sRGB capable. Possible values are true and false.

OpenGL: If enabled and supported by the system, the GL_FRAMEBUFFER_SRGB enable will control sRGB rendering. By default, sRGB rendering will be disabled.

OpenGL ES: If enabled and supported by the system, the context will always have sRGB rendering enabled.


[View source]
def stencil_bits=(value) #

Specifies the desired bits used for the stencil buffer of the default framebuffer. Possible values are non-negative integers and nil. Providing nil means the application has no preference (don't care).


[View source]
def stereo #

Specifies whether to use OpenGL stereoscopic rendering. Possible values are true and false. This is a hard constraint.


[View source]
def stereo=(flag) #

Specifies whether to use OpenGL stereoscopic rendering. Possible values are true and false. This is a hard constraint.


[View source]
def transparent_framebuffer #

Specifies whether the window framebuffer will be transparent. If enabled and supported by the system, the window framebuffer alpha channel will be used to combine the framebuffer with the background. This does not affect window decorations. Possible values are true and false.


[View source]
def transparent_framebuffer=(flag) #

Specifies whether the window framebuffer will be transparent. If enabled and supported by the system, the window framebuffer alpha channel will be used to combine the framebuffer with the background. This does not affect window decorations. Possible values are true and false.


[View source]
def visible #

Specifies whether the windowed mode window will be initially visible. Possible values are true and false. This hint is ignored for full screen windows.


[View source]
def visible=(flag) #

Specifies whether the windowed mode window will be initially visible. Possible values are true and false. This hint is ignored for full screen windows.


[View source]
def x11_class_name=(value) #

Specifies the desired ASCII encoded class part the ICCCM WM_CLASS window property. This is applicable only on X11 platforms.


[View source]
def x11_instance_name=(value) #

Specifies the desired ASCII encoded instance part of the ICCCM WM_CLASS window property. This is applicable only on X11 platforms.


[View source]