reflexion 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/application.cpp +5 -5
  3. data/.doc/ext/reflex/body.cpp +167 -0
  4. data/.doc/ext/reflex/capture_event.cpp +4 -4
  5. data/.doc/ext/reflex/draw_event.cpp +4 -4
  6. data/.doc/ext/reflex/event.cpp +4 -4
  7. data/.doc/ext/reflex/fixture.cpp +101 -0
  8. data/.doc/ext/reflex/focus_event.cpp +4 -4
  9. data/.doc/ext/reflex/frame_event.cpp +4 -4
  10. data/.doc/ext/reflex/image_view.cpp +22 -5
  11. data/.doc/ext/reflex/key_event.cpp +4 -4
  12. data/.doc/ext/reflex/native.cpp +6 -0
  13. data/.doc/ext/reflex/pointer_event.cpp +4 -4
  14. data/.doc/ext/reflex/reflex.cpp +2 -3
  15. data/.doc/ext/reflex/scroll_event.cpp +4 -4
  16. data/.doc/ext/reflex/selector.cpp +4 -4
  17. data/.doc/ext/reflex/style.cpp +4 -4
  18. data/.doc/ext/reflex/style_length.cpp +4 -4
  19. data/.doc/ext/reflex/style_length2.cpp +4 -4
  20. data/.doc/ext/reflex/style_length4.cpp +4 -4
  21. data/.doc/ext/reflex/update_event.cpp +4 -4
  22. data/.doc/ext/reflex/view.cpp +110 -8
  23. data/.doc/ext/reflex/wheel_event.cpp +4 -4
  24. data/.doc/ext/reflex/window.cpp +36 -12
  25. data/README.md +2 -2
  26. data/Rakefile +2 -1
  27. data/VERSION +1 -1
  28. data/ext/reflex/application.cpp +8 -8
  29. data/ext/reflex/body.cpp +181 -0
  30. data/ext/reflex/capture_event.cpp +4 -4
  31. data/ext/reflex/draw_event.cpp +4 -4
  32. data/ext/reflex/event.cpp +4 -4
  33. data/ext/reflex/fixture.cpp +108 -0
  34. data/ext/reflex/focus_event.cpp +4 -4
  35. data/ext/reflex/frame_event.cpp +4 -4
  36. data/ext/reflex/image_view.cpp +24 -5
  37. data/ext/reflex/key_event.cpp +4 -4
  38. data/ext/reflex/native.cpp +6 -0
  39. data/ext/reflex/pointer_event.cpp +4 -4
  40. data/ext/reflex/reflex.cpp +2 -3
  41. data/ext/reflex/scroll_event.cpp +4 -4
  42. data/ext/reflex/selector.cpp +4 -4
  43. data/ext/reflex/style.cpp +4 -4
  44. data/ext/reflex/style_length.cpp +4 -4
  45. data/ext/reflex/style_length2.cpp +4 -4
  46. data/ext/reflex/style_length4.cpp +4 -4
  47. data/ext/reflex/update_event.cpp +4 -4
  48. data/ext/reflex/view.cpp +126 -12
  49. data/ext/reflex/wheel_event.cpp +4 -4
  50. data/ext/reflex/window.cpp +39 -12
  51. data/include/reflex/bitmap.h +20 -0
  52. data/include/reflex/body.h +82 -0
  53. data/include/reflex/bounds.h +20 -0
  54. data/include/reflex/color.h +20 -0
  55. data/include/reflex/color_space.h +20 -0
  56. data/include/reflex/defs.h +5 -1
  57. data/include/reflex/event.h +16 -25
  58. data/include/reflex/fixture.h +116 -0
  59. data/include/reflex/font.h +20 -0
  60. data/include/reflex/image.h +20 -0
  61. data/include/reflex/image_view.h +1 -1
  62. data/include/reflex/matrix.h +20 -0
  63. data/include/reflex/painter.h +20 -0
  64. data/include/reflex/point.h +24 -0
  65. data/include/reflex/ruby/application.h +6 -0
  66. data/include/reflex/ruby/body.h +41 -0
  67. data/include/reflex/ruby/event.h +68 -0
  68. data/include/reflex/ruby/fixture.h +41 -0
  69. data/include/reflex/ruby/image_view.h +14 -0
  70. data/include/reflex/ruby/selector.h +14 -0
  71. data/include/reflex/ruby/style.h +14 -0
  72. data/include/reflex/ruby/style_length.h +26 -0
  73. data/include/reflex/ruby/view.h +43 -39
  74. data/include/reflex/ruby/window.h +27 -21
  75. data/include/reflex/ruby.h +2 -0
  76. data/include/reflex/shader.h +20 -0
  77. data/include/reflex/style.h +2 -3
  78. data/include/reflex/texture.h +20 -0
  79. data/include/reflex/view.h +45 -24
  80. data/include/reflex/window.h +11 -14
  81. data/include/reflex.h +3 -0
  82. data/lib/reflex/application.rb +6 -2
  83. data/lib/reflex/body.rb +17 -0
  84. data/lib/reflex/fixture.rb +17 -0
  85. data/lib/reflex/view.rb +16 -1
  86. data/lib/reflex/window.rb +13 -1
  87. data/lib/reflex.rb +2 -0
  88. data/reflex.gemspec +1 -1
  89. data/samples/bats.rb +4 -3
  90. data/samples/checker.rb +4 -3
  91. data/samples/fans.rb +4 -3
  92. data/samples/fps.rb +5 -3
  93. data/samples/grid.rb +5 -4
  94. data/samples/hello.rb +1 -1
  95. data/samples/image.rb +3 -2
  96. data/samples/ios/hello/hello/main.cpp +12 -3
  97. data/samples/ios/hello/hello.xcodeproj/project.pbxproj +376 -123
  98. data/samples/key.rb +5 -4
  99. data/samples/layout.rb +3 -2
  100. data/samples/model.rb +3 -2
  101. data/samples/osx/hello/hello/main.cpp +12 -3
  102. data/samples/osx/hello/hello.xcodeproj/project.pbxproj +375 -120
  103. data/samples/physics.rb +37 -0
  104. data/samples/repl.rb +3 -2
  105. data/samples/shader.rb +4 -4
  106. data/samples/shapes.rb +4 -4
  107. data/samples/text.rb +6 -4
  108. data/samples/tree.rb +5 -4
  109. data/samples/views.rb +3 -2
  110. data/samples/visuals.rb +1 -2
  111. data/src/body.cpp +244 -0
  112. data/src/event.cpp +18 -18
  113. data/src/fixture.cpp +108 -0
  114. data/src/image_view.cpp +1 -1
  115. data/src/ios/native_window.h +2 -0
  116. data/src/ios/native_window.mm +18 -1
  117. data/src/ios/opengl_view.mm +8 -0
  118. data/src/ios/window.mm +24 -3
  119. data/src/ios/window_data.h +3 -3
  120. data/src/osx/native_window.mm +17 -1
  121. data/src/osx/window.mm +24 -3
  122. data/src/osx/window_data.h +3 -3
  123. data/src/physics/Box2D/Box2D.h +68 -0
  124. data/src/physics/Box2D/Collision/Shapes/b2ChainShape.cpp +193 -0
  125. data/src/physics/Box2D/Collision/Shapes/b2ChainShape.h +105 -0
  126. data/src/physics/Box2D/Collision/Shapes/b2CircleShape.cpp +99 -0
  127. data/src/physics/Box2D/Collision/Shapes/b2CircleShape.h +91 -0
  128. data/src/physics/Box2D/Collision/Shapes/b2EdgeShape.cpp +138 -0
  129. data/src/physics/Box2D/Collision/Shapes/b2EdgeShape.h +74 -0
  130. data/src/physics/Box2D/Collision/Shapes/b2PolygonShape.cpp +467 -0
  131. data/src/physics/Box2D/Collision/Shapes/b2PolygonShape.h +101 -0
  132. data/src/physics/Box2D/Collision/Shapes/b2Shape.h +101 -0
  133. data/src/physics/Box2D/Collision/b2BroadPhase.cpp +119 -0
  134. data/src/physics/Box2D/Collision/b2BroadPhase.h +257 -0
  135. data/src/physics/Box2D/Collision/b2CollideCircle.cpp +154 -0
  136. data/src/physics/Box2D/Collision/b2CollideEdge.cpp +698 -0
  137. data/src/physics/Box2D/Collision/b2CollidePolygon.cpp +239 -0
  138. data/src/physics/Box2D/Collision/b2Collision.cpp +252 -0
  139. data/src/physics/Box2D/Collision/b2Collision.h +277 -0
  140. data/src/physics/Box2D/Collision/b2Distance.cpp +603 -0
  141. data/src/physics/Box2D/Collision/b2Distance.h +141 -0
  142. data/src/physics/Box2D/Collision/b2DynamicTree.cpp +778 -0
  143. data/src/physics/Box2D/Collision/b2DynamicTree.h +289 -0
  144. data/src/physics/Box2D/Collision/b2TimeOfImpact.cpp +486 -0
  145. data/src/physics/Box2D/Collision/b2TimeOfImpact.h +58 -0
  146. data/src/physics/Box2D/Common/b2BlockAllocator.cpp +215 -0
  147. data/src/physics/Box2D/Common/b2BlockAllocator.h +62 -0
  148. data/src/physics/Box2D/Common/b2Draw.cpp +44 -0
  149. data/src/physics/Box2D/Common/b2Draw.h +86 -0
  150. data/src/physics/Box2D/Common/b2GrowableStack.h +85 -0
  151. data/src/physics/Box2D/Common/b2Math.cpp +94 -0
  152. data/src/physics/Box2D/Common/b2Math.h +720 -0
  153. data/src/physics/Box2D/Common/b2Settings.cpp +44 -0
  154. data/src/physics/Box2D/Common/b2Settings.h +151 -0
  155. data/src/physics/Box2D/Common/b2StackAllocator.cpp +83 -0
  156. data/src/physics/Box2D/Common/b2StackAllocator.h +60 -0
  157. data/src/physics/Box2D/Common/b2Timer.cpp +101 -0
  158. data/src/physics/Box2D/Common/b2Timer.h +50 -0
  159. data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp +53 -0
  160. data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h +39 -0
  161. data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp +53 -0
  162. data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h +39 -0
  163. data/src/physics/Box2D/Dynamics/Contacts/b2CircleContact.cpp +52 -0
  164. data/src/physics/Box2D/Dynamics/Contacts/b2CircleContact.h +39 -0
  165. data/src/physics/Box2D/Dynamics/Contacts/b2Contact.cpp +247 -0
  166. data/src/physics/Box2D/Dynamics/Contacts/b2Contact.h +349 -0
  167. data/src/physics/Box2D/Dynamics/Contacts/b2ContactSolver.cpp +838 -0
  168. data/src/physics/Box2D/Dynamics/Contacts/b2ContactSolver.h +95 -0
  169. data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp +49 -0
  170. data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h +39 -0
  171. data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp +49 -0
  172. data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h +39 -0
  173. data/src/physics/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp +49 -0
  174. data/src/physics/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h +38 -0
  175. data/src/physics/Box2D/Dynamics/Contacts/b2PolygonContact.cpp +52 -0
  176. data/src/physics/Box2D/Dynamics/Contacts/b2PolygonContact.h +39 -0
  177. data/src/physics/Box2D/Dynamics/Joints/b2DistanceJoint.cpp +260 -0
  178. data/src/physics/Box2D/Dynamics/Joints/b2DistanceJoint.h +169 -0
  179. data/src/physics/Box2D/Dynamics/Joints/b2FrictionJoint.cpp +251 -0
  180. data/src/physics/Box2D/Dynamics/Joints/b2FrictionJoint.h +119 -0
  181. data/src/physics/Box2D/Dynamics/Joints/b2GearJoint.cpp +419 -0
  182. data/src/physics/Box2D/Dynamics/Joints/b2GearJoint.h +125 -0
  183. data/src/physics/Box2D/Dynamics/Joints/b2Joint.cpp +211 -0
  184. data/src/physics/Box2D/Dynamics/Joints/b2Joint.h +226 -0
  185. data/src/physics/Box2D/Dynamics/Joints/b2MotorJoint.cpp +304 -0
  186. data/src/physics/Box2D/Dynamics/Joints/b2MotorJoint.h +133 -0
  187. data/src/physics/Box2D/Dynamics/Joints/b2MouseJoint.cpp +222 -0
  188. data/src/physics/Box2D/Dynamics/Joints/b2MouseJoint.h +129 -0
  189. data/src/physics/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp +629 -0
  190. data/src/physics/Box2D/Dynamics/Joints/b2PrismaticJoint.h +196 -0
  191. data/src/physics/Box2D/Dynamics/Joints/b2PulleyJoint.cpp +348 -0
  192. data/src/physics/Box2D/Dynamics/Joints/b2PulleyJoint.h +152 -0
  193. data/src/physics/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp +502 -0
  194. data/src/physics/Box2D/Dynamics/Joints/b2RevoluteJoint.h +204 -0
  195. data/src/physics/Box2D/Dynamics/Joints/b2RopeJoint.cpp +241 -0
  196. data/src/physics/Box2D/Dynamics/Joints/b2RopeJoint.h +114 -0
  197. data/src/physics/Box2D/Dynamics/Joints/b2WeldJoint.cpp +344 -0
  198. data/src/physics/Box2D/Dynamics/Joints/b2WeldJoint.h +126 -0
  199. data/src/physics/Box2D/Dynamics/Joints/b2WheelJoint.cpp +419 -0
  200. data/src/physics/Box2D/Dynamics/Joints/b2WheelJoint.h +210 -0
  201. data/src/physics/Box2D/Dynamics/b2Body.cpp +549 -0
  202. data/src/physics/Box2D/Dynamics/b2Body.h +860 -0
  203. data/src/physics/Box2D/Dynamics/b2ContactManager.cpp +296 -0
  204. data/src/physics/Box2D/Dynamics/b2ContactManager.h +52 -0
  205. data/src/physics/Box2D/Dynamics/b2Fixture.cpp +303 -0
  206. data/src/physics/Box2D/Dynamics/b2Fixture.h +345 -0
  207. data/src/physics/Box2D/Dynamics/b2Island.cpp +539 -0
  208. data/src/physics/Box2D/Dynamics/b2Island.h +93 -0
  209. data/src/physics/Box2D/Dynamics/b2TimeStep.h +70 -0
  210. data/src/physics/Box2D/Dynamics/b2World.cpp +1339 -0
  211. data/src/physics/Box2D/Dynamics/b2World.h +354 -0
  212. data/src/physics/Box2D/Dynamics/b2WorldCallbacks.cpp +36 -0
  213. data/src/physics/Box2D/Dynamics/b2WorldCallbacks.h +155 -0
  214. data/src/physics/Box2D/Rope/b2Rope.cpp +259 -0
  215. data/src/physics/Box2D/Rope/b2Rope.h +115 -0
  216. data/src/style.cpp +2 -2
  217. data/src/view.cpp +217 -17
  218. data/src/window.cpp +25 -15
  219. data/src/world.cpp +206 -0
  220. data/src/world.h +96 -0
  221. data/task/box2d.rake +25 -0
  222. data/test/test_view.rb +5 -5
  223. metadata +125 -3
