rb_sdl2 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +1 -1
- data/lib/rb_sdl2/audio/audio.rb +162 -0
- data/lib/rb_sdl2/audio/audio_buffer.rb +12 -19
- data/lib/rb_sdl2/audio/audio_device.rb +17 -23
- data/lib/rb_sdl2/audio/audio_spec.rb +38 -6
- data/lib/rb_sdl2/audio/audio_spec_reader.rb +10 -0
- data/lib/rb_sdl2/clipboard.rb +31 -31
- data/lib/rb_sdl2/cpu_info.rb +34 -17
- data/lib/rb_sdl2/cursor.rb +105 -24
- data/lib/rb_sdl2/display.rb +16 -16
- data/lib/rb_sdl2/display_mode.rb +1 -1
- data/lib/rb_sdl2/error.rb +11 -4
- data/lib/rb_sdl2/errors.rb +7 -0
- data/lib/rb_sdl2/event/event.rb +130 -0
- data/lib/rb_sdl2/event/event_filter.rb +34 -70
- data/lib/rb_sdl2/event/event_pointer.rb +26 -0
- data/lib/rb_sdl2/event/event_queue.rb +97 -120
- data/lib/rb_sdl2/event/event_type.rb +147 -205
- data/lib/rb_sdl2/filesystem.rb +8 -9
- data/lib/rb_sdl2/hint.rb +26 -24
- data/lib/rb_sdl2/keyboard/keyboard.rb +50 -0
- data/lib/rb_sdl2/keyboard/mod_state.rb +68 -0
- data/lib/rb_sdl2/keyboard/state.rb +39 -0
- data/lib/rb_sdl2/message_box.rb +69 -102
- data/lib/rb_sdl2/mouse/global_mouse.rb +10 -3
- data/lib/rb_sdl2/mouse/mouse.rb +64 -0
- data/lib/rb_sdl2/mouse/mouse_button.rb +13 -11
- data/lib/rb_sdl2/mouse/mouse_class.rb +9 -17
- data/lib/rb_sdl2/mouse/mouse_wheel.rb +21 -37
- data/lib/rb_sdl2/mouse/relative_mouse.rb +15 -1
- data/lib/rb_sdl2/palette.rb +12 -12
- data/lib/rb_sdl2/pixel_format_enum.rb +87 -55
- data/lib/rb_sdl2/platform.rb +1 -1
- data/lib/rb_sdl2/power_info.rb +34 -23
- data/lib/rb_sdl2/rect.rb +7 -1
- data/lib/rb_sdl2/ref_count_pointer.rb +25 -10
- data/lib/rb_sdl2/rw_ops/rw_file.rb +19 -0
- data/lib/rb_sdl2/rw_ops/rw_memory.rb +18 -0
- data/lib/rb_sdl2/rw_ops/rw_object.rb +126 -0
- data/lib/rb_sdl2/rw_ops/rw_ops.rb +104 -0
- data/lib/rb_sdl2/rw_ops/rw_ops_pointer.rb +14 -0
- data/lib/rb_sdl2/sdl.rb +67 -28
- data/lib/rb_sdl2/sdl_pointer.rb +22 -0
- data/lib/rb_sdl2/surface/blend_mode.rb +41 -41
- data/lib/rb_sdl2/surface/pixel_format.rb +34 -33
- data/lib/rb_sdl2/surface.rb +280 -265
- data/lib/rb_sdl2/text_input.rb +21 -15
- data/lib/rb_sdl2/timer.rb +36 -31
- data/lib/rb_sdl2/version.rb +3 -3
- data/lib/rb_sdl2/video.rb +17 -5
- data/lib/rb_sdl2/window/accessor.rb +135 -0
- data/lib/rb_sdl2/window/display.rb +8 -8
- data/lib/rb_sdl2/window/flash.rb +22 -0
- data/lib/rb_sdl2/window/hit_test.rb +22 -43
- data/lib/rb_sdl2/window/shape.rb +55 -40
- data/lib/rb_sdl2/window/state.rb +178 -0
- data/lib/rb_sdl2/window/window.rb +149 -0
- data/lib/rb_sdl2.rb +79 -17
- data/rb_sdl2.gemspec +4 -4
- metadata +31 -35
- data/lib/rb_sdl2/audio/audio_allowed_changes.rb +0 -17
- data/lib/rb_sdl2/audio/audio_format.rb +0 -23
- data/lib/rb_sdl2/audio.rb +0 -132
- data/lib/rb_sdl2/cursor/color_cursor.rb +0 -19
- data/lib/rb_sdl2/cursor/cursor_class.rb +0 -24
- data/lib/rb_sdl2/cursor/cursor_pointer.rb +0 -12
- data/lib/rb_sdl2/cursor/default_cursor.rb +0 -18
- data/lib/rb_sdl2/cursor/system_cursor.rb +0 -45
- data/lib/rb_sdl2/event.rb +0 -161
- data/lib/rb_sdl2/keyboard/key_mod.rb +0 -37
- data/lib/rb_sdl2/keyboard/keyboard_state.rb +0 -34
- data/lib/rb_sdl2/keyboard.rb +0 -50
- data/lib/rb_sdl2/mouse/window_mouse.rb +0 -17
- data/lib/rb_sdl2/mouse.rb +0 -74
- data/lib/rb_sdl2/rw_ops/rw_operator.rb +0 -105
- data/lib/rb_sdl2/rw_ops.rb +0 -149
- data/lib/rb_sdl2/screen_saver.rb +0 -11
- data/lib/rb_sdl2/window/dialog.rb +0 -19
- data/lib/rb_sdl2/window/grab.rb +0 -23
- data/lib/rb_sdl2/window/position.rb +0 -38
- data/lib/rb_sdl2/window/size.rb +0 -59
- data/lib/rb_sdl2/window/window_flags.rb +0 -78
- data/lib/rb_sdl2/window.rb +0 -242
@@ -1,105 +0,0 @@
|
|
1
|
-
module RbSDL2
|
2
|
-
class RWOperator
|
3
|
-
# コールバック関数からの例外は全てコールバック中で拾いエラーを表す戻り値に変える。
|
4
|
-
# SDL がコールバック関数を呼び出すときに与える引数はチェックされていないことを前提とするべきである。
|
5
|
-
# SDL が期待するコールバック関数の戻り値は成功か失敗(エラー)かであり、
|
6
|
-
# read, write などの戻り値を考慮した動作を行わない。
|
7
|
-
# コールバック関数を実装する際には Ruby アプリケーションが困らない設計を行えばよい。
|
8
|
-
|
9
|
-
class CloseCallback < ::FFI::Function
|
10
|
-
def initialize(obj)
|
11
|
-
# int (* close) (struct SDL_RWops * context);
|
12
|
-
super(:int, [:pointer]) do |_context|
|
13
|
-
# close の際に _context ポインターを開放してはならない。ポインターは GC が管理する。
|
14
|
-
(obj.close; 0) rescue -1
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class ReadCallback < ::FFI::Function
|
20
|
-
def initialize(obj)
|
21
|
-
# size_t (* read) (struct SDL_RWops * context, void *ptr, size_t size, size_t maxnum);
|
22
|
-
super(:size_t, [:pointer, :pointer, :size_t, :size_t]) do |_context, ptr, size, max_num|
|
23
|
-
return 0 if ptr.null?
|
24
|
-
max = size * max_num
|
25
|
-
str = obj.read(max)
|
26
|
-
len = str.size
|
27
|
-
# len > max は obj.read が壊れている。
|
28
|
-
return 0 if str.nil? || len > max
|
29
|
-
ptr.write_bytes(str, 0, len)
|
30
|
-
len / size
|
31
|
-
rescue
|
32
|
-
0
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class SeekCallback < ::FFI::Function
|
38
|
-
def initialize(obj)
|
39
|
-
# Sint64 (* seek) (struct SDL_RWops * context, Sint64 offset, int whence);
|
40
|
-
super(:int64, [:pointer, :int64, :int]) do |_context, offset, whence|
|
41
|
-
obj.seek(offset, whence) rescue -1
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class SizeCallback < ::FFI::Function
|
47
|
-
def initialize(obj)
|
48
|
-
# Sint64 (* size) (struct SDL_RWops * context);
|
49
|
-
super(:int64, [:pointer]) do |_context|
|
50
|
-
# 不明な時は -1。Ruby では size が不明確なオブジェクトは size メソッドがないだろう。
|
51
|
-
obj.size rescue -1
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class WriteCallback < ::FFI::Function
|
57
|
-
def initialize(obj)
|
58
|
-
# size_t (* write) (struct SDL_RWops * context, const void *ptr, size_t size, size_t num);
|
59
|
-
super(:size_t, [:pointer, :pointer, :size_t, :size_t]) do |_context, ptr, size, max_num|
|
60
|
-
return 0 if ptr.null?
|
61
|
-
obj.write(ptr.read_bytes(size * max_num)) / size rescue 0
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
class RWOperatorPointer < RWOps::RWOpsPointer
|
67
|
-
class << self
|
68
|
-
def release(ptr)
|
69
|
-
# オブジェクトはクローズしない。(GC 回収の時には close コールバックオブジェクトは消えている)
|
70
|
-
# SDL_AllocRW で確保したポインターのみ SDL_FreeRW で開放できる。
|
71
|
-
::SDL2.SDL_FreeRW(ptr)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class << self
|
77
|
-
# obj は Ruby IO と同じようにふるまうことを期待している。
|
78
|
-
# obj に対して close, seek, size, read, write のメソッドを呼び出す。
|
79
|
-
# メソッドの呼び出し引数は Ruby IO と同様である。
|
80
|
-
# メソッドの戻り値は Ruby IO と同じ値を返せばよい。
|
81
|
-
# メソッド内での例外は SDL のエラーに変換され、Ruby 側には反映されない。
|
82
|
-
# obj がメソッド呼び出しに応答しない場合も安全である。その場合は SDL 側にエラーが通知される。
|
83
|
-
def new(obj)
|
84
|
-
ptr = RWOperatorPointer.new(::SDL2.SDL_AllocRW)
|
85
|
-
raise RbSDL2Error if ptr.null?
|
86
|
-
super(ptr, obj)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def initialize(ptr, obj)
|
91
|
-
@obj = obj
|
92
|
-
@st = ::SDL2::SDL_RWops.new(ptr).tap do |st|
|
93
|
-
st[:close] = @close = CloseCallback.new(obj)
|
94
|
-
st[:read] = @read = ReadCallback.new(obj)
|
95
|
-
st[:seek] = @seek = SeekCallback.new(obj)
|
96
|
-
st[:size] = @size = SizeCallback.new(obj)
|
97
|
-
st[:write] = @write = WriteCallback.new(obj)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def __getobj__ = @obj
|
102
|
-
|
103
|
-
def to_ptr = @st.to_ptr
|
104
|
-
end
|
105
|
-
end
|
data/lib/rb_sdl2/rw_ops.rb
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
module RbSDL2
|
2
|
-
class RWOps
|
3
|
-
class RWOpsPointer < ::FFI::AutoPointer
|
4
|
-
class << self
|
5
|
-
def release(ptr)
|
6
|
-
# SDL_RWclose は RWOps構造体を開放する。そのため呼び出しは1回しかできない。
|
7
|
-
# ::FFI::AutoPointer を使うことで2重開放を防ぐ。
|
8
|
-
err = ::SDL2.SDL_RWclose(ptr)
|
9
|
-
raise RbSDL2Error if err < 0
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def free
|
14
|
-
@released = true
|
15
|
-
super
|
16
|
-
end
|
17
|
-
|
18
|
-
def released? = @released
|
19
|
-
end
|
20
|
-
|
21
|
-
# マルチスレッド対応はしていない。
|
22
|
-
# close メソッドは SDL 側からクローズされていた場合に対応していない。
|
23
|
-
class << self
|
24
|
-
def from_memory(mem, size, autoclose: true, readonly: true)
|
25
|
-
ptr = if readonly
|
26
|
-
::SDL2.SDL_RWFromConstMem(mem, size)
|
27
|
-
else
|
28
|
-
::SDL2.SDL_RWFromMem(mem, size)
|
29
|
-
end
|
30
|
-
ptr = RWOpsPointer.new(ptr)
|
31
|
-
raise RbSDL2Error if ptr.null?
|
32
|
-
ptr.autorelease = autoclose
|
33
|
-
obj = allocate
|
34
|
-
obj.__send__(:initialize, ptr, mem)
|
35
|
-
if block_given?
|
36
|
-
begin
|
37
|
-
yield(obj)
|
38
|
-
ensure
|
39
|
-
obj.close
|
40
|
-
end
|
41
|
-
else
|
42
|
-
obj
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# mode は一般的なファイルAPIと同じ文字列が使用できる。
|
47
|
-
def new(file, _mode = "rb", autoclose: true, mode: _mode)
|
48
|
-
ptr = RWOpsPointer.new(::SDL2.SDL_RWFromFile(file.to_s, mode))
|
49
|
-
raise RbSDL2Error if ptr.null?
|
50
|
-
ptr.autorelease = autoclose
|
51
|
-
obj = super(ptr, file)
|
52
|
-
if block_given?
|
53
|
-
begin
|
54
|
-
yield(obj)
|
55
|
-
ensure
|
56
|
-
obj.close
|
57
|
-
end
|
58
|
-
else
|
59
|
-
obj
|
60
|
-
end
|
61
|
-
end
|
62
|
-
alias open new
|
63
|
-
|
64
|
-
require_relative 'rw_ops/rw_operator'
|
65
|
-
|
66
|
-
# io 引数には Ruby の IO オブジェクトのように振る舞うオブジェクトを与える。
|
67
|
-
# オブジェクトは自動的にクローズされない。(close が呼ばれた場合はクローズする)
|
68
|
-
# autoclose オプション引数に false を与えて、RWOps#to_ptr から取り出したポインターを
|
69
|
-
# C のスコープへ渡す場合、ポインターが利用されている間 RWOps オブジェクトを生存させる必要がある。
|
70
|
-
def with_object(io, autoclose: true)
|
71
|
-
rw = RWOperator.new(io)
|
72
|
-
ptr = rw.to_ptr
|
73
|
-
ptr.autorelease = autoclose
|
74
|
-
obj = allocate
|
75
|
-
obj.__send__(:initialize, ptr, rw)
|
76
|
-
if block_given?
|
77
|
-
begin
|
78
|
-
yield(obj)
|
79
|
-
ensure
|
80
|
-
obj.close
|
81
|
-
end
|
82
|
-
else
|
83
|
-
obj
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def initialize(ptr, obj = nil)
|
89
|
-
@obj = obj
|
90
|
-
@ptr = ptr
|
91
|
-
end
|
92
|
-
|
93
|
-
def autoclose=(bool)
|
94
|
-
@ptr.autorelease = bool
|
95
|
-
end
|
96
|
-
|
97
|
-
def autoclose? = @ptr.autorelease?
|
98
|
-
|
99
|
-
def close = @ptr.free
|
100
|
-
|
101
|
-
def closed? = @ptr.released?
|
102
|
-
|
103
|
-
def inspect
|
104
|
-
"#<#{self.class.name}:#{@obj.inspect}>"
|
105
|
-
end
|
106
|
-
|
107
|
-
def read(length = nil)
|
108
|
-
raise IOError if closed?
|
109
|
-
len = length.nil? ? size : length.to_i
|
110
|
-
raise ArgumentError if len < 0
|
111
|
-
return "" if len == 0
|
112
|
-
ptr = ::FFI::MemoryPointer.new(len)
|
113
|
-
num = ::SDL2.SDL_RWread(self, ptr, 1, len)
|
114
|
-
raise RbSDL2Error if num == 0
|
115
|
-
ptr.read_bytes(num)
|
116
|
-
end
|
117
|
-
|
118
|
-
def seek(offset, whence = IO::SEEK_SET)
|
119
|
-
raise IOError if closed?
|
120
|
-
raise RbSDL2Error if ::SDL2.SDL_RWseek(self, offset, whence) == -1
|
121
|
-
0
|
122
|
-
end
|
123
|
-
|
124
|
-
def size
|
125
|
-
raise IOError if closed?
|
126
|
-
num = ::SDL2.SDL_RWsize(self)
|
127
|
-
raise RbSDL2Error if num < 0
|
128
|
-
num
|
129
|
-
end
|
130
|
-
|
131
|
-
def to_ptr
|
132
|
-
raise IOError if closed?
|
133
|
-
@ptr
|
134
|
-
end
|
135
|
-
|
136
|
-
def write(*str)
|
137
|
-
raise FrozenError if frozen?
|
138
|
-
raise IOError if closed?
|
139
|
-
str.inject(0) do |sum, obj|
|
140
|
-
bytes = obj.to_s
|
141
|
-
len = bytes.size
|
142
|
-
ptr = ::FFI::MemoryPointer.new(len).write_bytes(bytes)
|
143
|
-
num = ::SDL2.SDL_RWwrite(self, ptr, 1, len)
|
144
|
-
raise RbSDL2Error if num < len
|
145
|
-
sum + len
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
data/lib/rb_sdl2/screen_saver.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module RbSDL2
|
2
|
-
class Window
|
3
|
-
module Dialog
|
4
|
-
require_relative '../message_box'
|
5
|
-
|
6
|
-
def alert(message, **opts) = MessageBox.alert(message, self, **opts)
|
7
|
-
|
8
|
-
def confirm(message, **opts) = MessageBox.confirm(message, self, **opts)
|
9
|
-
|
10
|
-
def dialog(message, **opts) = MessageBox.dialog(message, self, **opts)
|
11
|
-
|
12
|
-
def error_alert(message, **opts) = MessageBox.error(message, self, **opts)
|
13
|
-
|
14
|
-
def info_alert(message, **opts) = MessageBox.info(message, self, **opts)
|
15
|
-
|
16
|
-
def warn_alert(message, **opts) = MessageBox.warn(message, self, **opts)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/rb_sdl2/window/grab.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module RbSDL2
|
2
|
-
class Window
|
3
|
-
module Grab
|
4
|
-
def grab=(bool)
|
5
|
-
::SDL2.SDL_SetWindowGrab(self, bool ? ::SDL2::SDL_TRUE : ::SDL2::SDL_FALSE)
|
6
|
-
end
|
7
|
-
|
8
|
-
def grabbed? = ::SDL2.SDL_GetWindowGrab(self) == ::SDL2::SDL_TRUE
|
9
|
-
|
10
|
-
def grabbed_keyboard? = ::SDL2.SDL_GetWindowKeyboardGrab(self) == ::SDL2::SDL_TRUE
|
11
|
-
|
12
|
-
def grabbed_mouse? = ::SDL2.SDL_GetWindowMouseGrab(self) == ::SDL2::SDL_TRUE
|
13
|
-
|
14
|
-
def keyboard_grab=(bool)
|
15
|
-
::SDL2.SDL_SetWindowKeyboardGrab(self, bool ? ::SDL2::SDL_TRUE : ::SDL2::SDL_FALSE)
|
16
|
-
end
|
17
|
-
|
18
|
-
def mouse_grab=(bool)
|
19
|
-
::SDL2.SDL_SetWindowMouseGrab(self, bool ? ::SDL2::SDL_TRUE : ::SDL2::SDL_FALSE)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module RbSDL2
|
2
|
-
class Window
|
3
|
-
module Position
|
4
|
-
def position
|
5
|
-
x_y = Array.new(2) { ::FFI::MemoryPointer.new(:int) }
|
6
|
-
::SDL2.SDL_GetWindowPosition(self, *x_y)
|
7
|
-
x_y.map(&:read_int)
|
8
|
-
end
|
9
|
-
|
10
|
-
def position=(x_y)
|
11
|
-
wx, wy = x_y
|
12
|
-
wx ||= ::SDL2::SDL_WINDOWPOS_CENTERED_MASK
|
13
|
-
wy ||= ::SDL2::SDL_WINDOWPOS_CENTERED_MASK
|
14
|
-
::SDL2.SDL_SetWindowPosition(self, wx, wy)
|
15
|
-
end
|
16
|
-
|
17
|
-
def x
|
18
|
-
ptr = ::FFI::MemoryPointer.new(:int)
|
19
|
-
::SDL2.SDL_GetWindowPosition(self, ptr, nil)
|
20
|
-
ptr.read_int
|
21
|
-
end
|
22
|
-
|
23
|
-
def x=(num)
|
24
|
-
self.position = [num, y]
|
25
|
-
end
|
26
|
-
|
27
|
-
def y
|
28
|
-
ptr = ::FFI::MemoryPointer.new(:int)
|
29
|
-
::SDL2.SDL_GetWindowPosition(self, nil, ptr)
|
30
|
-
ptr.read_int
|
31
|
-
end
|
32
|
-
|
33
|
-
def y=(num)
|
34
|
-
self.position = [x, num]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/lib/rb_sdl2/window/size.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
module RbSDL2
|
2
|
-
class Window
|
3
|
-
module Size
|
4
|
-
def height
|
5
|
-
ptr = ::FFI::MemoryPointer.new(:int)
|
6
|
-
::SDL2.SDL_GetWindowSize(self, nil, ptr)
|
7
|
-
ptr.read_int
|
8
|
-
end
|
9
|
-
alias h height
|
10
|
-
|
11
|
-
def height=(num)
|
12
|
-
self.size = [w, num]
|
13
|
-
end
|
14
|
-
alias h= height=
|
15
|
-
|
16
|
-
def maximum_size
|
17
|
-
w_h = Array.new(2) { ::FFI::MemoryPointer.new(:int) }
|
18
|
-
::SDL2.SDL_GetWindowMaximumSize(self, *w_h)
|
19
|
-
w_h.map(&:read_int)
|
20
|
-
end
|
21
|
-
|
22
|
-
def maximum_size=(w_h)
|
23
|
-
::SDL2.SDL_SetWindowMaximumSize(self, *w_h)
|
24
|
-
end
|
25
|
-
|
26
|
-
def minimum_size
|
27
|
-
w_h = Array.new(2) { ::FFI::MemoryPointer.new(:int) }
|
28
|
-
::SDL2.SDL_GetWindowMinimumSize(self, *w_h)
|
29
|
-
w_h.map(&:read_int)
|
30
|
-
end
|
31
|
-
|
32
|
-
def minimum_size=(w_h)
|
33
|
-
::SDL2.SDL_SetWindowMinimumSize(self, *w_h)
|
34
|
-
end
|
35
|
-
|
36
|
-
def size
|
37
|
-
w_h = Array.new(2) { ::FFI::MemoryPointer.new(:int) }
|
38
|
-
::SDL2.SDL_GetWindowSize(self, *w_h)
|
39
|
-
w_h.map(&:read_int)
|
40
|
-
end
|
41
|
-
|
42
|
-
def size=(w_h)
|
43
|
-
::SDL2.SDL_SetWindowSize(self, *w_h)
|
44
|
-
end
|
45
|
-
|
46
|
-
def width
|
47
|
-
ptr = ::FFI::MemoryPointer.new(:int)
|
48
|
-
::SDL2.SDL_GetWindowSize(self, ptr, nil)
|
49
|
-
ptr.read_int
|
50
|
-
end
|
51
|
-
alias w width
|
52
|
-
|
53
|
-
def width=(num)
|
54
|
-
self.size = [num, h]
|
55
|
-
end
|
56
|
-
alias w= width=
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
module RbSDL2
|
2
|
-
class Window
|
3
|
-
module WindowFlags
|
4
|
-
class << self
|
5
|
-
def to_num(allow_high_dpi: false, always_on_top: false, borderless: false, foreign: false,
|
6
|
-
fullscreen: false, fullscreen_desktop: false, hidden: false, input_focus: false,
|
7
|
-
input_grabbed: false, maximized: false, minimized: false, mouse_capture: false,
|
8
|
-
mouse_focus: false, opengl: false, popup_menu: false, resizable: false,
|
9
|
-
shown: false, skip_taskbar: false, tooltip: false, utility: false, vulkan: false)
|
10
|
-
0 |
|
11
|
-
(allow_high_dpi ? ::SDL2::SDL_WINDOW_ALLOW_HIGHDPI : 0) |
|
12
|
-
(always_on_top ? ::SDL2::SDL_WINDOW_ALWAYS_ON_TOP : 0) |
|
13
|
-
(borderless ? ::SDL2::SDL_WINDOW_BORDERLESS : 0) |
|
14
|
-
(foreign ? ::SDL2::SDL_WINDOW_FOREIGN : 0) |
|
15
|
-
(fullscreen ? ::SDL2::SDL_WINDOW_FULLSCREEN : 0) |
|
16
|
-
(fullscreen_desktop ? ::SDL2::SDL_WINDOW_FULLSCREEN_DESKTOP : 0) |
|
17
|
-
(hidden ? ::SDL2::SDL_WINDOW_HIDDEN : 0) |
|
18
|
-
(input_focus ? ::SDL2::SDL_WINDOW_INPUT_FOCUS : 0) |
|
19
|
-
(input_grabbed ? ::SDL2::SDL_WINDOW_INPUT_GRABBED : 0) |
|
20
|
-
(maximized ? ::SDL2::SDL_WINDOW_MAXIMIZED : 0) |
|
21
|
-
(minimized ? ::SDL2::SDL_WINDOW_MINIMIZED : 0) |
|
22
|
-
(mouse_capture ? ::SDL2::SDL_WINDOW_MOUSE_CAPTURE : 0) |
|
23
|
-
(mouse_focus ? ::SDL2::SDL_WINDOW_MOUSE_FOCUS : 0) |
|
24
|
-
(opengl ? ::SDL2::SDL_WINDOW_OPENGL : 0) |
|
25
|
-
(popup_menu ? ::SDL2::SDL_WINDOW_POPUP_MENU : 0) |
|
26
|
-
(resizable ? ::SDL2::SDL_WINDOW_RESIZABLE : 0) |
|
27
|
-
(shown ? ::SDL2::SDL_WINDOW_SHOWN : 0) |
|
28
|
-
(skip_taskbar ? ::SDL2::SDL_WINDOW_SKIP_TASKBAR : 0) |
|
29
|
-
(tooltip ? ::SDL2::SDL_WINDOW_TOOLTIP : 0) |
|
30
|
-
(utility ? ::SDL2::SDL_WINDOW_UTILITY : 0) |
|
31
|
-
(vulkan ? ::SDL2::SDL_WINDOW_VULKAN : 0)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def allow_high_dpi? = ::SDL2::SDL_WINDOW_ALLOW_HIGHDPI & flags != 0
|
36
|
-
|
37
|
-
def always_on_top? = ::SDL2::SDL_WINDOW_ALWAYS_ON_TOP & flags != 0
|
38
|
-
|
39
|
-
def borderless? = ::SDL2::SDL_WINDOW_BORDERLESS & flags != 0
|
40
|
-
|
41
|
-
def foreign? = ::SDL2::SDL_WINDOW_FOREIGN & flags != 0
|
42
|
-
|
43
|
-
def fullscreen? = ::SDL2::SDL_WINDOW_FULLSCREEN & flags != 0
|
44
|
-
|
45
|
-
def fullscreen_desktop? = ::SDL2::SDL_WINDOW_FULLSCREEN_DESKTOP & flags != 0
|
46
|
-
|
47
|
-
def hidden? = ::SDL2::SDL_WINDOW_HIDDEN & flags != 0
|
48
|
-
|
49
|
-
def input_focused? = ::SDL2::SDL_WINDOW_INPUT_FOCUS & flags != 0
|
50
|
-
|
51
|
-
def input_grabbed? = ::SDL2::SDL_WINDOW_INPUT_GRABBED & flags != 0
|
52
|
-
|
53
|
-
def maximized? = ::SDL2::SDL_WINDOW_MAXIMIZED & flags != 0
|
54
|
-
|
55
|
-
def minimized? = ::SDL2::SDL_WINDOW_MINIMIZED & flags != 0
|
56
|
-
|
57
|
-
def mouse_captured? = ::SDL2::SDL_WINDOW_MOUSE_CAPTURE & flags != 0
|
58
|
-
|
59
|
-
def mouse_focused? = ::SDL2::SDL_WINDOW_MOUSE_FOCUS & flags != 0
|
60
|
-
|
61
|
-
def opengl? = ::SDL2::SDL_WINDOW_OPENGL & flags != 0
|
62
|
-
|
63
|
-
def popup_menu? = ::SDL2::SDL_WINDOW_POPUP_MENU & flags != 0
|
64
|
-
|
65
|
-
def resizable? = ::SDL2::SDL_WINDOW_RESIZABLE & flags != 0
|
66
|
-
|
67
|
-
def skip_taskbar? = ::SDL2::SDL_WINDOW_SKIP_TASKBAR & flags != 0
|
68
|
-
|
69
|
-
def shown? = ::SDL2::SDL_WINDOW_SHOWN & flags != 0
|
70
|
-
|
71
|
-
def tooltip? = ::SDL2::SDL_WINDOW_TOOLTIP & flags != 0
|
72
|
-
|
73
|
-
def utility? = ::SDL2::SDL_WINDOW_UTILITY & flags != 0
|
74
|
-
|
75
|
-
def vulkan? = ::SDL2::SDL_WINDOW_VULKAN & flags != 0
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|