reflexion 0.1.23 → 0.1.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/capture_event.cpp +6 -5
  3. data/.doc/ext/reflex/contact_event.cpp +14 -12
  4. data/.doc/ext/reflex/draw_event.cpp +10 -8
  5. data/.doc/ext/reflex/event.cpp +2 -10
  6. data/.doc/ext/reflex/focus_event.cpp +14 -13
  7. data/.doc/ext/reflex/frame_event.cpp +17 -17
  8. data/.doc/ext/reflex/key_event.cpp +20 -19
  9. data/.doc/ext/reflex/pointer_event.cpp +1 -1
  10. data/.doc/ext/reflex/scroll_event.cpp +14 -17
  11. data/.doc/ext/reflex/timer.cpp +9 -1
  12. data/.doc/ext/reflex/timer_event.cpp +4 -13
  13. data/.doc/ext/reflex/update_event.cpp +6 -5
  14. data/.doc/ext/reflex/wheel_event.cpp +39 -22
  15. data/VERSION +1 -1
  16. data/ext/reflex/capture_event.cpp +6 -5
  17. data/ext/reflex/contact_event.cpp +16 -14
  18. data/ext/reflex/draw_event.cpp +9 -7
  19. data/ext/reflex/event.cpp +2 -11
  20. data/ext/reflex/focus_event.cpp +14 -13
  21. data/ext/reflex/frame_event.cpp +16 -16
  22. data/ext/reflex/key_event.cpp +20 -19
  23. data/ext/reflex/pointer_event.cpp +1 -1
  24. data/ext/reflex/scroll_event.cpp +15 -18
  25. data/ext/reflex/timer.cpp +15 -6
  26. data/ext/reflex/timer_event.cpp +9 -19
  27. data/ext/reflex/update_event.cpp +6 -5
  28. data/ext/reflex/wheel_event.cpp +40 -21
  29. data/include/reflex/event.h +224 -115
  30. data/include/reflex/shape.h +2 -2
  31. data/lib/reflex/contact_event.rb +7 -7
  32. data/lib/reflex/focus_event.rb +8 -8
  33. data/lib/reflex/key_event.rb +8 -8
  34. data/lib/reflex/pointer.rb +3 -3
  35. data/lib/reflex/timer_event.rb +2 -1
  36. data/lib/reflex/wheel_event.rb +1 -9
  37. data/lib/reflex/window.rb +1 -1
  38. data/reflex.gemspec +4 -4
  39. data/src/event.cpp +630 -76
  40. data/src/event.h +15 -0
  41. data/src/image_view.cpp +2 -2
  42. data/src/ios/view_controller.mm +1 -1
  43. data/src/osx/event.h +1 -1
  44. data/src/osx/event.mm +9 -9
  45. data/src/osx/native_window.mm +1 -1
  46. data/src/shape.cpp +11 -13
  47. data/src/shape.h +1 -1
  48. data/src/view.cpp +137 -89
  49. data/src/view.h +5 -6
  50. data/src/window.cpp +44 -38
  51. data/src/world.cpp +6 -4
  52. data/test/test_capture_event.rb +16 -0
  53. data/test/test_contact_event.rb +40 -0
  54. data/test/test_draw_event.rb +35 -0
  55. data/test/test_event.rb +20 -6
  56. data/test/test_focus_event.rb +34 -0
  57. data/test/test_frame_event.rb +38 -0
  58. data/test/test_key_event.rb +33 -0
  59. data/test/test_pointer.rb +14 -14
  60. data/test/test_pointer_event.rb +1 -1
  61. data/test/test_scroll_event.rb +39 -0
  62. data/test/test_timer_event.rb +38 -0
  63. data/test/test_update_event.rb +29 -0
  64. data/test/test_wheel_event.rb +40 -0
  65. metadata +29 -11
@@ -19,15 +19,16 @@ RUCY_DEF_ALLOC(alloc, klass)
19
19
  RUCY_END
20
20
 
21
21
  static
22
- RUCY_DEF5(initialize, type, chars, code, repeat, modifiers)
22
+ RUCY_DEF5(initialize, action, chars, code, modifiers, repeat)
23
23
  {
24
24
  CHECK;
25
25
 
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);
26
+ *THIS = Reflex::KeyEvent(
27
+ (Reflex::KeyEvent::Action) to<uint>(action),
28
+ chars.c_str(),
29
+ to<int>(code),
30
+ to<uint>(modifiers),
31
+ to<int>(repeat));
31
32
 
32
33
  return rb_call_super(0, NULL);
33
34
  }
@@ -37,16 +38,16 @@ static
37
38
  RUCY_DEF1(initialize_copy, obj)