@@ -8,13 +8,11 @@
8
8
  using namespace Rucy;
9
9
 
10
10
 
11
- static Class cStyleLength2;
12
-
13
- RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength2, cStyleLength2)
11
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength2)
14
12
 
15
13
  #define THIS to<Reflex::StyleLength2*>(self)
16
14
 
17
- #define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength2, cStyleLength2, self)
15
+ #define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength2, self)
18
16
 
19
17
 
20
18
  static
@@ -88,6 +86,8 @@ VALUE get_at(VALUE self, VALUE index)
88
86
  }
89
87
 
90
88
 
89
+ static Class cStyleLength2;
90
+
91
91
  void
92
92
  Init_style_length2 ()
93
93
  {
@@ -8,13 +8,11 @@
8
8
  using namespace Rucy;
9
9
 
10
10
 
11
- static Class cStyleLength4;
12
-
13
- RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength4, cStyleLength4)
11
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength4)
14
12
 
15
13
  #define THIS to<Reflex::StyleLength4*>(self)
16
14
 
17
- #define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength4, cStyleLength4, self)
15
+ #define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength4, self)
18
16
 
19
17
 
20
18
  static
@@ -116,6 +114,8 @@ VALUE get_at(VALUE self, VALUE index)
116
114
  }
