reflexion 0.1.13 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 -15
- data/.doc/ext/reflex/reflex.cpp +3 -1
- 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/LICENSE +21 -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 -14
- data/ext/reflex/reflex.cpp +3 -1
- 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/include/reflex/defs.h +0 -2
- 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/ruby/reflex.h +1 -0
- data/include/reflex/style.h +30 -4
- data/lib/reflex.rb +2 -1
- data/lib/reflex/camera.rb +13 -0
- data/lib/reflex/pointer_event.rb +4 -0
- data/reflex.gemspec +4 -4
- data/samples/camera.rb +45 -0
- data/samples/shapes.rb +16 -0
- data/src/event.cpp +7 -7
- data/src/ios/view_controller.h +4 -0
- data/src/ios/view_controller.mm +22 -34
- data/src/osx/native_window.mm +10 -26
- data/src/shape.cpp +4 -4
- data/src/style.cpp +4 -4
- data/src/timer.cpp +3 -6
- data/src/view.cpp +2 -2
- data/src/window.cpp +27 -0
- data/src/window.h +2 -0
- data/test/test_pointer_event.rb +79 -34
- metadata +16 -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);
|
@@ -171,7 +180,6 @@ Init_pointer_event ()
|
|
171
180
|
cPointerEvent.define_const("POINTER_MOUSE_MIDDLE", Reflex::POINTER_MOUSE_MIDDLE);
|
172
181
|
cPointerEvent.define_const("POINTER_TOUCH", Reflex::POINTER_TOUCH);
|
173
182
|
cPointerEvent.define_const("POINTER_PEN", Reflex::POINTER_PEN);
|
174
|
-
cPointerEvent.define_const("POINTER_TYPE_LAST", Reflex::POINTER_TYPE_LAST);
|
175
183
|
}
|
176
184
|
|
177
185
|
|
data/ext/reflex/reflex.cpp
CHANGED
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/include/reflex/defs.h
CHANGED
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/style.h
CHANGED
@@ -24,7 +24,22 @@ namespace Reflex
|
|
24
24
|
|
25
25
|
typedef coord Value;
|
26
26
|
|
27
|
-
enum Type
|
27
|
+
enum Type
|
28
|
+
{
|
29
|
+
|
30
|
+
NONE = 0,
|
31
|
+
|
32
|
+
PIXEL,
|
33
|
+
|
34
|
+
PERCENT,
|
35
|
+
|
36
|
+
FILL,
|
37
|
+
|
38
|
+
FIT,
|
39
|
+
|
40
|
+
TYPE_MAX
|
41
|
+
|
42
|
+
};// Type
|
28
43
|
|
29
44
|
StyleLength (Type type = NONE, Value value = 0);
|
30
45
|
|
@@ -60,9 +75,20 @@ namespace Reflex
|
|
60
75
|
|
61
76
|
enum Flow
|
62
77
|
{
|
63
|
-
|
64
|
-
|
65
|
-
|
78
|
+
|
79
|
+
FLOW_NONE = 0,
|
80
|
+
|
81
|
+
FLOW_RIGHT,
|
82
|
+
|
83
|
+
FLOW_DOWN,
|
84
|
+
|
85
|
+
FLOW_LEFT,
|
86
|
+
|
87
|
+
FLOW_UP,
|
88
|
+
|
89
|
+
FLOW_MAX
|
90
|
+
|
91
|
+
};// Flow
|
66
92
|
|
67
93
|
Style (const char* name = NULL);
|
68
94
|
|
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
|