Module: RbSDL2::Window::Accessor
- Included in:
- RbSDL2::Window
- Defined in:
- lib/rb_sdl2/window/accessor.rb
Instance Method Summary collapse
- #border_size ⇒ Object
- #height ⇒ Object (also: #h)
- #height=(num) ⇒ Object (also: #h=)
- #icon=(surface) ⇒ Object
- #maximum_size ⇒ Object
- #maximum_size=(w_h) ⇒ Object
- #minimum_size ⇒ Object
- #minimum_size=(w_h) ⇒ Object
-
#mouse_rect ⇒ Object
戻り値が nil の場合は範囲が設定されていません。.
-
#mouse_rect=(rect) ⇒ Object
範囲を破棄する場合は rect には nil を与えます。.
-
#opacity ⇒ Object
ウィンドウの透明度を戻す。値は 0.0 から 1.0。値が低いほど透明になる。.
-
#opacity=(val) ⇒ Object
ウィンドウの透明度を変更する。値は 0.0 から 1.0。値が低いほど透明になる。.
- #position ⇒ Object
- #position=(x_y) ⇒ Object
- #size ⇒ Object
- #size=(w_h) ⇒ Object
- #title ⇒ Object
- #title=(s) ⇒ Object
- #width ⇒ Object (also: #w)
- #width=(num) ⇒ Object (also: #w=)
- #x ⇒ Object
- #x=(num) ⇒ Object
- #y ⇒ Object
- #y=(num) ⇒ Object
Instance Method Details
#border_size ⇒ Object
4 5 6 7 8 9 |
# File 'lib/rb_sdl2/window/accessor.rb', line 4 def border_size top_left_bottom_right = Array.new(4) { ::FFI::MemoryPointer.new(:int) } err = ::SDL.GetWindowBordersSize(self, *top_left_bottom_right) raise RbSDL2Error if err < 0 top_left_bottom_right.map(&:read_int) end |
#height ⇒ Object Also known as: h
11 12 13 14 15 |
# File 'lib/rb_sdl2/window/accessor.rb', line 11 def height ptr = ::FFI::MemoryPointer.new(:int) ::SDL.GetWindowSize(self, nil, ptr) ptr.read_int end |
#height=(num) ⇒ Object Also known as: h=
18 19 20 |
# File 'lib/rb_sdl2/window/accessor.rb', line 18 def height=(num) self.size = [w, num] end |
#icon=(surface) ⇒ Object
23 24 25 |
# File 'lib/rb_sdl2/window/accessor.rb', line 23 def icon=(surface) ::SDL.SetWindowIcon(self, surface) end |
#maximum_size ⇒ Object
27 28 29 30 31 |
# File 'lib/rb_sdl2/window/accessor.rb', line 27 def maximum_size w_h = Array.new(2) { ::FFI::MemoryPointer.new(:int) } ::SDL.GetWindowMaximumSize(self, *w_h) w_h.map(&:read_int) end |
#maximum_size=(w_h) ⇒ Object
33 34 35 |
# File 'lib/rb_sdl2/window/accessor.rb', line 33 def maximum_size=(w_h) ::SDL.SetWindowMaximumSize(self, *w_h) end |
#minimum_size ⇒ Object
37 38 39 40 41 |
# File 'lib/rb_sdl2/window/accessor.rb', line 37 def minimum_size w_h = Array.new(2) { ::FFI::MemoryPointer.new(:int) } ::SDL.GetWindowMinimumSize(self, *w_h) w_h.map(&:read_int) end |
#minimum_size=(w_h) ⇒ Object
43 44 45 |
# File 'lib/rb_sdl2/window/accessor.rb', line 43 def minimum_size=(w_h) ::SDL.SetWindowMinimumSize(self, *w_h) end |
#mouse_rect ⇒ Object
戻り値が nil の場合は範囲が設定されていません。
48 49 50 51 |
# File 'lib/rb_sdl2/window/accessor.rb', line 48 def mouse_rect ptr = ::SDL.GetWindowMouseRect(self) ptr.null? ? nil : Rect.to_ary(ptr) end |
#mouse_rect=(rect) ⇒ Object
範囲を破棄する場合は rect には nil を与えます。
54 55 56 57 |
# File 'lib/rb_sdl2/window/accessor.rb', line 54 def mouse_rect=(rect) err = ::SDL.SetWindowMouseRect(self, rect && Rect.new(*rect)) raise RbSDL2Error if err < 0 end |
#opacity ⇒ Object
ウィンドウの透明度を戻す。値は 0.0 から 1.0。値が低いほど透明になる。
60 61 62 63 64 65 |
# File 'lib/rb_sdl2/window/accessor.rb', line 60 def opacity out_opacity = ::FFI::MemoryPointer.new(:float) err = ::SDL.GetWindowOpacity(self, out_opacity) raise RbSDL2Error if err < 0 out_opacity.read_float end |
#opacity=(val) ⇒ Object
ウィンドウの透明度を変更する。値は 0.0 から 1.0。値が低いほど透明になる。
68 69 70 71 |
# File 'lib/rb_sdl2/window/accessor.rb', line 68 def opacity=(val) err = ::SDL.SetWindowOpacity(self, val) raise RbSDL2Error if err < 0 end |
#position ⇒ Object
73 74 75 76 77 |
# File 'lib/rb_sdl2/window/accessor.rb', line 73 def position x_y = Array.new(2) { ::FFI::MemoryPointer.new(:int) } ::SDL.GetWindowPosition(self, *x_y) x_y.map(&:read_int) end |
#position=(x_y) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/rb_sdl2/window/accessor.rb', line 79 def position=(x_y) wx, wy = x_y ::SDL.SetWindowPosition(self, wx || SDL_WINDOWPOS_CENTERED_MASK, wy || SDL_WINDOWPOS_CENTERED_MASK) end |
#size ⇒ Object
86 87 88 89 90 |
# File 'lib/rb_sdl2/window/accessor.rb', line 86 def size w_h = Array.new(2) { ::FFI::MemoryPointer.new(:int) } ::SDL.GetWindowSize(self, *w_h) w_h.map(&:read_int) end |
#size=(w_h) ⇒ Object
92 93 94 |
# File 'lib/rb_sdl2/window/accessor.rb', line 92 def size=(w_h) ::SDL.SetWindowSize(self, *w_h) end |
#title ⇒ Object
96 |
# File 'lib/rb_sdl2/window/accessor.rb', line 96 def title = SDL.ptr_to_str(::SDL.GetWindowTitle(self)) |
#title=(s) ⇒ Object
98 99 100 |
# File 'lib/rb_sdl2/window/accessor.rb', line 98 def title=(s) ::SDL.SetWindowTitle(self, SDL.str_to_sdl(s)) end |
#width ⇒ Object Also known as: w
102 103 104 105 106 |
# File 'lib/rb_sdl2/window/accessor.rb', line 102 def width ptr = ::FFI::MemoryPointer.new(:int) ::SDL.GetWindowSize(self, ptr, nil) ptr.read_int end |
#width=(num) ⇒ Object Also known as: w=
109 110 111 |
# File 'lib/rb_sdl2/window/accessor.rb', line 109 def width=(num) self.size = [num, h] end |
#x ⇒ Object
114 115 116 117 118 |
# File 'lib/rb_sdl2/window/accessor.rb', line 114 def x ptr = ::FFI::MemoryPointer.new(:int) ::SDL.GetWindowPosition(self, ptr, nil) ptr.read_int end |
#x=(num) ⇒ Object
120 121 122 |
# File 'lib/rb_sdl2/window/accessor.rb', line 120 def x=(num) self.position = [num, y] end |
#y ⇒ Object
124 125 126 127 128 |
# File 'lib/rb_sdl2/window/accessor.rb', line 124 def y ptr = ::FFI::MemoryPointer.new(:int) ::SDL.GetWindowPosition(self, nil, ptr) ptr.read_int end |
#y=(num) ⇒ Object
130 131 132 |
# File 'lib/rb_sdl2/window/accessor.rb', line 130 def y=(num) self.position = [x, num] end |