117
115
 
118
116
 
117
+ static Class cStyleLength4;
118
+
119
119
  void
120
120
  Init_style_length4 ()
121
121
  {
@@ -8,13 +8,11 @@
8
8
  using namespace Rucy;
9
9
 
10
10
 
11
- static Class cUpdateEvent;
12
-
13
- RUCY_DEFINE_VALUE_FROM_TO(Reflex::UpdateEvent, cUpdateEvent)
11
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::UpdateEvent)
14
12
 
15
13
  #define THIS to<Reflex::UpdateEvent*>(self)
16
14
 
17
- #define CHECK RUCY_CHECK_OBJ(Reflex::UpdateEvent, cUpdateEvent, self)
15
+ #define CHECK RUCY_CHECK_OBJ(Reflex::UpdateEvent, self)
18
16
 
19
17
 
20
18
  static
@@ -50,6 +48,8 @@ VALUE dt(VALUE self)
50
48
  }
51
49
 
52
50
 
51
+ static Class cUpdateEvent;
52
+
53
53
  void
54
54
  Init_update_event ()
55
55
  {
@@ -8,6 +8,7 @@
8
8
  #include "reflex/ruby/window.h"
9
9
  #include "reflex/ruby/selector.h"
10
10
  #include "reflex/ruby/style.h"
11
+ #include "reflex/ruby/body.h"
11
12
 
12
13
 
13
14
  using namespace Rucy;
@@ -15,13 +16,11 @@ using namespace Rucy;
15
16
  using Reflex::coord;
16
17
 
17
18
 
18
- static Class cView;
19
-
20
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::View, cView)
19
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::View)
21
20
 