38
39
  {
39
40
  CHECK;
40
- *THIS = to<Reflex::KeyEvent&>(obj);
41
+ *THIS = to<Reflex::KeyEvent&>(obj).dup();
41
42
  return self;
42
43
  }
43
44
  RUCY_END
44
45
 
45
46
  static
46
- RUCY_DEF0(get_type)
47
+ RUCY_DEF0(get_action)
47
48
  {
48
49
  CHECK;
49
- return value(THIS->type);
50
+ return value(THIS->action());
50
51
  }
51
52
  RUCY_END
52
53
 
@@ -54,7 +55,7 @@ static
54
55
  RUCY_DEF0(get_key)
55
56
  {
56
57
  CHECK;
57
- switch (THIS->code)
58
+ switch (THIS->code())
58
59
  {
59
60
  #define CASE(key) case Reflex::KEY_##key
60
61
  #define SYMBOL1(name) SYMBOL2(_##name, #name)
@@ -252,7 +253,7 @@ static
252
253
  RUCY_DEF0(get_chars)
253
254
  {
254
255
  CHECK;
255
- return value(THIS->chars.c_str());
256
+ return value(THIS->chars());
256
257
  }
257
258
  RUCY_END
258
259
 
@@ -260,7 +261,7 @@ static
260
261
  RUCY_DEF0(get_code)
261
262
  {
262
263
  CHECK;
263
- return value(THIS->code);
264
+ return value(THIS->code());
264
265
  }
265
266
  RUCY_END
266
267
 
@@ -268,7 +269,7 @@ static
268
269
  RUCY_DEF0(get_modifiers)
269
270
  {
270
271
  CHECK;
271
- return value(THIS->modifiers);
272
+ return value(THIS->modifiers());
272
273
  }
273
274
  RUCY_END
274
275
 
@@ -276,7 +277,7 @@ static
276
277
  RUCY_DEF0(get_repeat)
277
278
  {
278
279
  CHECK;
279
- return value(THIS->repeat);
280
+ return value(THIS->repeat());
280
281
  }
281
282
  RUCY_END
282
283
 
@@ -284,7 +285,7 @@ static
284
285
  RUCY_DEF0(is_captured)
285
286
  {
286
287
  CHECK;
287
- return value(THIS->captured);
288
+ return value(THIS->is_captured());
288
289
  }
289
290
  RUCY_END
290
291
 
@@ -300,16 +301,16 @@ Init_key_event ()
300
301
  cKeyEvent.define_alloc_func(alloc);
301
302
  cKeyEvent.define_private_method("initialize", initialize);
302
303
  cKeyEvent.define_private_method("initialize_copy", initialize_copy);
303
- cKeyEvent.define_method("type", get_type);
304
+ cKeyEvent.define_method("action", get_action);
304
305
  cKeyEvent.define_method("key", get_key);
305
306
  cKeyEvent.define_method("chars", get_chars);
306
307
  cKeyEvent.define_method("code", get_code);
307
308
  cKeyEvent.define_method("modifiers", get_modifiers);
308
309
  cKeyEvent.define_method("repeat", get_repeat);
309
310
  cKeyEvent.define_method("captured?", is_captured);
310
- cKeyEvent.define_const("TYPE_NONE", Reflex::KeyEvent::NONE);
311
- cKeyEvent.define_const("TYPE_DOWN", Reflex::KeyEvent::DOWN);
312
- cKeyEvent.define_const("TYPE_UP", Reflex::KeyEvent::UP);
311
+ cKeyEvent.define_const("ACTION_NONE", Reflex::KeyEvent::ACTION_NONE);
312
+ cKeyEvent.define_const("DOWN", Reflex::KeyEvent::DOWN);
313
+ cKeyEvent.define_const("UP", Reflex::KeyEvent::UP);
313
314
  }
314
315
 
315
316
 
@@ -43,7 +43,7 @@ static
43
43
  RUCY_DEF1(initialize_copy, obj)
44
44
  {
45
45
  CHECK;
46
- *THIS = to<Reflex::PointerEvent&>(obj);
46
+ *THIS = to<Reflex::PointerEvent&>(obj).dup();
47
47
  return self;
48
48
  }
49
49
  RUCY_END
@@ -24,12 +24,9 @@ RUCY_DEF6(initialize, x, y, z, dx, dy, dz)
24
24
  {
25
25
  CHECK;
26
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);
27
+ *THIS = Reflex::ScrollEvent(
28
+ to<coord>( x), to<coord>( y), to<coord>( z),
29
+ to<coord>(dx), to<coord>(dy), to<coord>(dz));
33
30
 
34
31
  return rb_call_super(0, NULL);
35
32
  }
