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
Methods included from StructHelper
#member_readers, #member_writers
Constructor Details
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(pointer) end |
Instance Method Details
#brightness ⇒ Object
Return the brightness level
189 190 191 |
# File 'lib/sdl2/window.rb', line 189 def brightness SDL2.get_window_brightness(self) end |
#brightness=(level) ⇒ Object
Set the brightness level
194 195 196 |
# File 'lib/sdl2/window.rb', line 194 def brightness=(level) SDL2.set_window_brightness(self, level.to_f) end |
#current_size ⇒ Object
Get the window’s current size
296 297 298 299 300 301 |
# File 'lib/sdl2/window.rb', line 296 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
305 306 307 |
# File 'lib/sdl2/window.rb', line 305 def current_size=(size) SDL2.set_window_size(self, size[0], size[1]) end |
#display ⇒ Object
Get the display associated with this window
215 216 217 |
# File 'lib/sdl2/window.rb', line 215 def display Display[display_index] end |
#display_index ⇒ Object
Get the display index associated with this window
210 211 212 |
# File 'lib/sdl2/window.rb', line 210 def display_index SDL2.get_window_display_index(self) end |
#display_mode ⇒ Object
Get a copy of the DisplayMode structure
199 200 201 202 203 204 205 206 207 |
# File 'lib/sdl2/window.rb', line 199 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
220 221 222 |
# File 'lib/sdl2/window.rb', line 220 def flags SDL2.get_window_flags(self) end |
#fullscreen=(flags) ⇒ Object
Set the window’s FULLSCREEN mode flags.
361 362 363 |
# File 'lib/sdl2/window.rb', line 361 def fullscreen=(flags) SDL2.set_window_fullscreen(self, flags) end |
#grab=(value) ⇒ Object
Set the input grab mode
230 231 232 |
# File 'lib/sdl2/window.rb', line 230 def grab=(value) SDL2.set_window_grab(self, value) end |
#grab? ⇒ Boolean
The window’s input grab mode
225 226 227 |
# File 'lib/sdl2/window.rb', line 225 def grab? SDL2.get_window_grab?(self) end |
#hide ⇒ Object
Hide the window
255 256 257 |
# File 'lib/sdl2/window.rb', line 255 def hide SDL2.hide_window(self) end |
#icon=(surface) ⇒ Object
Set the window’s icon from a surface
285 286 287 |
# File 'lib/sdl2/window.rb', line 285 def icon=(surface) set_window_icon(self, surface) end |
#id ⇒ Object
Get the window identifier
235 236 237 |
# File 'lib/sdl2/window.rb', line 235 def id SDL2.get_window_id(self) end |
#maximize ⇒ Object
Maximize the window
260 261 262 |
# File 'lib/sdl2/window.rb', line 260 def maximize SDL2.maximize_window(self) end |
#maximum_size ⇒ Object
Get the window’s maximum_size
311 312 313 314 315 316 |
# File 'lib/sdl2/window.rb', line 311 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
320 321 322 |
# File 'lib/sdl2/window.rb', line 320 def maximum_size=(size) SDL2.set_window_maximum_size(self, size[0], size[1]) end |
#minimize ⇒ Object
Minimize the window
265 266 267 |
# File 'lib/sdl2/window.rb', line 265 def minimize SDL2.minimize_window(self) end |
#minimum_size ⇒ Object
Get the window’s minimum size
326 327 328 329 330 331 |
# File 'lib/sdl2/window.rb', line 326 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
335 336 337 |
# File 'lib/sdl2/window.rb', line 335 def minimum_size=(size) SDL2.set_window_minimum_size(self, size[0], size[1]) end |
#pixel_format ⇒ Object
Get the window pixel format
240 241 242 |
# File 'lib/sdl2/window.rb', line 240 def pixel_format SDL2.get_window_pixel_format(self) end |
#position ⇒ Object
Get the window’s position
341 342 343 344 345 346 347 |
# File 'lib/sdl2/window.rb', line 341 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{|struct|struct.pointer.free} [x, y] end |
#position=(location) ⇒ Object
Set the window’s position
351 352 353 |
# File 'lib/sdl2/window.rb', line 351 def position=(location) SDL2::set_window_position(self, location[0],location[1]) end |
#raise_above ⇒ Object
Raise the window
270 271 272 |
# File 'lib/sdl2/window.rb', line 270 def raise_above SDL2.raise_window(self) end |
#restore ⇒ Object
Restore the window
275 276 277 |
# File 'lib/sdl2/window.rb', line 275 def restore SDL2.restore_window(self) end |
#show ⇒ Object
Show the window
280 281 282 |
# File 'lib/sdl2/window.rb', line 280 def show SDL2.show_window(self) end |
#surface ⇒ Object
Return the surface associated with the window
356 357 358 |
# File 'lib/sdl2/window.rb', line 356 def surface SDL2.get_window_surface(self) end |
#title ⇒ Object
Get the window title caption
245 246 247 |
# File 'lib/sdl2/window.rb', line 245 def title SDL2.get_window_title(self) end |
#title=(value) ⇒ Object
Set the window title caption
250 251 252 |
# File 'lib/sdl2/window.rb', line 250 def title=(value) SDL2.set_window_title(self, value) end |
#update_surface ⇒ Object
Update the window’s surface
290 291 292 |
# File 'lib/sdl2/window.rb', line 290 def update_surface() SDL2.update_window_surface!(self) end |