22
21
  #define THIS to<Reflex::View*>(self)
23
22
 
24
- #define CHECK RUCY_CHECK_OBJECT(Reflex::View, cView, self)
23
+ #define CHECK RUCY_CHECK_OBJECT(Reflex::View, self)
25
24
 
26
25
  #define CALL(fun) RUCY_WRAPPER_CALL(Reflex::View, THIS, fun)
27
26
 
@@ -46,7 +45,7 @@ static
46
45
  VALUE show(VALUE self)
47
46
  {
48
47
  CHECK;
49
- CALL(show());
48
+ THIS->show();
50
49
  return self;
51
50
  }
52
51
 
@@ -54,7 +53,7 @@ static
54
53
  VALUE hide(VALUE self)
55
54
  {
56
55
  CHECK;
57
- CALL(hide());
56
+ THIS->hide();
58
57
  return self;
59
58
  }
60
59
 
@@ -209,6 +208,20 @@ VALUE content_size(VALUE self)
209
208
  return value(THIS->content_size());
210
209
  }
211
210
 
211
+ static
212
+ VALUE make_body(VALUE self)
213
+ {
214
+ CHECK;
215
+ CALL(make_body());
216
+ }
217
+
218
+ static
219
+ VALUE clear_body(VALUE self)
220
+ {
221
+ CHECK;
222
+ THIS->clear_body();
223
+ }
224
+
212
225
  static
213
226
  VALUE set_name(VALUE self, VALUE name)
214
227
  {
@@ -351,6 +364,67 @@ VALUE window(VALUE self)
351
364
  return value(THIS->window());
352
365
  }
353
366
 