@@ -39,7 +36,7 @@ static
39
36
  RUCY_DEF1(initialize_copy, obj)
40
37
  {
41
38
  CHECK;
42
- *THIS = to<Reflex::ScrollEvent&>(obj);
39
+ *THIS = to<Reflex::ScrollEvent&>(obj).dup();
43
40
  return self;
44
41
  }
45
42
  RUCY_END
@@ -48,7 +45,7 @@ static
48
45
  RUCY_DEF0(x)
49
46
  {
50
47
  CHECK;
51
- return value(THIS->x);
48
+ return value(THIS->scroll().x);
52
49
  }
53
50
  RUCY_END
54
51
 
@@ -56,7 +53,7 @@ static
56
53
  RUCY_DEF0(y)
57
54
  {
58
55
  CHECK;
59
- return value(THIS->y);
56
+ return value(THIS->scroll().y);
60
57
  }
61
58
  RUCY_END
62
59
 
@@ -64,7 +61,7 @@ static
64
61
  RUCY_DEF0(z)
65
62
  {
66
63
  CHECK;
67
- return value(THIS->z);
64
+ return value(THIS->scroll().z);
68
65
  }
69
66
  RUCY_END
70
67
 
@@ -72,7 +69,7 @@ static
72
69
  RUCY_DEF0(dx)
73
70
  {
74
71
  CHECK;
75
- return value(THIS->dx);
72
+ return value(THIS->dscroll().x);
76
73
  }
77
74
  RUCY_END
78
75
 
@@ -80,7 +77,7 @@ static
80
77
  RUCY_DEF0(dy)
81
78
  {
82
79
  CHECK;
83
- return value(THIS->dy);
80
+ return value(THIS->dscroll().y);
84
81
  }
85
82
  RUCY_END
86
83
 
@@ -88,7 +85,7 @@ static
88
85
  RUCY_DEF0(dz)
89
86
  {
90
87
  CHECK;
91
- return value(THIS->dz);
88
+ return value(THIS->dscroll().z);
92
89
  }
93
90
  RUCY_END
94
91
 
@@ -96,15 +93,15 @@ static
96
93
  RUCY_DEF0(scroll)
97
94
  {
98
95
  CHECK;
99
- return value(Rays::Point(THIS->x, THIS->y, THIS->z));
96
+ return value(THIS->scroll());
100
97
  }
101
98
  RUCY_END
102
99
 
103
100
  static
104
- RUCY_DEF0(delta)
101
+ RUCY_DEF0(dscroll)
105
102
  {
106
103
  CHECK;
107
- return value(Rays::Point(THIS->dx, THIS->dy, THIS->dz));
104
+ return value(THIS->dscroll());
108
105
  }
109
106
  RUCY_END
110
107
 
@@ -126,8 +123,8 @@ Init_scroll_event ()
126
123
  cScrollEvent.define_method("dx", dx);
127
124
  cScrollEvent.define_method("dy", dy);
128
125
  cScrollEvent.define_method("dz", dz);
129
- cScrollEvent.define_method("scroll", scroll);
130
- cScrollEvent.define_method("delta", delta);
126
+ cScrollEvent.define_method( "scroll", scroll);
127
+ cScrollEvent.define_method("dscroll", dscroll);
131
128
  }
132
129
 
133
130
 
data/ext/reflex/timer.cpp CHANGED
@@ -1,6 +1,7 @@
1
1
  #include "reflex/ruby/timer.h"
2
2
 
3
3
 
4
+ #include "reflex/exception.h"
4
5
  #include "reflex/ruby/view.h"
5
6
  #include "reflex/ruby/selector.h"
6
7
  #include "defs.h"
@@ -16,6 +17,13 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Timer)
16
17
  #define CALL(fun) RUCY_CALL_SUPER(THIS, fun)
17
18
 
18
19
 
20
+ static
21
+ RUCY_DEF_ALLOC(alloc, klass)
22
+ {
23
+ Reflex::reflex_error(__FILE__, __LINE__, "can not instantiate Timer class.");
24
+ }
25
+ RUCY_END
26
+
19
27
  static
20
28
  RUCY_DEF0(stop)
