Class: SDL2::Window
- Includes:
- WINDOW
- Defined in:
- lib/sdl2/window.rb
Overview
System Window A rectangular area you can blit into.
Defined Under Namespace
Classes: Data
Constant Summary
Constants included from WINDOW
SDL2::WINDOW::BORDERLESS, SDL2::WINDOW::FOREIGN, SDL2::WINDOW::FULLSCREEN, SDL2::WINDOW::FULLSCREEN_DESKTOP, SDL2::WINDOW::HIDDEN, SDL2::WINDOW::INPUT_FOCUS, SDL2::WINDOW::INPUT_GRABBED, SDL2::WINDOW::MAXIMIZED, SDL2::WINDOW::MINIMIZED, SDL2::WINDOW::MOUSE_FOCUS, SDL2::WINDOW::OPENGL, SDL2::WINDOW::RESIZABLE, SDL2::WINDOW::SHOWN
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
The Window’s data manager.
Class Method Summary collapse
-
.create(title = '', x = 0, y = 0, w = 100, h = 100, flags = 0) ⇒ Object
Construct a new window with given:.
-
.create_from(data) ⇒ Object
Constructs a new window from arbitrary system-specific structure See SDL Documentation.
-
.create_with_renderer(w, h, flags) ⇒ Object
Constructs both a window and a renderer.
-
.from_id(id) ⇒ Object
Returns the identified window already created.
-
.release(pointer) ⇒ Object
Release memory utilized by structure.
Instance Method Summary collapse
-
#brightness ⇒ Object
Return the brightness level.
-
#brightness=(level) ⇒ Object
Set the brightness level.
-
#current_size ⇒ Object
Get the window’s current size.
-
#current_size=(size) ⇒ Object
Set the window’s current size.
-
#display ⇒ Object
Get the display associated with this window.
-
#display_index ⇒ Object
Get the display index associated with this window.
-
#display_mode ⇒ Object
Get a copy of the DisplayMode structure.
-
#flags ⇒ Object
Get the window flags.
-
#fullscreen=(flags) ⇒ Object
Set the window’s FULLSCREEN mode flags.
-
#grab=(value) ⇒ Object
Set the input grab mode.
-
#grab? ⇒ Boolean
The window’s input grab mode.
-
#hide ⇒ Object
Hide the window.
-
#icon=(surface) ⇒ Object
Set the window’s icon from a surface.
-
#id ⇒ Object
Get the window identifier.
-
#initialize(*args, &block) ⇒ Window
constructor
Construct a new window.
-
#maximize ⇒ Object
Maximize the window.
-
#maximum_size ⇒ Object
Get the window’s maximum_size.
-
#maximum_size=(size) ⇒ Object
Set the window’s maximum size.
-
#minimize ⇒ Object
Minimize the window.
-
#minimum_size ⇒ Object
Get the window’s minimum size.
-
#minimum_size=(size) ⇒ Object
Set the window’s minimum size.
-
#pixel_format ⇒ Object
Get the window pixel format.
-
#position ⇒ Object
Get the window’s position.
-
#position=(location) ⇒ Object
Set the window’s position.
-
#raise_above ⇒ Object
Raise the window.
-
#restore ⇒ Object
Restore the window.
-
#show ⇒ Object
Show the window.
-
#surface ⇒ Object
Return the surface associated with the window.
-
#title ⇒ Object
Get the window title caption.
-
#title=(value) ⇒ Object
Set the window title caption.
-
#update_surface ⇒ Object
Update the window’s surface.
Methods included from EnumerableConstants
Methods inherited from Struct
#==, cast, #free, #update_members
Methods included from StructHelper
#member_readers, #member_writers
Constructor Details
#initialize(*args, &block) ⇒ Window
Construct a new window.
140 141 142 143 |
# File 'lib/sdl2/window.rb', line 140 def initialize(*args, &block) super(*args, &block) @data = Data.new(self) end |
Instance Attribute Details
#data ⇒ Object (readonly)
The Window’s data manager.
137 138 139 |
# File 'lib/sdl2/window.rb', line 137 def data @data end |
Class Method Details
.create(title = '', x = 0, y = 0, w = 100, h = 100, flags = 0) ⇒ Object
Construct a new window with given:
152 153 154 |
# File 'lib/sdl2/window.rb', line 152 def self.create(title ='', x = 0, y = 0, w = 100, h = 100, flags = 0) SDL2.create_window!(title, x, y, w, h, flags) end |
.create_from(data) ⇒ Object
Constructs a new window from arbitrary system-specific structure See SDL Documentation
159 160 161 |
# File 'lib/sdl2/window.rb', line 159 def self.create_from(data) create_window_from!(data) end |
.create_with_renderer(w, h, flags) ⇒ Object
Constructs both a window and a renderer
173 174 175 176 177 178 179 180 181 |
# File 'lib/sdl2/window.rb', line 173 def self.create_with_renderer(w, h, flags) window = Window.new renderer = Renderer.new if SDL2.create_window_and_renderer(w,h,flags,window,renderer) == 0 [window, renderer] else nil end end |
.from_id(id) ⇒ Object
Returns the identified window already created
165 166 167 |
# File 'lib/sdl2/window.rb', line 165 def self.from_id(id) get_window_from_id!(id) end |
.release(pointer) ⇒ Object
Release memory utilized by structure
184 185 186 |
# File 'lib/sdl2/window.rb', line 184 def self.release(pointer) destroy_window(self.new pointer) end |
Instance Method Details
#brightness ⇒ Object
Return the brightness level
195 196 197 |
# File 'lib/sdl2/window.rb', line 195 def brightness SDL2.get_window_brightness(self) end |
#brightness=(level) ⇒ Object
Set the brightness level
200 201 202 |
# File 'lib/sdl2/window.rb', line 200 def brightness=(level) SDL2.set_window_brightness(self, level.to_f) end |
#current_size ⇒ Object
Get the window’s current size
302 303 304 305 306 307 |
# File 'lib/sdl2/window.rb', line 302 def current_size() w_struct, h_struct = IntStruct.new, IntStruct.new SDL2::get_window_size(self, w_struct, h_struct) w, h = w_struct[:value], h_struct[:value] [w, h] end |
#current_size=(size) ⇒ Object
Set the window’s current size
311 312 313 |
# File 'lib/sdl2/window.rb', line 311 def current_size=(size) SDL2.set_window_size(self, size[0], size[1]) end |
#display ⇒ Object
Get the display associated with this window
221 222 223 |
# File 'lib/sdl2/window.rb', line 221 def display Display[display_index] end |
#display_index ⇒ Object
Get the display index associated with this window
216 217 218 |
# File 'lib/sdl2/window.rb', line 216 def display_index SDL2.get_window_display_index(self) end |
#display_mode ⇒ Object
Get a copy of the DisplayMode structure
205 206 207 208 209 210 211 212 213 |
# File 'lib/sdl2/window.rb', line 205 def display_mode dm = SDL2::Display::Mode.new if SDL2.get_window_display_mode(self, dm) == 0 return dm else dm.pointer.free return nil end end |
#flags ⇒ Object
Get the window flags
226 227 228 |
# File 'lib/sdl2/window.rb', line 226 def flags SDL2.get_window_flags(self) end |
#fullscreen=(flags) ⇒ Object
Set the window’s FULLSCREEN mode flags.
367 368 369 |
# File 'lib/sdl2/window.rb', line 367 def fullscreen=(flags) SDL2.set_window_fullscreen(self, flags) end |
#grab=(value) ⇒ Object
Set the input grab mode
236 237 238 |
# File 'lib/sdl2/window.rb', line 236 def grab=(value) SDL2.set_window_grab(self, value) end |
#grab? ⇒ Boolean
The window’s input grab mode
231 232 233 |
# File 'lib/sdl2/window.rb', line 231 def grab? SDL2.get_window_grab?(self) end |
#hide ⇒ Object
Hide the window
261 262 263 |
# File 'lib/sdl2/window.rb', line 261 def hide SDL2.hide_window(self) end |
#icon=(surface) ⇒ Object
Set the window’s icon from a surface
291 292 293 |
# File 'lib/sdl2/window.rb', line 291 def icon=(surface) set_window_icon(self, surface) end |
#id ⇒ Object
Get the window identifier
241 242 243 |
# File 'lib/sdl2/window.rb', line 241 def id SDL2.get_window_id(self) end |
#maximize ⇒ Object
Maximize the window
266 267 268 |
# File 'lib/sdl2/window.rb', line 266 def maximize SDL2.maximize_window(self) end |
#maximum_size ⇒ Object
Get the window’s maximum_size
317 318 319 320 321 322 |
# File 'lib/sdl2/window.rb', line 317 def maximum_size w_struct, h_struct = IntStruct.new, IntStruct.new SDL2::get_window_maximum_size(self, w_struct, h_struct) w, h = w_struct[:value], h_struct[:value] [w, h] end |
#maximum_size=(size) ⇒ Object
Set the window’s maximum size
326 327 328 |
# File 'lib/sdl2/window.rb', line 326 def maximum_size=(size) SDL2.set_window_maximum_size(self, size[0], size[1]) end |
#minimize ⇒ Object
Minimize the window
271 272 273 |
# File 'lib/sdl2/window.rb', line 271 def minimize SDL2.minimize_window(self) end |
#minimum_size ⇒ Object
Get the window’s minimum size
332 333 334 335 336 337 |
# File 'lib/sdl2/window.rb', line 332 def minimum_size w_struct, h_struct = IntStruct.new, IntStruct.new SDL2::get_window_minimum_size(self, w_struct, h_struct) w, h = w_struct[:value], h_struct[:value] [w, h] end |
#minimum_size=(size) ⇒ Object
Set the window’s minimum size
341 342 343 |
# File 'lib/sdl2/window.rb', line 341 def minimum_size=(size) SDL2.set_window_minimum_size(self, size[0], size[1]) end |
#pixel_format ⇒ Object
Get the window pixel format
246 247 248 |
# File 'lib/sdl2/window.rb', line 246 def pixel_format SDL2.get_window_pixel_format(self) end |
#position ⇒ Object
Get the window’s position
347 348 349 350 351 352 353 |
# File 'lib/sdl2/window.rb', line 347 def position position = [IntStruct.new, IntStruct.new] SDL2::get_window_position(self, position[0], position[1]) x, y = position[0][:value], position[1][:value] position.each(&:free) [x, y] end |
#position=(location) ⇒ Object
Set the window’s position
357 358 359 |
# File 'lib/sdl2/window.rb', line 357 def position=(location) SDL2::set_window_position(self, location[0],location[1]) end |
#raise_above ⇒ Object
Raise the window
276 277 278 |
# File 'lib/sdl2/window.rb', line 276 def raise_above SDL2.raise_window(self) end |
#restore ⇒ Object
Restore the window
281 282 283 |
# File 'lib/sdl2/window.rb', line 281 def restore SDL2.restore_window(self) end |
#show ⇒ Object
Show the window
286 287 288 |
# File 'lib/sdl2/window.rb', line 286 def show SDL2.show_window(self) end |
#surface ⇒ Object
Return the surface associated with the window
362 363 364 |
# File 'lib/sdl2/window.rb', line 362 def surface SDL2.get_window_surface(self) end |
#title ⇒ Object
Get the window title caption
251 252 253 |
# File 'lib/sdl2/window.rb', line 251 def title SDL2.get_window_title(self) end |
#title=(value) ⇒ Object
Set the window title caption
256 257 258 |
# File 'lib/sdl2/window.rb', line 256 def title=(value) SDL2.set_window_title(self, value) end |
#update_surface ⇒ Object
Update the window’s surface
296 297 298 |
# File 'lib/sdl2/window.rb', line 296 def update_surface() SDL2.update_window_surface!(self) end |