367
+ static
368
+ VALUE body(VALUE self)
369
+ {
370
+ CHECK;
371
+ return value(THIS->body());
372
+ }
373
+
374
+ static
375
+ VALUE set_density(VALUE self, VALUE value)
376
+ {
377
+ CHECK;
378
+ THIS->set_density(value.as_f(true));
379
+ return value;
380
+ }
381
+
382
+ static
383
+ VALUE set_friction(VALUE self, VALUE value)
384
+ {
385
+ CHECK;
386
+ THIS->set_friction(value.as_f(true));
387
+ return value;
388
+ }
389
+
390
+ static
391
+ VALUE set_restitution(VALUE self, VALUE value)
392
+ {
393
+ CHECK;
394
+ THIS->set_restitution(value.as_f(true));
395
+ return value;
396
+ }
397
+
398
+ static
399
+ VALUE set_gravity(VALUE self, VALUE x, VALUE y)
400
+ {
401
+ CHECK;
402
+ THIS->set_gravity(x.as_f(true), y.as_f(true));
403
+ return self;
404
+ }
405
+
406
+ static
407
+ VALUE get_gravity(VALUE self)
408
+ {
409
+ CHECK;
410
+ return value(THIS->gravity());
411
+ }
412
+
413
+ static
414
+ VALUE set_debug(VALUE self, VALUE state)
415
+ {
416
+ CHECK;
417
+ THIS->set_debug(state);
418
+ return state;
419
+ }
420
+
421
+ static
422
+ VALUE is_debug(VALUE self)
423
+ {
424
+ CHECK;
425
+ return value(THIS->is_debug());
426
+ }
427
+
354
428
  static
355
429
  VALUE on_attach(VALUE self, VALUE event)
356
430
  {
@@ -365,6 +439,20 @@ VALUE on_detach(VALUE self, VALUE event)
365
439
  CALL(on_detach(to<Reflex::Event*>(event)));
366
440
  }
367
441
 
442
+ static
443
+ VALUE on_show(VALUE self, VALUE event)
444
+ {
445
+ CHECK;
446
+ CALL(on_show(to<Reflex::Event*>(event)));
447
+ }
448
+
449
+ static
450
+ VALUE on_hide(VALUE self, VALUE event)
451
+ {
452
+ CHECK;
453
+ CALL(on_hide(to<Reflex::Event*>(event)));
454
+ }
455
+
368
456
  static
369
457
  VALUE on_update(VALUE self, VALUE event)
370
458
  {
@@ -478,9 +566,11 @@ VALUE on_capture(VALUE self, VALUE event)
478
566
  }
479
567
 
480
568
  static
481
- RUCY_DEF_clear_override_flags(cof, Reflex::View, cView);
569
+ RUCY_DEF_clear_override_flags(cof, Reflex::View);
482
570
 
483
571
 
572
+ static Class cView;
573
+
484
574
  void
485
575
  Init_view ()
486
576
  {
@@ -506,6 +596,8 @@ Init_view ()
506
596
  cView.define_method("focus?", has_focus);
507
597
  rb_define_method(cView, "resize_to_fit", RUBY_METHOD_FUNC(resize_to_fit), 0);
508
598
  rb_define_method(cView, "content_size", RUBY_METHOD_FUNC(content_size), 0);
599
+ rb_define_method(cView, "make_body", RUBY_METHOD_FUNC(make_body), 0);
600
+ rb_define_method(cView, "clear_body", RUBY_METHOD_FUNC(clear_body), 0);
509
601
  rb_define_method(cView, "name=", RUBY_METHOD_FUNC(set_name), 1);
510
602
  rb_define_method(cView, "name", RUBY_METHOD_FUNC(get_name), 0);
511
603
  rb_define_method(cView, "add_tag", RUBY_METHOD_FUNC(add_tag), 1);
@@ -522,8 +614,18 @@ Init_view ()
522
614
  rb_define_method(cView, "get_capture", RUBY_METHOD_FUNC(get_capture), 0);
523
615
  rb_define_method(cView, "parent", RUBY_METHOD_FUNC(parent), 0);
524
616
  rb_define_method(cView, "window", RUBY_METHOD_FUNC(window), 0);
525
- rb_define_method(cView, "on_attach", RUBY_METHOD_FUNC(on_attach), 1);
617
+ rb_define_method(cView, "body", RUBY_METHOD_FUNC(body), 0);
618
+ rb_define_method(cView, "density=", RUBY_METHOD_FUNC(set_density), 1);
619
+ rb_define_method(cView, "friction=", RUBY_METHOD_FUNC(set_friction), 1);
620
+ rb_define_method(cView, "restitution=", RUBY_METHOD_FUNC(set_restitution), 1);
621
+ rb_define_method(cView, "set_gravity", RUBY_METHOD_FUNC(set_gravity), 2);
622
+ rb_define_method(cView, "gravity", RUBY_METHOD_FUNC(get_gravity), 0);
623
+ rb_define_method(cView, "debug=", RUBY_METHOD_FUNC(set_debug), 1);
624
+ cView.define_method("debug?", is_debug);
625
+ cView.define_method("on_attach!", on_attach);
526
626
  rb_define_method(cView, "on_detach", RUBY_METHOD_FUNC(on_detach), 1);
627
+ rb_define_method(cView, "on_show", RUBY_METHOD_FUNC(on_show), 1);
628
+ rb_define_method(cView, "on_hide", RUBY_METHOD_FUNC(on_hide), 1);
527
629
  rb_define_method(cView, "on_update", RUBY_METHOD_FUNC(on_update), 1);
528
630
  rb_define_method(cView, "on_draw", RUBY_METHOD_FUNC(on_draw), 1);
529
631
  rb_define_method(cView, "on_move", RUBY_METHOD_FUNC(on_move), 1);
@@ -11,13 +11,11 @@ using namespace Rucy;
11
11
  using Reflex::coord;
12
12
 
13
13
 
14
- static Class cWheelEvent;
15
-
16
- RUCY_DEFINE_VALUE_FROM_TO(Reflex::WheelEvent, cWheelEvent)
14
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::WheelEvent)
17
15
 