21
29
  {
@@ -82,13 +90,14 @@ Init_timer ()
82
90
  Module mReflex = define_module("Reflex");
83
91
 
84
92
  cTimer = mReflex.define_class("Timer");
93
+ cTimer.define_alloc_func(alloc);
85
94
  cTimer.define_method("stop", stop);
86
- cTimer.define_method("owner", get_owner);
87
- cTimer.define_method("id", get_id);
88
- cTimer.define_method("interval", get_interval);
89
- cTimer.define_method("count=", set_count);
90
- cTimer.define_method("count", get_count);
91
- cTimer.define_method("finish?", is_finished);
95
+ cTimer.define_method("owner", get_owner);
96
+ cTimer.define_method("id", get_id);
97
+ cTimer.define_method("interval", get_interval);
98
+ cTimer.define_method("count=", set_count);
99
+ cTimer.define_method("count", get_count);
100
+ cTimer.define_method("finished?", is_finished);
92
101
 
93
102
  define_selector_methods<Reflex::Timer>(cTimer);
94
103
  }
@@ -25,7 +25,7 @@ RUCY_DEF1(initialize, timer)
25
25
  {
26
26
  CHECK;
27
27
 
28
- THIS->timer = to<Reflex::Timer*>(timer);
28
+ *THIS = Reflex::TimerEvent(to<Reflex::Timer*>(timer));
29
29
 
30
30
  return rb_call_super(0, NULL);
31
31
  }
@@ -35,7 +35,7 @@ static
35
35
  RUCY_DEF1(initialize_copy, obj)
36
36
  {
37
37
  CHECK;
38
- *THIS = to<Reflex::TimerEvent&>(obj);
38
+ *THIS = to<Reflex::TimerEvent&>(obj).dup();
39
39
  return self;
40
40
  }
41
41
  RUCY_END
@@ -44,7 +44,7 @@ static
44
44
  RUCY_DEF0(timer)
45
45
  {
46
46
  CHECK;
47
- return value(THIS->timer);
47
+ return value(THIS->timer());
48
48
  }
49
49
  RUCY_END
50
50
 
@@ -72,15 +72,6 @@ RUCY_DEF0(interval)
72
72
  }
73
73
  RUCY_END
74
74
 
75
- static
76
- RUCY_DEF1(set_count, count)
77
- {
78
- CHECK;
79
- THIS->set_count(to<int>(count));
80
- return count;
81
- }
82
- RUCY_END
83
-
84
75
  static
85
76
  RUCY_DEF0(count)
86
77
  {
@@ -109,13 +100,12 @@ Init_timer_event ()
109
100
  cTimerEvent.define_alloc_func(alloc);
110
101
  cTimerEvent.define_private_method("initialize", initialize);
111
102
  cTimerEvent.define_private_method("initialize_copy", initialize_copy);
112
- cTimerEvent.define_method("timer", timer);
113
- cTimerEvent.define_method("owner", owner);
114
- cTimerEvent.define_method("id", id);
115
- cTimerEvent.define_method("interval", interval);
116
- cTimerEvent.define_method("count=", set_count);
117
- cTimerEvent.define_method("count", count);
118
- cTimerEvent.define_method("finish?", is_finished);
103
+ cTimerEvent.define_method("timer", timer);
104
+ cTimerEvent.define_method("owner", owner);
105
+ cTimerEvent.define_method("id", id);
106
+ cTimerEvent.define_method("interval", interval);
107
+ cTimerEvent.define_method("count", count);
108
+ cTimerEvent.define_method("finished?", is_finished);
119
109
  }
120
110
 
121
111
 
@@ -23,8 +23,9 @@ RUCY_DEF2(initialize, now, dt)
23
23
  {
24
24
  CHECK;
25
25
 
26
- THIS->now = to<double>(now);
27
- THIS->dt = to<float>(dt);
26
+ *THIS = Reflex::UpdateEvent(
27
+ to<double>(now),
28
+ to<float>(dt));
28
29
 
29
30
  return rb_call_super(0, NULL);
30
31
  }
@@ -34,7 +35,7 @@ static
34
35
  RUCY_DEF1(initialize_copy, obj)
35
36
  {
36
37
  CHECK;
37
- *THIS = to<Reflex::UpdateEvent&>(obj);
38
+ *THIS = to<Reflex::UpdateEvent&>(obj).dup();
38
39
  return self;
39
40
  }
40
41
  RUCY_END
@@ -43,7 +44,7 @@ static
43
44
  RUCY_DEF0(now)
44
45
  {
45
46
  CHECK;
46
- return value(THIS->now);
47
+ return value(THIS->now());
47
48
  }
48
49
  RUCY_END
49
50
 
@@ -51,7 +52,7 @@ static
51
52
  RUCY_DEF0(dt)
52
53
  {
53
54
  CHECK;
54
- return value(THIS->dt);
55
+ return value(THIS->dt());
55
56
  }
56
57
  RUCY_END
57
58
 
