reflexion 0.1.15 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/capture_event.cpp +4 -5
- data/.doc/ext/reflex/contact_event.cpp +4 -7
- data/.doc/ext/reflex/draw_event.cpp +3 -4
- data/.doc/ext/reflex/frame_event.cpp +7 -8
- data/.doc/ext/reflex/key_event.cpp +7 -8
- data/.doc/ext/reflex/motion_event.cpp +3 -5
- data/.doc/ext/reflex/pointer_event.cpp +23 -14
- data/.doc/ext/reflex/scroll_event.cpp +8 -9
- data/.doc/ext/reflex/update_event.cpp +4 -5
- data/.doc/ext/reflex/wheel_event.cpp +5 -6
- data/.doc/ext/reflex/window.cpp +17 -0
- data/VERSION +1 -1
- data/ext/reflex/capture_event.cpp +3 -4
- data/ext/reflex/contact_event.cpp +3 -6
- data/ext/reflex/draw_event.cpp +2 -3
- data/ext/reflex/frame_event.cpp +6 -7
- data/ext/reflex/key_event.cpp +6 -7
- data/ext/reflex/motion_event.cpp +2 -4
- data/ext/reflex/pointer_event.cpp +22 -13
- data/ext/reflex/scroll_event.cpp +8 -9
- data/ext/reflex/update_event.cpp +3 -4
- data/ext/reflex/wheel_event.cpp +4 -5
- data/ext/reflex/window.cpp +19 -0
- data/include/reflex/event.h +15 -15
- data/include/reflex/exception.h +9 -3
- data/include/reflex/ruby/event.h +11 -11
- data/include/reflex/window.h +4 -0
- data/lib/reflex.rb +2 -1
- data/lib/reflex/camera.rb +13 -0
- data/lib/reflex/pointer_event.rb +4 -0
- data/lib/reflex/window.rb +2 -1
- data/reflex.gemspec +4 -4
- data/samples/camera.rb +45 -0
- data/src/event.cpp +7 -7
- data/src/ios/view_controller.mm +1 -1
- data/src/ios/window.mm +18 -0
- data/src/osx/native_window.mm +1 -1
- data/src/osx/window.mm +22 -0
- data/src/timer.cpp +3 -6
- data/src/window.cpp +13 -1
- data/src/window.h +6 -0
- data/test/test_pointer_event.rb +79 -34
- data/test/test_window.rb +17 -0
- metadata +15 -13
data/ext/reflex/key_event.cpp
CHANGED
@@ -19,16 +19,15 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
19
19
|
RUCY_END
|
20
20
|
|
21
21
|
static
|
22
|
-
|
22
|
+
RUCY_DEF5(initialize, type, chars, code, repeat, modifiers)
|
23
23
|
{
|
24
24
|
CHECK;
|
25
|
-
check_arg_count(__FILE__, __LINE__, "KeyEvent#initialize", argc, 0, 1, 2, 3, 4, 5);
|
26
25
|
|
27
|
-
THIS->type = (
|
28
|
-
THIS->chars =
|
29
|
-
THIS->code =
|
30
|
-
THIS->repeat =
|
31
|
-
THIS->modifiers =
|
26
|
+
THIS->type = (Reflex::KeyEvent::Type) to<int>(type);
|
27
|
+
THIS->chars = chars.c_str();
|
28
|
+
THIS->code = to<int>(code);
|
29
|
+
THIS->repeat = to<int>(repeat);
|
30
|
+
THIS->modifiers = to<uint>(modifiers);
|
32
31
|
|
33
32
|
return rb_call_super(0, NULL);
|
34
33
|
}
|
data/ext/reflex/motion_event.cpp
CHANGED
@@ -20,13 +20,11 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
20
20
|
RUCY_END
|
21
21
|
|
22
22
|
static
|
23
|
-
|
23
|
+
RUCY_DEF1(initialize, gravity)
|
24
24
|
{
|
25
25
|
CHECK;
|
26
|
-
check_arg_count(__FILE__, __LINE__, "MotionEvent#initialize", argc, 0, 1);
|
27
26
|
|
28
|
-
|
29
|
-
THIS->gravity = to<Rays::Point>(argv[0]);
|
27
|
+
THIS->gravity = to<Rays::Point>(gravity);
|
30
28
|
|
31
29
|
return rb_call_super(0, NULL);
|
32
30
|
}
|
@@ -20,19 +20,23 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
20
20
|
RUCY_END
|
21
21
|
|
22
22
|
static
|
23
|
-
|
23
|
+
RUCY_DEF6(initialize, type, pointer_type, modifiers, count, drag, positions)
|
24
24
|
{
|
25
25
|
CHECK;
|
26
|
-
check_arg_count(__FILE__, __LINE__, "PointerEvent#initialize", argc, 0, 1, 2, 3, 4, 5, 6, 7);
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
THIS->
|
33
|
-
THIS->
|
34
|
-
THIS->
|
35
|
-
THIS->
|
27
|
+
int size = positions.size();
|
28
|
+
if (size <= 0 || Reflex::PointerEvent::MAX < size)
|
29
|
+
argument_error(__FILE__, __LINE__);
|
30
|
+
|
31
|
+
THIS->type = (Reflex::PointerEvent::Type) to<int>(type);
|
32
|
+
THIS->pointer_type = to<uint>(pointer_type);
|
33
|
+
THIS->modifiers = to<uint>(modifiers);
|
34
|
+
THIS->count = to<uint>(count);
|
35
|
+
THIS->drag = to<bool>(drag);
|
36
|
+
THIS->size = (size_t) size;
|
37
|
+
|
38
|
+
for (int i = 0; i < size; ++i)
|
39
|
+
THIS->positions[i] = to<Rays::Point>(positions[i]);
|
36
40
|
|
37
41
|
return rb_call_super(0, NULL);
|
38
42
|
}
|
@@ -131,10 +135,15 @@ RUCY_DEFN(position)
|
|
131
135
|
RUCY_END
|
132
136
|
|
133
137
|
static
|
134
|
-
RUCY_DEF1(
|
138
|
+
RUCY_DEF1(get_at, index)
|
135
139
|
{
|
136
140
|
CHECK;
|
137
|
-
|
141
|
+
|
142
|
+
int i = to<int>(index);
|
143
|
+
if (i < 0 || THIS->size <= (size_t) i)
|
144
|
+
index_error(__FILE__, __LINE__);
|
145
|
+
|
146
|
+
return value((*THIS)[i]);
|
138
147
|
}
|
139
148
|
RUCY_END
|
140
149
|
|
@@ -160,7 +169,7 @@ Init_pointer_event ()
|
|
160
169
|
cPointerEvent.define_method("x", x);
|
161
170
|
cPointerEvent.define_method("y", y);
|
162
171
|
cPointerEvent.define_method("position", position);
|
163
|
-
cPointerEvent.define_method("[]",
|
172
|
+
cPointerEvent.define_method("[]", get_at);
|
164
173
|
cPointerEvent.define_const("TYPE_NONE", Reflex::PointerEvent::NONE);
|
165
174
|
cPointerEvent.define_const("TYPE_DOWN", Reflex::PointerEvent::DOWN);
|
166
175
|
cPointerEvent.define_const("TYPE_UP", Reflex::PointerEvent::UP);
|
data/ext/reflex/scroll_event.cpp
CHANGED
@@ -20,17 +20,16 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
20
20
|
RUCY_END
|
21
21
|
|
22
22
|
static
|
23
|
-
|
23
|
+
RUCY_DEF6(initialize, x, y, z, dx, dy, dz)
|
24
24
|
{
|
25
25
|
CHECK;
|
26
|
-
|
27
|
-
|
28
|
-
THIS->
|
29
|
-
THIS->
|
30
|
-
THIS->
|
31
|
-
THIS->
|
32
|
-
THIS->
|
33
|
-
THIS->dz = (argc >= 6) ? to<coord>(argv[5]) : 0;
|
26
|
+
|
27
|
+
THIS->x = to<coord>(x);
|
28
|
+
THIS->y = to<coord>(y);
|
29
|
+
THIS->z = to<coord>(z);
|
30
|
+
THIS->dx = to<coord>(dx);
|
31
|
+
THIS->dy = to<coord>(dy);
|
32
|
+
THIS->dz = to<coord>(dz);
|
34
33
|
|
35
34
|
return rb_call_super(0, NULL);
|
36
35
|
}
|
data/ext/reflex/update_event.cpp
CHANGED
@@ -19,13 +19,12 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
19
19
|
RUCY_END
|
20
20
|
|
21
21
|
static
|
22
|
-
|
22
|
+
RUCY_DEF2(initialize, now, dt)
|
23
23
|
{
|
24
24
|
CHECK;
|
25
|
-
check_arg_count(__FILE__, __LINE__, "UpdateEvent#initialize", argc, 0, 1, 2);
|
26
25
|
|
27
|
-
THIS->now =
|
28
|
-
THIS->dt =
|
26
|
+
THIS->now = to<double>(now);
|
27
|
+
THIS->dt = to<float>(dt);
|
29
28
|
|
30
29
|
return rb_call_super(0, NULL);
|
31
30
|
}
|
data/ext/reflex/wheel_event.cpp
CHANGED
@@ -20,14 +20,13 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
20
20
|
RUCY_END
|
21
21
|
|
22
22
|
static
|
23
|
-
|
23
|
+
RUCY_DEF3(initialize, dx, dy, dz)
|
24
24
|
{
|
25
25
|
CHECK;
|
26
|
-
check_arg_count(__FILE__, __LINE__, "WheelEvent#initialize", argc, 0, 1, 2, 3);
|
27
26
|
|
28
|
-
THIS->dx =
|
29
|
-
THIS->dy =
|
30
|
-
THIS->dz =
|
27
|
+
THIS->dx = to<coord>(dx);
|
28
|
+
THIS->dy = to<coord>(dy);
|
29
|
+
THIS->dz = to<coord>(dz);
|
31
30
|
|
32
31
|
return rb_call_super(0, NULL);
|
33
32
|
}
|
data/ext/reflex/window.cpp
CHANGED
@@ -93,6 +93,23 @@ RUCY_DEF0(get_frame)
|
|
93
93
|
}
|
94
94
|
RUCY_END
|
95
95
|
|
96
|
+
static
|
97
|
+
RUCY_DEF1(set_resizable, state)
|
98
|
+
{
|
99
|
+
CHECK;
|
100
|
+
THIS->set_resizable(to<bool>(state));
|
101
|
+
return value(THIS->is_resizable());
|
102
|
+
}
|
103
|
+
RUCY_END
|
104
|
+
|
105
|
+
static
|
106
|
+
RUCY_DEF0(is_resizable)
|
107
|
+
{
|
108
|
+
CHECK;
|
109
|
+
return value(THIS->is_resizable());
|
110
|
+
}
|
111
|
+
RUCY_END
|
112
|
+
|
96
113
|
static
|
97
114
|
RUCY_DEF0(hidden)
|
98
115
|
{
|
@@ -267,6 +284,8 @@ Init_window ()
|
|
267
284
|
cWindow.define_method("title", get_title);
|
268
285
|
cWindow.define_method("frame=", set_frame);
|
269
286
|
cWindow.define_method("frame", get_frame);
|
287
|
+
cWindow.define_method("resizable=", set_resizable);
|
288
|
+
cWindow.define_method("resizable?", is_resizable);
|
270
289
|
cWindow.define_method("hidden", hidden);
|
271
290
|
cWindow.define_method("root", root);
|
272
291
|
cWindow.define_method("focus", focus);
|
data/include/reflex/event.h
CHANGED
@@ -37,16 +37,6 @@ namespace Reflex
|
|
37
37
|
};// Event
|
38
38
|
|
39
39
|
|
40
|
-
struct MotionEvent : public Event
|
41
|
-
{
|
42
|
-
|
43
|
-
Point gravity;
|
44
|
-
|
45
|
-
MotionEvent (const Point& gravity = Point(0, 9.8));
|
46
|
-
|
47
|
-
};// MotionEvent
|
48
|
-
|
49
|
-
|
50
40
|
struct UpdateEvent : public Event
|
51
41
|
{
|
52
42
|
|
@@ -115,14 +105,14 @@ namespace Reflex
|
|
115
105
|
{
|
116
106
|
struct {coord x, y, z;};
|
117
107
|
|
118
|
-
|
108
|
+
Coord3 scroll_;
|
119
109
|
};
|
120
110
|
|
121
111
|
union
|
122
112
|
{
|
123
113
|
struct {coord dx, dy, dz;};
|
124
114
|
|
125
|
-
|
115
|
+
Coord3 delta_;
|
126
116
|
};
|
127
117
|
|
128
118
|
ScrollEvent ();
|
@@ -203,7 +193,7 @@ namespace Reflex
|
|
203
193
|
{
|
204
194
|
struct {coord x, y, z;};
|
205
195
|
|
206
|
-
|
196
|
+
Coord3 positions[MAX];
|
207
197
|
};
|
208
198
|
|
209
199
|
PointerEvent ();
|
@@ -234,14 +224,14 @@ namespace Reflex
|
|
234
224
|
{
|
235
225
|
struct {coord dx, dy, dz;};
|
236
226
|
|
237
|
-
|
227
|
+
Coord3 delta_;
|
238
228
|
};
|
239
229
|
|
240
230
|
union
|
241
231
|
{
|
242
232
|
struct {coord x, y, z;};
|
243
233
|
|
244
|
-
|
234
|
+
Coord3 position_;
|
245
235
|
};
|
246
236
|
|
247
237
|
uint modifiers;
|
@@ -315,6 +305,16 @@ namespace Reflex
|
|
315
305
|
};// ContactEvent
|
316
306
|
|
317
307
|
|
308
|
+
struct MotionEvent : public Event
|
309
|
+
{
|
310
|
+
|
311
|
+
Point gravity;
|
312
|
+
|
313
|
+
MotionEvent (const Point& gravity = Point(0, 9.8));
|
314
|
+
|
315
|
+
};// MotionEvent
|
316
|
+
|
317
|
+
|
318
318
|
}// Reflex
|
319
319
|
|
320
320
|
|
data/include/reflex/exception.h
CHANGED
@@ -38,11 +38,17 @@ namespace Reflex
|
|
38
38
|
|
39
39
|
using namespace Xot::ErrorFunctions;
|
40
40
|
|
41
|
-
|
41
|
+
[[noreturn]]
|
42
|
+
void reflex_error (
|
43
|
+
const char* file, int line, const char* format = NULL, ...);
|
42
44
|
|
43
|
-
|
45
|
+
[[noreturn]]
|
46
|
+
void layout_error (
|
47
|
+
const char* file, int line, const char* format = NULL, ...);
|
44
48
|
|
45
|
-
|
49
|
+
[[noreturn]]
|
50
|
+
void physics_error (
|
51
|
+
const char* file, int line, const char* format = NULL, ...);
|
46
52
|
|
47
53
|
}// ErrorFunctions
|
48
54
|
|
data/include/reflex/ruby/event.h
CHANGED
@@ -17,9 +17,6 @@ namespace Reflex
|
|
17
17
|
Rucy::Class event_class ();
|
18
18
|
// class Reflex::Event
|
19
19
|
|
20
|
-
Rucy::Class motion_event_class ();
|
21
|
-
// class Reflex::MotionEvent
|
22
|
-
|
23
20
|
Rucy::Class update_event_class ();
|
24
21
|
// class Reflex::UpdateEvent
|
25
22
|
|
@@ -53,14 +50,15 @@ namespace Reflex
|
|
53
50
|
Rucy::Class contact_event_class ();
|
54
51
|
// class Reflex::ContactEvent
|
55
52
|
|
53
|
+
Rucy::Class motion_event_class ();
|
54
|
+
// class Reflex::MotionEvent
|
55
|
+
|
56
56
|
|
57
57
|
}// Reflex
|
58
58
|
|
59
59
|
|
60
60
|
RUCY_DECLARE_VALUE_FROM_TO(Reflex::Event)
|
61
61
|
|
62
|
-
RUCY_DECLARE_VALUE_FROM_TO(Reflex::MotionEvent)
|
63
|
-
|
64
62
|
RUCY_DECLARE_VALUE_FROM_TO(Reflex::UpdateEvent)
|
65
63
|
|
66
64
|
RUCY_DECLARE_VALUE_FROM_TO(Reflex::DrawEvent)
|
@@ -83,6 +81,8 @@ RUCY_DECLARE_VALUE_FROM_TO(Reflex::TimerEvent)
|
|
83
81
|
|
84
82
|
RUCY_DECLARE_VALUE_FROM_TO(Reflex::ContactEvent)
|
85
83
|
|
84
|
+
RUCY_DECLARE_VALUE_FROM_TO(Reflex::MotionEvent)
|
85
|
+
|
86
86
|
|
87
87
|
namespace Rucy
|
88
88
|
{
|
@@ -94,12 +94,6 @@ namespace Rucy
|
|
94
94
|
return Reflex::event_class();
|
95
95
|
}
|
96
96
|
|
97
|
-
template <> inline Class
|
98
|
-
get_ruby_class<Reflex::MotionEvent> ()
|
99
|
-
{
|
100
|
-
return Reflex::motion_event_class();
|
101
|
-
}
|
102
|
-
|
103
97
|
template <> inline Class
|
104
98
|
get_ruby_class<Reflex::UpdateEvent> ()
|
105
99
|
{
|
@@ -166,6 +160,12 @@ namespace Rucy
|
|
166
160
|
return Reflex::contact_event_class();
|
167
161
|
}
|
168
162
|
|
163
|
+
template <> inline Class
|
164
|
+
get_ruby_class<Reflex::MotionEvent> ()
|
165
|
+
{
|
166
|
+
return Reflex::motion_event_class();
|
167
|
+
}
|
168
|
+
|
169
169
|
|
170
170
|
}// Rucy
|
171
171
|
|
data/include/reflex/window.h
CHANGED
data/lib/reflex.rb
CHANGED
@@ -9,13 +9,14 @@ require 'reflex/bounds'
|
|
9
9
|
require 'reflex/color'
|
10
10
|
require 'reflex/color_space'
|
11
11
|
require 'reflex/matrix'
|
12
|
+
require 'reflex/painter'
|
12
13
|
require 'reflex/polyline'
|
13
14
|
require 'reflex/polygon'
|
14
15
|
require 'reflex/bitmap'
|
15
16
|
require 'reflex/image'
|
16
17
|
require 'reflex/font'
|
17
18
|
require 'reflex/shader'
|
18
|
-
require 'reflex/
|
19
|
+
require 'reflex/camera'
|
19
20
|
|
20
21
|
require 'reflex/reflex'
|
21
22
|
require 'reflex/helper'
|
data/lib/reflex/pointer_event.rb
CHANGED
@@ -64,6 +64,10 @@ module Reflex
|
|
64
64
|
(get_pointer_type & POINTER_PEN) != 0
|
65
65
|
end
|
66
66
|
|
67
|
+
def positions ()
|
68
|
+
size.times.map {|i| position i}
|
69
|
+
end
|
70
|
+
|
67
71
|
def inspect ()
|
68
72
|
"#<Reflex::PointerEvent type:#{type}/#{pointer_type} x:#{x} y:#{y} size:#{size} mod:#{modifiers} count:#{count} drag:#{drag?}>"
|
69
73
|
end
|
data/lib/reflex/window.rb
CHANGED
data/reflex.gemspec
CHANGED
@@ -28,10 +28,10 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.platform = Gem::Platform::RUBY
|
29
29
|
s.required_ruby_version = '~> 2'
|
30
30
|
|
31
|
-
s.add_runtime_dependency 'xot', '~> 0.1'
|
32
|
-
s.add_runtime_dependency 'rucy', '~> 0.1'
|
33
|
-
s.add_runtime_dependency 'beeps', '~> 0.1'
|
34
|
-
s.add_runtime_dependency 'rays', '~> 0.1'
|
31
|
+
s.add_runtime_dependency 'xot', '~> 0.1.21'
|
32
|
+
s.add_runtime_dependency 'rucy', '~> 0.1.21'
|
33
|
+
s.add_runtime_dependency 'beeps', '~> 0.1.21'
|
34
|
+
s.add_runtime_dependency 'rays', '~> 0.1.21'
|
35
35
|
|
36
36
|
s.files = `git ls-files`.split $/
|
37
37
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/samples/camera.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
%w[xot rays reflex]
|
5
|
+
.map {|s| File.expand_path "../../../#{s}/lib", __FILE__}
|
6
|
+
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
7
|
+
|
8
|
+
require 'reflex'
|
9
|
+
|
10
|
+
|
11
|
+
class Win < Reflex::Window
|
12
|
+
def initialize ()
|
13
|
+
super title: "Camera Example", frame: [100, 100, 800, 600]
|
14
|
+
|
15
|
+
@w = 100
|
16
|
+
@h = 200
|
17
|
+
@resize_crop = Rays::Camera.new(@w, @h, resize: true, crop: true) {start}
|
18
|
+
@crop = Rays::Camera.new(@w, @h, resize: false, crop: true) {start}
|
19
|
+
@resize = Rays::Camera.new(@w, @h, resize: true, crop: false) {start}
|
20
|
+
@original = Rays::Camera.new(@w, @h, resize: false, crop: false) {start}
|
21
|
+
end
|
22
|
+
|
23
|
+
def on_draw (e)
|
24
|
+
p = e.painter
|
25
|
+
|
26
|
+
p.image @resize_crop.image, @w * 0, 0 if @resize_crop.image
|
27
|
+
p.image @crop.image, @w * 1, 0 if @crop.image
|
28
|
+
p.image @resize.image, @w * 2, 0 if @resize.image
|
29
|
+
p.image @original.image, 0, @h if @original.image
|
30
|
+
|
31
|
+
p.text "#{e.fps.to_i} FPS", 10, 10
|
32
|
+
|
33
|
+
p.fill nil
|
34
|
+
p.stroke 1
|
35
|
+
p.rect 0, 0, @w, @h
|
36
|
+
end
|
37
|
+
|
38
|
+
def on_update (e)
|
39
|
+
redraw
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Reflex.start do
|
44
|
+
Win.new.show
|
45
|
+
end
|