18
16
  #define THIS to<Reflex::WheelEvent*>(self)
19
17
 
20
- #define CHECK RUCY_CHECK_OBJ(Reflex::WheelEvent, cWheelEvent, self)
18
+ #define CHECK RUCY_CHECK_OBJ(Reflex::WheelEvent, self)
21
19
 
22
20
 
23
21
  static
@@ -111,6 +109,8 @@ VALUE position(VALUE self)
111
109
  }
112
110
 
113
111
 
112
+ static Class cWheelEvent;
113
+
114
114
  void
115
115
  Init_wheel_event ()
116
116
  {
@@ -12,13 +12,11 @@ using namespace Rucy;
12
12
  using Reflex::coord;
13
13
 
14
14
 
15
- static Class cWindow;
16
-
17
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Window, cWindow)
15
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Window)
18
16
 
19
17
  #define THIS to<Reflex::Window*>(self)
20
18
 
21
- #define CHECK RUCY_CHECK_OBJECT(Reflex::Window, cWindow, self)
19
+ #define CHECK RUCY_CHECK_OBJECT(Reflex::Window, self)
22
20
 
23
21
  #define CALL(fun) RUCY_WRAPPER_CALL(Reflex::Window, THIS, fun)
24
22
 
@@ -30,26 +28,26 @@ VALUE alloc(VALUE klass)
30
28
  }
31
29
 
32
30
  static
33
- VALUE close(VALUE self)
31
+ VALUE show(VALUE self)
34
32
  {
35
33
  CHECK;
36
- CALL(close());
34
+ THIS->show();
37
35
  return self;
38
36
  }
39
37
 
40
38
  static
41
- VALUE show(VALUE self)
39
+ VALUE hide(VALUE self)
42
40
  {
43
41
  CHECK;
44
- CALL(show());
42
+ THIS->hide();
45
43
  return self;
46
44
  }
47
45
 
48
46
  static
49
- VALUE hide(VALUE self)
47
+ VALUE close(VALUE self)
50
48
  {
51
49
  CHECK;
52
- CALL(hide());
50
+ THIS->close();
53
51
  return self;
54
52
  }
55
53
 
@@ -118,6 +116,27 @@ VALUE painter(VALUE self)
118
116
  return value(THIS->painter());
119
117
  }
120
118
 
119
+ static
120
+ VALUE on_show(VALUE self, VALUE event)
121
+ {
122
+ CHECK;
123
+ CALL(on_show(to<Reflex::Event*>(event)));
124
+ }
125
+
126
+ static
127
+ VALUE on_hide(VALUE self, VALUE event)
128
+ {
129
+ CHECK;
130
+ CALL(on_hide(to<Reflex::Event*>(event)));
131
+ }
132
+
133
+ static
134
+ VALUE on_close(VALUE self, VALUE event)
135
+ {
136
+ CHECK;
137
+ CALL(on_close(to<Reflex::Event*>(event)));
138
+ }
139
+
121
140
  static
122
141
  VALUE on_update(VALUE self, VALUE event)
123
142
  {
@@ -203,8 +222,10 @@ VALUE on_wheel(VALUE self, VALUE event)
203
222
  }
204
223
 
205
224
  static
206
- RUCY_DEF_clear_override_flags(cof, Reflex::Window, cWindow);
225
+ RUCY_DEF_clear_override_flags(cof, Reflex::Window);
226
+
207
227
 
228
+ static Class cWindow;
208
229
 
209
230
  void
210
231
  Init_window ()
@@ -213,9 +234,9 @@ Init_window ()
213
234
 
214
235
  cWindow = rb_define_class_under(mReflex, "Window", rb_cObject);
215
236
  rb_define_alloc_func(cWindow, alloc);
216
- rb_define_method(cWindow, "close", RUBY_METHOD_FUNC(close), 0);
217
237
  rb_define_method(cWindow, "show", RUBY_METHOD_FUNC(show), 0);
218
238
  rb_define_method(cWindow, "hide", RUBY_METHOD_FUNC(hide), 0);
239
+ rb_define_method(cWindow, "close", RUBY_METHOD_FUNC(close), 0);
219
240
  rb_define_method(cWindow, "redraw", RUBY_METHOD_FUNC(redraw), 0);
220
241
  rb_define_method(cWindow, "title=", RUBY_METHOD_FUNC(set_title), 1);
221
242
  rb_define_method(cWindow, "title", RUBY_METHOD_FUNC(get_title), 0);
@@ -225,6 +246,9 @@ Init_window ()
225
246
  rb_define_method(cWindow, "root", RUBY_METHOD_FUNC(root), 0);
226
247
  rb_define_method(cWindow, "focus", RUBY_METHOD_FUNC(focus), 0);
227
248
  rb_define_method(cWindow, "painter", RUBY_METHOD_FUNC(painter), 0);