@@ -20,13 +20,14 @@ RUCY_DEF_ALLOC(alloc, klass)
20
20
  RUCY_END
21
21
 
22
22
  static
23
- RUCY_DEF3(initialize, dx, dy, dz)
23
+ RUCY_DEF7(initialize, x, y, z, dx, dy, dz, modifiers)
24
24
  {
25
25
  CHECK;
26
26
 
27
- THIS->dx = to<coord>(dx);
28
- THIS->dy = to<coord>(dy);
29
- THIS->dz = to<coord>(dz);
27
+ *THIS = Reflex::WheelEvent(
28
+ to<coord>( x), to<coord>( y), to<coord>( z),
29
+ to<coord>(dx), to<coord>(dy), to<coord>(dz),
30
+ to<uint>(modifiers));
30
31
 
31
32
  return rb_call_super(0, NULL);
32
33
  }
@@ -36,56 +37,72 @@ static
36
37
  RUCY_DEF1(initialize_copy, obj)
37
38
  {
38
39
  CHECK;
39
- *THIS = to<Reflex::WheelEvent&>(obj);
40
+ *THIS = to<Reflex::WheelEvent&>(obj).dup();
40
41
  return self;
41
42
  }
42
43
  RUCY_END
43
44
 
44
45
  static
45
- RUCY_DEF0(dx)
46
+ RUCY_DEF0(x)
46
47
  {
47
48
  CHECK;
48
- return value(THIS->dx);
49
+ return value(THIS->position().x);
49
50
  }
50
51
  RUCY_END
51
52
 
52
53
  static
53
- RUCY_DEF0(dy)
54
+ RUCY_DEF0(y)
54
55
  {
55
56
  CHECK;
56
- return value(THIS->dy);
57
+ return value(THIS->position().y);
57
58
  }
58
59
  RUCY_END
59
60
 
60
61
  static
61
- RUCY_DEF0(dz)
62
+ RUCY_DEF0(z)
62
63
  {
63
64
  CHECK;
64
- return value(THIS->dz);
65
+ return value(THIS->position().z);
65
66
  }
66
67
  RUCY_END
67
68
 
68
69
  static
69
- RUCY_DEF0(x)
70
+ RUCY_DEF0(dx)
70
71
  {
71
72
  CHECK;
72
- return value(THIS->x);
73
+ return value(THIS->dposition().x);
73
74
  }
74
75
  RUCY_END
75
76
 
76
77
  static
77
- RUCY_DEF0(y)
78
+ RUCY_DEF0(dy)
78
79
  {
79
80
  CHECK;
80
- return value(THIS->y);
81
+ return value(THIS->dposition().y);
81
82
  }
82
83
  RUCY_END
83
84
 
84
85
  static
85
- RUCY_DEF0(z)
86
+ RUCY_DEF0(dz)
87
+ {
88
+ CHECK;
89
+ return value(THIS->dposition().z);
90
+ }
91
+ RUCY_END
92
+
93
+ static
94
+ RUCY_DEF0(position)
86
95
  {
87
96
  CHECK;
88
- return value(THIS->z);
97
+ return value(THIS->position());
98
+ }
99
+ RUCY_END
100
+
101
+ static
102
+ RUCY_DEF0(dposition)
103
+ {
104
+ CHECK;
105
+ return value(THIS->dposition());
89
106
  }
90
107
  RUCY_END
91
108
 
@@ -93,7 +110,7 @@ static
93
110
  RUCY_DEF0(modifiers)
94
111
  {
95
112
  CHECK;
96
- return value(THIS->modifiers);
113
+ return value(THIS->modifiers());
97
114
  }
98
115
  RUCY_END
99
116
 
@@ -109,12 +126,14 @@ Init_wheel_event ()
109
126
  cWheelEvent.define_alloc_func(alloc);
110
127
  cWheelEvent.define_private_method("initialize", initialize);
111
128
  cWheelEvent.define_private_method("initialize_copy", initialize_copy);
112
- cWheelEvent.define_method("dx", dx);
113
- cWheelEvent.define_method("dy", dy);
114
- cWheelEvent.define_method("dz", dz);
115
129
  cWheelEvent.define_method("x", x);
116
130
  cWheelEvent.define_method("y", y);
117
131
  cWheelEvent.define_method("z", z);
132
+ cWheelEvent.define_method("dx", dx);
133
+ cWheelEvent.define_method("dy", dy);
134
+ cWheelEvent.define_method("dz", dz);
135
+ cWheelEvent.define_method( "position", position);
136
+ cWheelEvent.define_method("dposition", dposition);
118
137
  cWheelEvent.define_method("modifiers", modifiers);
119
138
  }
120
139