Class: SFML::WindowBase
- Inherits:
-
Object
- Object
- SFML::WindowBase
- Defined in:
- ext/window/window_base.c,
ext/window/window_base.c
Overview
An OS window and its event queue, without an OpenGL context. It is the base of SFML::Window and SFML::RenderWindow, and every method below is also available -- backed by the matching sfRenderWindow entry point -- on both.
Class Method Summary collapse
Instance Method Summary collapse
-
#close! ⇒ self
Closes the window.
-
#create_vulkan_surface(instance, allocator = nil) ⇒ Integer?
Creates a Vulkan surface for this window.
-
#cursor=(value) ⇒ Cursor
Sets the window's mouse cursor.
-
#cursor_grabbed=(value) ⇒ self
Confines or releases the mouse cursor to the window's client area.
-
#cursor_visible=(value) ⇒ self
Shows or hides the mouse cursor over the window.
-
#focus? ⇒ Boolean
Returns
trueif the window currently has focus. -
#new(video_mode, title, style = :default, state = :windowed) ⇒ WindowBase
constructor
Creates an OS window with no OpenGL context of its own.
-
#is_open? ⇒ Boolean
Returns
truewhile the window is open. -
#joystick_threshold=(value) ⇒ Float
Sets the minimum joystick axis change that generates a move event.
-
#key_repeat_enabled=(value) ⇒ self
Enables or disables key-repeat events.
-
#maximum_size=(value) ⇒ Vector2
Sets the window's maximum allowed client size.
-
#minimum_size=(value) ⇒ Vector2
Sets the window's minimum allowed client size.
-
#mouse_cursor=(value) ⇒ Cursor
Sets the window's mouse cursor.
-
#native_handle ⇒ Integer
Returns the OS-specific window handle.
-
#poll_event!(event) ⇒ Boolean
Pops the next pending event into
event, if any, without blocking. -
#position ⇒ Vector2
Returns the window's position in desktop coordinates.
-
#position=(value) ⇒ Vector2
Moves the window to
value. -
#request_focus ⇒ self
Requests focus for this window.
-
#set_icon(size, pixels) ⇒ String
Sets the window's icon from RGBA32 pixel data.
-
#size ⇒ Vector2
Returns the client area size in pixels.
-
#size=(value) ⇒ self
Resizes the window's client area.
-
#title=(value) ⇒ self
Sets the window title.
-
#visible=(value) ⇒ self
Shows or hides the window.
-
#wait_event!(event) ⇒ Boolean
Blocks until an event is available and pops it into
event.
Constructor Details
#new(video_mode, title, style = :default, state = :windowed) ⇒ WindowBase
Creates an OS window with no OpenGL context of its own.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'ext/window/window_base.c', line 79
static VALUE WindowBase_initialize(int argc, VALUE* argv, VALUE self) {
VALUE rb_video_mode, rb_title, rb_style, rb_state, title_buffer;
sfWindowState state = sfWindowed;
uint32_t style = sfDefaultStyle;
sfWindowBase* window;
rb_scan_args(argc, argv, "22", &rb_video_mode, &rb_title, &rb_style, &rb_state);
if (!rb_obj_is_kind_of(rb_video_mode, Get_Klass_Mode())) {
raise_invalid_argument_class(Get_Klass_Mode());
}
if (!NIL_P(rb_style)) {
style = window_style_from_rb(rb_style);
}
if (!NIL_P(rb_state)) {
state = window_state_from_rb(rb_state);
}
title_buffer = utf32_from_rb(rb_title);
window = sfWindowBase_createUnicode(*Get_Mode_Struct(rb_video_mode), UTF32_PTR(title_buffer),
style, state);
RB_GC_GUARD(title_buffer);
if (window == NULL) {
rb_raise(rb_eRuntimeError, "failed to create window");
}
Get_Window_Data(self)->handle = window;
Get_Window_Data(self)->kind = SFML_WINDOW_KIND_BASE;
return self;
}
|
Class Method Details
.from_handle(handle) ⇒ WindowBase
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'ext/window/window_base.c', line 124
static VALUE WindowBase_s_from_handle(int argc, VALUE* argv, VALUE klass) {
VALUE rb_handle;
sfWindowBase* window;
rb_scan_args(argc, argv, "1", &rb_handle);
window = sfWindowBase_createFromHandle((sfWindowHandle)(uintptr_t)NUM2ULL(rb_handle));
if (window == NULL) {
rb_raise(rb_eRuntimeError, "failed to create window from handle");
}
return Window_wrap_handle(klass, window, SFML_WINDOW_KIND_BASE);
}
|
Instance Method Details
#close! ⇒ self
Closes the window.
#create_vulkan_surface(instance, allocator = nil) ⇒ Integer?
Creates a Vulkan surface for this window.
#cursor=(value) ⇒ Cursor
Sets the window's mouse cursor.
#cursor_grabbed=(value) ⇒ self
Confines or releases the mouse cursor to the window's client area.
#cursor_visible=(value) ⇒ self
Shows or hides the mouse cursor over the window.
#focus? ⇒ Boolean
Returns true if the window currently has focus.
#is_open? ⇒ Boolean
Returns true while the window is open.
#joystick_threshold=(value) ⇒ Float
Sets the minimum joystick axis change that generates a move event.
#key_repeat_enabled=(value) ⇒ self
Enables or disables key-repeat events.
#maximum_size=(value) ⇒ Vector2
Sets the window's maximum allowed client size.
#minimum_size=(value) ⇒ Vector2
Sets the window's minimum allowed client size.
#mouse_cursor=(value) ⇒ Cursor
Sets the window's mouse cursor.
#native_handle ⇒ Integer
Returns the OS-specific window handle.
#poll_event!(event) ⇒ Boolean
Pops the next pending event into event, if any, without blocking.
#position ⇒ Vector2
Returns the window's position in desktop coordinates.
#position=(value) ⇒ Vector2
Moves the window to value.
#request_focus ⇒ self
Requests focus for this window.
#set_icon(size, pixels) ⇒ String
Sets the window's icon from RGBA32 pixel data.
#size ⇒ Vector2
Returns the client area size in pixels.
#size=(value) ⇒ self
Resizes the window's client area.
#title=(value) ⇒ self
Sets the window title.
#visible=(value) ⇒ self
Shows or hides the window.
#wait_event!(event) ⇒ Boolean
Blocks until an event is available and pops it into event.