249
+ cWindow.define_method("on_show!", on_show);
250
+ rb_define_method(cWindow, "on_hide", RUBY_METHOD_FUNC(on_hide), 1);
251
+ rb_define_method(cWindow, "on_close", RUBY_METHOD_FUNC(on_close), 1);
228
252
  rb_define_method(cWindow, "on_update", RUBY_METHOD_FUNC(on_update), 1);
229
253
  rb_define_method(cWindow, "on_draw", RUBY_METHOD_FUNC(on_draw), 1);
230
254
  rb_define_method(cWindow, "on_move", RUBY_METHOD_FUNC(on_move), 1);
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
- = Reflex - A Graphical User Interface Tool Kit.
2
+ # Reflex - A Graphical User Interface Tool Kit.
3
3
 
4
- == by snori@xord.org
4
+ ## by snori@xord.org
data/Rakefile CHANGED
@@ -17,6 +17,7 @@ include Xot::Rake
17
17
  MODULES = [Xot, Rucy, Rays, Reflex].map {|m| m.const_get :Module}
18
18
  MODULE = MODULES.last
19
19
  GEMNAME = 'reflexion'
20
+ INCDIRS = ['src/physics']
20
21
  TESTS_ALONE = ['test/test_reflex.rb']
21
22
 
22
23
 
@@ -25,4 +26,4 @@ task :default => :build
25
26
  task :build => :ext
26
27
 
27
28
 
28
- MODULES.each {|m| m.load_tasks :lib, :ext, :test, :doc, :gem}
29
+ MODULES.each {|m| m.load_tasks :lib, :ext, :test, :doc, :gem, :box2d}
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
@@ -8,13 +8,11 @@
8
8
  using namespace Rucy;
9
9
 
10
10
 
11
- static Class cApplication;
12
-
13
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Application, cApplication)
11
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Application)
14
12
 
15
13
  #define THIS to<Reflex::Application*>(self)
16
14
 
17
- #define CHECK RUCY_CHECK_OBJECT(Reflex::Application, cApplication, self)
15
+ #define CHECK RUCY_CHECK_OBJECT(Reflex::Application, self)
18
16
 
19
17
  #define CALL(fun) RUCY_WRAPPER_CALL(Reflex::Application, THIS, fun)
20
18
 
@@ -101,6 +99,8 @@ RUCY_DEF0(instance)
101
99
  RUCY_END
102
100
 
103
101
 
102
+ static Class cApplication;
103
+
104
104
  void
105
105
  Init_application ()
106
106
  {
@@ -109,13 +109,13 @@ Init_application ()
109
109
  cApplication = mReflex.define_class("Application");
110
110
  cApplication.define_alloc_func(alloc);
111
111
  cApplication.define_method("start", start);
112
- cApplication.define_method("quit", quit);
112
+ cApplication.define_method("quit", quit);
113
113
  cApplication.define_method("name=", set_name);
114
114
  cApplication.define_method("name", get_name);
115
- cApplication.define_method("on_start", on_start);
116
- cApplication.define_method("on_quit", on_quit);
115
+ cApplication.define_method("on_start!", on_start);
116
+ cApplication.define_method("on_quit", on_quit);
117
117
  cApplication.define_method("on_preference", on_preference);
118
- cApplication.define_method("on_about", on_about);
118
+ cApplication.define_method("on_about", on_about);
119
119
  cApplication.define_singleton_method("instance", instance);
120
120
  }
121
121
 
@@ -0,0 +1,181 @@
1
+ #include "reflex/ruby/body.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include "rays/ruby/point.h"
6
+ #include "reflex/ruby/fixture.h"
7
+ #include "defs.h"
8
+
9
+
10
+ using namespace Rucy;
11
+
12
+
13
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::Body)
14
+
15
+ #define THIS to<Reflex::Body*>(self)
16
+
17
+ #define CHECK RUCY_CHECK_OBJ(Reflex::Body, self)
18
+
19
+
20
+ static
21
+ RUCY_DEF1(initialize_copy, obj)
22
+ {
23
+ CHECK;
24
+ *THIS = to<Reflex::Body&>(obj);
25
+ return self;
26
+ }
27
+ RUCY_END
28
+
29
+ static
30
+ RUCY_DEF2(add_box, width, height)
31
+ {
32
+ CHECK;
33
+ return value(THIS->add_box(width.as_f(true), height.as_f(true)));
34
+ }
35
+ RUCY_END
36
+
37
+ static
38
+ RUCY_DEF1(add_circle, size)
39
+ {
40
+ CHECK;
41
+ return value(THIS->add_circle(size.as_f(true)));
42
+ }
43
+ RUCY_END
44
+
45
+ static
46
+ RUCY_DEF0(clear_fixtures)
47
+ {
48
+ CHECK;
49
+ THIS->clear_fixtures();
50
+ return self;
51
+ }
52
+ RUCY_END
53
+
54
+ static
55
+ RUCY_DEF0(get_position)
56
+ {
57
+ CHECK;
58
+ return value(THIS->position());
59
+ }
60
+ RUCY_END
61
+
62
+ static
63
+ RUCY_DEF0(get_angle)
64
+ {
65
+ CHECK;
66
+ return value(THIS->angle());
67
+ }
68
+ RUCY_END
69
+
70
+ static
71
+ RUCY_DEF1(set_static, state)
72
+ {
73
+ CHECK;
74
+ THIS->set_static(state);
75
+ return state;
76
+ }
77
+ RUCY_END
78
+
79
+ static
80
+ RUCY_DEF0(is_static)
81
+ {
82
+ CHECK;
83
+ return value(THIS->is_static());
84
+ }
85
+ RUCY_END
86
+
87
+ static
88
+ RUCY_DEF1(set_dynamic, state)
89
+ {
90
+ CHECK;
91
+ THIS->set_dynamic(state);
92
+ return state;
93
+ }
94
+ RUCY_END
95
+
96
+ static
97
+ RUCY_DEF0(is_dynamic)
98
+ {
99
+ CHECK;
100
+ return value(THIS->is_dynamic());
101
+ }
102
+ RUCY_END
103
+
104
+ static
105
+ RUCY_DEF1(set_density, density)
106
+ {
107
+ CHECK;
108
+ THIS->set_density(density.as_f(true));
109
+ return self;
110
+ }
111
+ RUCY_END
112
+
113
+ static
114
+ RUCY_DEF1(set_friction, friction)
115
+ {
116
+ CHECK;
117
+ THIS->set_friction(friction.as_f(true));
118
+ return self;
119
+ }
120
+ RUCY_END
121
+
122
+ static
123
+ RUCY_DEF1(set_restitution, restitution)
124
+ {
125
+ CHECK;
126
+ THIS->set_restitution(restitution.as_f(true));
127
+ return self;
128
+ }
129
+ RUCY_END
130
+
131
+ static
132
+ RUCY_DEF0(each)
133
+ {
134
+ CHECK;
135
+
136
+ Value ret;
137
+ Reflex::Body::iterator end = THIS->end();
138
+ for (Reflex::Body::iterator it = THIS->begin(); it != end; ++it)
139
+ ret = rb_yield(value(*it));
140
+ return ret;
141
+ }
142
+ RUCY_END
143
+
144
+
145
+ static Class cBody;
146
+
147
+ void
148
+ Init_body ()
149
+ {
150
+ Module mReflex = define_module("Reflex");
151
+
152
+ cBody = mReflex.define_class("Body");
153
+ cBody.define_private_method("initialize_copy", initialize_copy);
154
+ cBody.define_method("add_box", add_box);
155
+ cBody.define_method("add_circle", add_circle);
156
+ cBody.define_method("clear_fixtures", clear_fixtures);
157
+ cBody.define_method("position", get_position);
158
+ cBody.define_method("angle", get_angle);
159
+ cBody.define_method("static=", set_static);
160
+ cBody.define_method("static?", is_static);
161
+ cBody.define_method("dynamic=", set_dynamic);
162
+ cBody.define_method("dynamic?", is_dynamic);
163
+ cBody.define_method("density=", set_density);
164
+ cBody.define_method("friction=", set_friction);
165
+ cBody.define_method("restitution=", set_restitution);
166
+ cBody.define_method("each", each);
167
+ }
168
+
169
+
170
+ namespace Reflex
171
+ {
172
+
173
+
174
+ Class
175
+ body_class ()
176
+ {
177
+ return cBody;
178
+ }
179
+
180
+
181
+ }// Reflex
@@ -9,13 +9,11 @@
9
9
  using namespace Rucy;
10
10
 
11
11
 
12
- static Class cCaptureEvent;
13
-
14
- RUCY_DEFINE_VALUE_FROM_TO(Reflex::CaptureEvent, cCaptureEvent)
12
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::CaptureEvent)
15
13
 
16
14
  #define THIS to<Reflex::CaptureEvent*>(self)
17
15
 
18
- #define CHECK RUCY_CHECK_OBJ(Reflex::CaptureEvent, cCaptureEvent, self)
16
+ #define CHECK RUCY_CHECK_OBJ(Reflex::CaptureEvent, self)
19
17
 
20
18
 
21
19
  static
@@ -64,6 +62,8 @@ RUCY_DEF0(end)
64
62
  RUCY_END
65
63
 
66
64
 
65
+ static Class cCaptureEvent;
66
+
67
67
  void
68
68
  Init_capture_event ()
69
69
  {
@@ -10,13 +10,11 @@
10
10
  using namespace Rucy;
11
11
 
12
12
 
13
- static Class cDrawEvent;
14
-
15
- RUCY_DEFINE_VALUE_FROM_TO(Reflex::DrawEvent, cDrawEvent)
13
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::DrawEvent)
16
14
 
17
15
  #define THIS to<Reflex::DrawEvent*>(self)
18
16
 
19
- #define CHECK RUCY_CHECK_OBJ(Reflex::DrawEvent, cDrawEvent, self)
17
+ #define CHECK RUCY_CHECK_OBJ(Reflex::DrawEvent, self)
20
18
 
21
19
 
22
20
  static
@@ -80,6 +78,8 @@ RUCY_DEF0(fps)
80
78
  RUCY_END
81
79
 
82
80
 
81
+ static Class cDrawEvent;
82
+
83
83
  void
84
84
  Init_draw_event ()
85
85
  {