reflexion 0.5.3 → 0.7.0

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.
Files changed (309) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/application.cpp +56 -7
  3. data/.doc/ext/reflex/capture_event.cpp +1 -1
  4. data/.doc/ext/reflex/chase_constraint.cpp +84 -0
  5. data/.doc/ext/reflex/clipboard.cpp +65 -0
  6. data/.doc/ext/reflex/color_event.cpp +76 -0
  7. data/.doc/ext/reflex/color_picker.cpp +113 -0
  8. data/.doc/ext/reflex/constraint.cpp +135 -0
  9. data/.doc/ext/reflex/contact_event.cpp +1 -1
  10. data/.doc/ext/reflex/control_change_event.cpp +1 -1
  11. data/.doc/ext/reflex/device.cpp +1 -1
  12. data/.doc/ext/reflex/device_event.cpp +1 -1
  13. data/.doc/ext/reflex/draw_event.cpp +1 -1
  14. data/.doc/ext/reflex/ellipse_shape.cpp +1 -1
  15. data/.doc/ext/reflex/event.cpp +1 -1
  16. data/.doc/ext/reflex/file_dialog.cpp +181 -0
  17. data/.doc/ext/reflex/file_event.cpp +103 -0
  18. data/.doc/ext/reflex/filter.cpp +1 -1
  19. data/.doc/ext/reflex/focus_event.cpp +1 -1
  20. data/.doc/ext/reflex/frame_event.cpp +1 -1
  21. data/.doc/ext/reflex/gamepad.cpp +48 -0
  22. data/.doc/ext/reflex/image_view.cpp +1 -1
  23. data/.doc/ext/reflex/key_event.cpp +1 -274
  24. data/.doc/ext/reflex/line_shape.cpp +1 -1
  25. data/.doc/ext/reflex/link_constraint.cpp +178 -0
  26. data/.doc/ext/reflex/menu.cpp +303 -0
  27. data/.doc/ext/reflex/midi.cpp +9 -2
  28. data/.doc/ext/reflex/midi_event.cpp +1 -1
  29. data/.doc/ext/reflex/motion_event.cpp +1 -1
  30. data/.doc/ext/reflex/native.cpp +40 -10
  31. data/.doc/ext/reflex/note_event.cpp +1 -1
  32. data/.doc/ext/reflex/pin.cpp +156 -0
  33. data/.doc/ext/reflex/pointer.cpp +3 -1
  34. data/.doc/ext/reflex/pointer_event.cpp +3 -3
  35. data/.doc/ext/reflex/polygon_shape.cpp +1 -1
  36. data/.doc/ext/reflex/rect_shape.cpp +1 -1
  37. data/.doc/ext/reflex/reflex.cpp +606 -237
  38. data/.doc/ext/reflex/screen.cpp +27 -1
  39. data/.doc/ext/reflex/scroll_event.cpp +1 -1
  40. data/.doc/ext/reflex/selector.cpp +5 -5
  41. data/.doc/ext/reflex/shape.cpp +1 -1
  42. data/.doc/ext/reflex/snap_constraint.cpp +125 -0
  43. data/.doc/ext/reflex/style.cpp +1 -1
  44. data/.doc/ext/reflex/style_length.cpp +4 -3
  45. data/.doc/ext/reflex/text_event.cpp +104 -0
  46. data/.doc/ext/reflex/timer.cpp +1 -1
  47. data/.doc/ext/reflex/timer_event.cpp +1 -1
  48. data/.doc/ext/reflex/update_event.cpp +1 -1
  49. data/.doc/ext/reflex/view.cpp +206 -79
  50. data/.doc/ext/reflex/wheel_constraint.cpp +142 -0
  51. data/.doc/ext/reflex/wheel_event.cpp +1 -1
  52. data/.doc/ext/reflex/window.cpp +282 -31
  53. data/.github/workflows/release-gem.yml +2 -40
  54. data/.github/workflows/tag.yml +5 -28
  55. data/.github/workflows/test.yml +1 -28
  56. data/ChangeLog.md +79 -0
  57. data/Gemfile.lock +13 -8
  58. data/README.md +1 -0
  59. data/Rakefile +13 -2
  60. data/Reflex.podspec +2 -2
  61. data/VERSION +1 -1
  62. data/ext/reflex/application.cpp +62 -7
  63. data/ext/reflex/capture_event.cpp +1 -1
  64. data/ext/reflex/chase_constraint.cpp +89 -0
  65. data/ext/reflex/clipboard.cpp +69 -0
  66. data/ext/reflex/color_event.cpp +80 -0
  67. data/ext/reflex/color_picker.cpp +121 -0
  68. data/ext/reflex/constraint.cpp +146 -0
  69. data/ext/reflex/contact_event.cpp +1 -1
  70. data/ext/reflex/control_change_event.cpp +1 -1
  71. data/ext/reflex/device.cpp +1 -1
  72. data/ext/reflex/device_event.cpp +1 -1
  73. data/ext/reflex/draw_event.cpp +1 -1
  74. data/ext/reflex/ellipse_shape.cpp +1 -1
  75. data/ext/reflex/event.cpp +1 -1
  76. data/ext/reflex/extconf.rb +4 -2
  77. data/ext/reflex/file_dialog.cpp +194 -0
  78. data/ext/reflex/file_event.cpp +108 -0
  79. data/ext/reflex/filter.cpp +1 -1
  80. data/ext/reflex/focus_event.cpp +1 -1
  81. data/ext/reflex/frame_event.cpp +1 -1
  82. data/ext/reflex/gamepad.cpp +50 -0
  83. data/ext/reflex/image_view.cpp +1 -1
  84. data/ext/reflex/key_event.cpp +1 -275
  85. data/ext/reflex/line_shape.cpp +1 -1
  86. data/ext/reflex/link_constraint.cpp +194 -0
  87. data/ext/reflex/menu.cpp +331 -0
  88. data/ext/reflex/midi.cpp +11 -3
  89. data/ext/reflex/midi_event.cpp +1 -1
  90. data/ext/reflex/motion_event.cpp +1 -1
  91. data/ext/reflex/native.cpp +40 -10
  92. data/ext/reflex/note_event.cpp +1 -1
  93. data/ext/reflex/pin.cpp +165 -0
  94. data/ext/reflex/pointer.cpp +3 -1
  95. data/ext/reflex/pointer_event.cpp +3 -3
  96. data/ext/reflex/polygon_shape.cpp +1 -1
  97. data/ext/reflex/rect_shape.cpp +1 -1
  98. data/ext/reflex/reflex.cpp +608 -237
  99. data/ext/reflex/screen.cpp +31 -2
  100. data/ext/reflex/scroll_event.cpp +1 -1
  101. data/ext/reflex/selector.cpp +5 -5
  102. data/ext/reflex/selector.h +10 -10
  103. data/ext/reflex/shape.cpp +1 -1
  104. data/ext/reflex/snap_constraint.cpp +135 -0
  105. data/ext/reflex/style.cpp +1 -1
  106. data/ext/reflex/style_length.cpp +4 -3
  107. data/ext/reflex/text_event.cpp +111 -0
  108. data/ext/reflex/timer.cpp +1 -1
  109. data/ext/reflex/timer_event.cpp +1 -1
  110. data/ext/reflex/update_event.cpp +1 -1
  111. data/ext/reflex/view.cpp +236 -96
  112. data/ext/reflex/wheel_constraint.cpp +154 -0
  113. data/ext/reflex/wheel_event.cpp +1 -1
  114. data/ext/reflex/window.cpp +318 -40
  115. data/include/reflex/application.h +19 -0
  116. data/include/reflex/clipboard.h +53 -0
  117. data/include/reflex/color_picker.h +65 -0
  118. data/include/reflex/constraint.h +275 -0
  119. data/include/reflex/defs.h +204 -195
  120. data/include/reflex/event.h +180 -88
  121. data/include/reflex/file_dialog.h +73 -0
  122. data/include/reflex/gamepad.h +3 -0
  123. data/include/reflex/menu.h +120 -0
  124. data/include/reflex/midi.h +3 -0
  125. data/include/reflex/pin.h +68 -0
  126. data/include/reflex/pointer.h +4 -0
  127. data/include/reflex/reflex.h +2 -0
  128. data/include/reflex/ruby/application.h +6 -1
  129. data/include/reflex/ruby/clipboard.h +23 -0
  130. data/include/reflex/ruby/color_picker.h +89 -0
  131. data/include/reflex/ruby/constraint.h +94 -0
  132. data/include/reflex/ruby/event.h +62 -29
  133. data/include/reflex/ruby/file_dialog.h +89 -0
  134. data/include/reflex/ruby/gamepad.h +46 -0
  135. data/include/reflex/ruby/menu.h +103 -0
  136. data/include/reflex/ruby/pin.h +40 -0
  137. data/include/reflex/ruby/reflex.h +3 -0
  138. data/include/reflex/ruby/view.h +123 -39
  139. data/include/reflex/ruby/window.h +96 -19
  140. data/include/reflex/ruby.h +3 -0
  141. data/include/reflex/screen.h +11 -2
  142. data/include/reflex/view.h +66 -27
  143. data/include/reflex/window.h +57 -12
  144. data/include/reflex.h +8 -0
  145. data/lib/reflex/application.rb +5 -5
  146. data/lib/reflex/autoinit.rb +3 -1
  147. data/lib/reflex/button.rb +3 -3
  148. data/lib/reflex/chase_constraint.rb +15 -0
  149. data/lib/reflex/clipboard.rb +19 -0
  150. data/lib/reflex/color_event.rb +16 -0
  151. data/lib/reflex/color_picker.rb +45 -0
  152. data/lib/reflex/constraint.rb +29 -0
  153. data/lib/reflex/control_change_event.rb +17 -0
  154. data/lib/reflex/extension.rb +1 -1
  155. data/lib/reflex/file_dialog.rb +70 -0
  156. data/lib/reflex/file_event.rb +37 -0
  157. data/lib/reflex/helper.rb +79 -0
  158. data/lib/reflex/key_event.rb +14 -14
  159. data/lib/reflex/link_constraint.rb +31 -0
  160. data/lib/reflex/menu.rb +92 -0
  161. data/lib/reflex/model.rb +19 -19
  162. data/lib/reflex/note_event.rb +1 -1
  163. data/lib/reflex/pin.rb +39 -0
  164. data/lib/reflex/pointer.rb +30 -1
  165. data/lib/reflex/pointer_event.rb +13 -2
  166. data/lib/reflex/reflex.rb +5 -0
  167. data/lib/reflex/shape.rb +14 -14
  168. data/lib/reflex/snap_constraint.rb +28 -0
  169. data/lib/reflex/style.rb +16 -16
  170. data/lib/reflex/text_event.rb +40 -0
  171. data/lib/reflex/timer.rb +3 -3
  172. data/lib/reflex/view.rb +85 -18
  173. data/lib/reflex/wheel_constraint.rb +28 -0
  174. data/lib/reflex/wheel_event.rb +19 -1
  175. data/lib/reflex/window.rb +25 -13
  176. data/lib/reflex.rb +23 -8
  177. data/pod.rake +1 -1
  178. data/reflex.gemspec +4 -4
  179. data/samples/constraint.rb +152 -0
  180. data/samples/ime.rb +100 -0
  181. data/samples/ios/hello/hello.xcodeproj/project.pbxproj +236 -224
  182. data/samples/menu.rb +32 -0
  183. data/samples/model.rb +3 -3
  184. data/samples/test/alert.rb +93 -0
  185. data/samples/test/always_on.rb +76 -0
  186. data/samples/test/app_background.rb +51 -0
  187. data/samples/test/boundary.rb +75 -0
  188. data/samples/test/callback_exception.rb +101 -0
  189. data/samples/test/cancel.rb +53 -0
  190. data/samples/test/color_picker.rb +63 -0
  191. data/samples/test/file_dialog.rb +102 -0
  192. data/samples/window_style.rb +156 -0
  193. data/src/application.cpp +180 -20
  194. data/src/application.h +95 -5
  195. data/src/clipboard.cpp +81 -0
  196. data/src/color_picker.cpp +113 -0
  197. data/src/color_picker.h +36 -0
  198. data/src/constraint.cpp +1662 -0
  199. data/src/constraint.h +64 -0
  200. data/src/event.cpp +416 -252
  201. data/src/event.h +13 -2
  202. data/src/file_dialog.cpp +163 -0
  203. data/src/file_dialog.h +52 -0
  204. data/src/gamepad.cpp +42 -5
  205. data/src/gamepad.h +4 -0
  206. data/src/ios/app_delegate.mm +5 -3
  207. data/src/ios/application.mm +29 -0
  208. data/src/ios/clipboard.mm +44 -0
  209. data/src/ios/color_picker.mm +19 -0
  210. data/src/ios/event.h +6 -2
  211. data/src/ios/event.mm +31 -12
  212. data/src/ios/file_dialog.mm +21 -0
  213. data/src/ios/gamepad.mm +4 -4
  214. data/src/ios/menu.mm +41 -0
  215. data/src/ios/reflex.mm +8 -0
  216. data/src/ios/screen.mm +26 -0
  217. data/src/ios/view_controller.mm +47 -42
  218. data/src/ios/window.mm +44 -9
  219. data/src/menu.cpp +387 -0
  220. data/src/menu.h +81 -0
  221. data/src/midi.cpp +61 -31
  222. data/src/osx/app_delegate.h +4 -0
  223. data/src/osx/app_delegate.mm +168 -139
  224. data/src/osx/application.mm +103 -5
  225. data/src/osx/clipboard.mm +45 -0
  226. data/src/osx/color_picker.mm +112 -0
  227. data/src/osx/event.h +10 -0
  228. data/src/osx/event.mm +114 -30
  229. data/src/osx/file_dialog.mm +168 -0
  230. data/src/osx/gamepad.mm +2 -2
  231. data/src/osx/gamepad_hid.mm +1 -1
  232. data/src/osx/menu.h +25 -0
  233. data/src/osx/menu.mm +516 -0
  234. data/src/osx/native_window.h +16 -2
  235. data/src/osx/native_window.mm +141 -57
  236. data/src/osx/opengl_view.h +2 -1
  237. data/src/osx/opengl_view.mm +229 -37
  238. data/src/osx/reflex.mm +38 -0
  239. data/src/osx/screen.mm +36 -0
  240. data/src/osx/window.mm +117 -24
  241. data/src/pin.cpp +137 -0
  242. data/src/pointer.cpp +36 -16
  243. data/src/pointer.h +10 -0
  244. data/src/rays.h +46 -0
  245. data/src/sdl/application.cpp +73 -8
  246. data/src/sdl/clipboard.cpp +39 -0
  247. data/src/sdl/color_picker.cpp +18 -0
  248. data/src/sdl/event.cpp +44 -6
  249. data/src/sdl/event.h +18 -3
  250. data/src/sdl/file_dialog.cpp +20 -0
  251. data/src/sdl/gamepad.cpp +3 -7
  252. data/src/sdl/menu.cpp +40 -0
  253. data/src/sdl/reflex.cpp +20 -0
  254. data/src/sdl/screen.cpp +36 -0
  255. data/src/sdl/window.cpp +168 -37
  256. data/src/shape.cpp +15 -10
  257. data/src/view.cpp +583 -233
  258. data/src/view.h +22 -4
  259. data/src/vk.h +416 -0
  260. data/src/win32/application.cpp +167 -12
  261. data/src/win32/application.h +20 -0
  262. data/src/win32/clipboard.cpp +210 -0
  263. data/src/win32/color_picker.cpp +82 -0
  264. data/src/win32/event.cpp +123 -11
  265. data/src/win32/event.h +22 -3
  266. data/src/win32/file_dialog.cpp +226 -0
  267. data/src/win32/gamepad.cpp +9 -2
  268. data/src/win32/menu.cpp +490 -0
  269. data/src/win32/menu.h +35 -0
  270. data/src/win32/opengl.cpp +2 -9
  271. data/src/win32/reflex.cpp +44 -3
  272. data/src/win32/screen.cpp +164 -3
  273. data/src/win32/screen.h +8 -0
  274. data/src/win32/tray.cpp +191 -0
  275. data/src/win32/tray.h +22 -0
  276. data/src/win32/vk.cpp +11 -0
  277. data/src/win32/window.cpp +858 -135
  278. data/src/win32/window.h +9 -0
  279. data/src/window.cpp +929 -183
  280. data/src/window.h +77 -33
  281. data/src/world.cpp +86 -15
  282. data/src/world.h +9 -2
  283. data/test/helper.rb +24 -0
  284. data/test/test_application.rb +101 -1
  285. data/test/test_chase_constraint.rb +122 -0
  286. data/test/test_clipboard.rb +54 -0
  287. data/test/test_color_event.rb +36 -0
  288. data/test/test_color_picker.rb +62 -0
  289. data/test/test_constraint.rb +184 -0
  290. data/test/test_event.rb +1 -1
  291. data/test/test_file_dialog.rb +48 -0
  292. data/test/test_file_event.rb +43 -0
  293. data/test/test_has_text_preedit.rb +54 -0
  294. data/test/test_key_event.rb +23 -2
  295. data/test/test_link_constraint.rb +237 -0
  296. data/test/test_menu.rb +237 -0
  297. data/test/test_pin.rb +65 -0
  298. data/test/test_pointer.rb +50 -26
  299. data/test/test_pointer_event.rb +25 -10
  300. data/test/test_reflex.rb +36 -0
  301. data/test/test_screen.rb +24 -2
  302. data/test/test_snap_constraint.rb +140 -0
  303. data/test/test_text_event.rb +54 -0
  304. data/test/test_view.rb +152 -25
  305. data/test/test_wheel_constraint.rb +125 -0
  306. data/test/test_wheel_event.rb +24 -10
  307. data/test/test_window.rb +205 -43
  308. metadata +154 -10
  309. data/.github/workflows/utils.rb +0 -127
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15c42394de71e92c5f03509d7e79930a02b00d849846647a1722d2b381aded79
4
- data.tar.gz: ca3a4f10526c32f2307bb9f70f305e66063142b62713f4f9c90bf66ca96646f5
3
+ metadata.gz: 5228288ca6eaf922b07a4e5934fc402f16a79261541db581691fdc77df985a41
4
+ data.tar.gz: 9a4918d2d0c66b5aec2dda5b4cf9afd080d9c7fd8ef863517791b2bcf34561f4
5
5
  SHA512:
6
- metadata.gz: f31929a116e8213bfc46812b43da782c7c1fcae7b25a9ff22dda2a5c069362abc74f32dd645cfce1b28ace8e8a6cf4f9eacaac5967e6658f1ce7e45314dfe584
7
- data.tar.gz: 29879e13e7fd53991fd28f17cc956fcb2acdaf785cfb4fc657f52616e9c0698cdd223f8928ac5815012a8fb85e4d268c675eb1d77594a3c671a150a9075074ff
6
+ metadata.gz: 6520e51eb23b4215b34116fd37b34fe1a06532e554186bf47ac0b956e5f9a71e97d6c7aae4465550e8d4ed86f763e86f605d2e811959fbe42fe50fb253bcfb67
7
+ data.tar.gz: 371a81c13682e5c6cceda6549fcf2e6378574d3bf4181bcedbf4e09f175a7ba975869d76240692c72ce312de6dc0dec079e11e546aaba4bb86eb0c038c28e085
@@ -1,6 +1,7 @@
1
1
  #include "reflex/ruby/application.h"
2
2
 
3
3
 
4
+ #include "reflex/ruby/menu.h"
4
5
  #include "reflex/ruby/window.h"
5
6
  #include "defs.h"
6
7
 
@@ -9,8 +10,8 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Application)
9
10
 
10
11
  #define THIS to<Reflex::Application*>(self)
11
12
 
12
- #define CHECK_OBJ RUCY_CHECK_OBJ( Reflex::Application, self)
13
- #define CHECK RUCY_CHECK_OBJECT(Reflex::Application, self)
13
+ #define CHECK_PTR RUCY_CHECK_PTR(Reflex::Application, self)
14
+ #define CHECK RUCY_CHECK_OBJ(Reflex::Application, self)
14
15
 
15
16
  #define CALL(fun) RUCY_CALL_SUPER(THIS, fun)
16
17
 
@@ -24,7 +25,7 @@ VALUE alloc(VALUE klass)
24
25
  static
25
26
  VALUE start(VALUE self)
26
27
  {
27
- CHECK_OBJ;
28
+ CHECK_PTR;
28
29
  CALL(start());
29
30
  return self;
30
31
  }
@@ -52,6 +53,51 @@ VALUE get_name(VALUE self)
52
53
  return value(THIS->name());
53
54
  }
54
55
 
56
+ static
57
+ VALUE set_menu(VALUE self, VALUE menu)
58
+ {
59
+ CHECK;
60
+ THIS->set_menu(menu ? to<Reflex::Menu*>(menu) : NULL);
61
+ return menu;
62
+ }
63
+
64
+ static
65
+ VALUE get_menu(VALUE self)
66
+ {
67
+ CHECK;
68
+ return value(THIS->menu());
69
+ }
70
+
71
+ static
72
+ VALUE set_background(VALUE self, VALUE state)
73
+ {
74
+ CHECK;
75
+ THIS->set_background(to<bool>(state));
76
+ return state;
77
+ }
78
+
79
+ static
80
+ VALUE is_background(VALUE self)
81
+ {
82
+ CHECK;
83
+ return value(THIS->background());
84
+ }
85
+
86
+ static
87
+ VALUE set_background_menu(VALUE self, VALUE menu)
88
+ {
89
+ CHECK;
90
+ THIS->set_background_menu(menu ? to<Reflex::Menu*>(menu) : NULL);
91
+ return menu;
92
+ }
93
+
94
+ static
95
+ VALUE get_background_menu(VALUE self)
96
+ {
97
+ CHECK;
98
+ return value(THIS->background_menu());
99
+ }
100
+
55
101
  static
56
102
  VALUE each_window(VALUE self)
57
103
  {
@@ -59,7 +105,7 @@ VALUE each_window(VALUE self)
59
105
 
60
106
  Value ret;
61
107
  for (auto it = THIS->window_begin(), end = THIS->window_end(); it != end; ++it)
62
- ret = rb_yield(value(it->get()));
108
+ ret = yield(value(it->get()));
63
109
  return ret;
64
110
  }
65
111
 
@@ -68,9 +114,6 @@ VALUE on_start(VALUE self, VALUE event)
68
114
  {
69
115
  CHECK;
70
116
 
71
- RUCY_SYM(call_start_block);
72
- self.call(call_start_block);
73
-
74
117
  CALL(on_start(to<Reflex::Event*>(event)));
75
118
  }
76
119
 
@@ -136,6 +179,12 @@ Init_reflex_application ()
136
179
  rb_define_method(cApplication, "quit", RUBY_METHOD_FUNC(quit), 0);
137
180
  rb_define_method(cApplication, "name=", RUBY_METHOD_FUNC(set_name), 1);
138
181
  rb_define_method(cApplication, "name", RUBY_METHOD_FUNC(get_name), 0);
182
+ rb_define_method(cApplication, "menu=", RUBY_METHOD_FUNC(set_menu), 1);
183
+ rb_define_method(cApplication, "menu", RUBY_METHOD_FUNC(get_menu), 0);
184
+ rb_define_method(cApplication, "background=", RUBY_METHOD_FUNC(set_background), 1);
185
+ cApplication.define_method("background?", is_background);
186
+ rb_define_method(cApplication, "background_menu=", RUBY_METHOD_FUNC(set_background_menu), 1);
187
+ rb_define_method(cApplication, "background_menu", RUBY_METHOD_FUNC(get_background_menu), 0);
139
188
  rb_define_method(cApplication, "each_window", RUBY_METHOD_FUNC(each_window), 0);
140
189
  rb_define_method(cApplication, "on_start", RUBY_METHOD_FUNC(on_start), 1);
141
190
  rb_define_method(cApplication, "on_quit", RUBY_METHOD_FUNC(on_quit), 1);
@@ -9,7 +9,7 @@ RUCY_DEFINE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::CaptureEvent)
9
9
 
10
10
  #define THIS to<Reflex::CaptureEvent*>(self)
11
11
 
12
- #define CHECK RUCY_CHECK_OBJ(Reflex::CaptureEvent, self)
12
+ #define CHECK RUCY_CHECK_PTR(Reflex::CaptureEvent, self)
13
13
 
14
14
 
15
15
  static
@@ -0,0 +1,84 @@
1
+ #include "reflex/ruby/constraint.h"
2
+
3
+
4
+ #include <rays/ruby/point.h>
5
+ #include "reflex/exception.h"
6
+ #include "reflex/ruby/pin.h"
7
+ #include "reflex/ruby/view.h"
8
+ #include "defs.h"
9
+
10
+
11
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::ChaseConstraint)
12
+
13
+ #define THIS to<Reflex::ChaseConstraint*>(self)
14
+
15
+ #define CHECK RUCY_CHECK_PTR(Reflex::ChaseConstraint, self)
16
+
17
+
18
+ static
19
+ VALUE alloc(VALUE klass)
20
+ {
21
+ Reflex::reflex_error(
22
+ __FILE__, __LINE__, "can not instantiate ChaseConstraint class");
23
+ }
24
+
25
+ static
26
+ VALUE set_target(VALUE self)
27
+ {
28
+ CHECK;
29
+ THIS->set_target(to<Reflex::Pin>(argc, argv));
30
+ }
31
+
32
+ static
33
+ VALUE get_target(VALUE self)
34
+ {
35
+ CHECK;
36
+ return value(THIS->target());
37
+ }
38
+
39
+ static
40
+ VALUE set_force(VALUE self, VALUE max_force)
41
+ {
42
+ CHECK;
43
+ if (max_force.is_nil())
44
+ THIS->clear_force();
45
+ else
46
+ THIS->set_force(to<float>(max_force));
47
+ }
48
+
49
+ static
50
+ VALUE get_force(VALUE self)
51
+ {
52
+ CHECK;
53
+ return THIS->has_force() ? value(THIS->force()) : nil();
54
+ }
55
+
56
+
57
+ static Class cChaseConstraint;
58
+
59
+ void
60
+ Init_reflex_chase_constraint ()
61
+ {
62
+ Module mReflex = rb_define_module("Reflex");
63
+
64
+ cChaseConstraint = mReflex.define_class("ChaseConstraint", Reflex::constraint_class());
65
+ rb_define_alloc_func(cChaseConstraint, alloc);
66
+ rb_define_method(cChaseConstraint, "target=", RUBY_METHOD_FUNC(set_target), -1);
67
+ rb_define_method(cChaseConstraint, "target", RUBY_METHOD_FUNC(get_target), 0);
68
+ rb_define_method(cChaseConstraint, "force=", RUBY_METHOD_FUNC(set_force), 1);
69
+ rb_define_method(cChaseConstraint, "force", RUBY_METHOD_FUNC(get_force), 0);
70
+ }
71
+
72
+
73
+ namespace Reflex
74
+ {
75
+
76
+
77
+ Class
78
+ chase_constraint_class ()
79
+ {
80
+ return cChaseConstraint;
81
+ }
82
+
83
+
84
+ }// Reflex
@@ -0,0 +1,65 @@
1
+ #include "reflex/ruby/clipboard.h"
2
+
3
+
4
+ #include "reflex/exception.h"
5
+ #include "defs.h"
6
+
7
+
8
+ static
9
+ VALUE alloc(VALUE klass)
10
+ {
11
+ Reflex::reflex_error(__FILE__, __LINE__, "can not instantiate Clipboard class.");
12
+ }
13
+
14
+ static
15
+ VALUE set_text(VALUE self, VALUE text)
16
+ {
17
+ Reflex::Clipboard clipboard;
18
+ if (!text.is_nil()) clipboard.set_text(text.c_str());
19
+ Reflex::set_clipboard(clipboard);
20
+ return text;
21
+ }
22
+
23
+ static
24
+ VALUE get_text(VALUE self)
25
+ {
26
+ Reflex::Clipboard clipboard = Reflex::get_clipboard();
27
+ const char* text = clipboard.text();
28
+ return text ? value(text) : nil();
29
+ }
30
+
31
+ static
32
+ VALUE clear(VALUE self)
33
+ {
34
+ Reflex::set_clipboard(Reflex::Clipboard());
35
+ return self;
36
+ }
37
+
38
+
39
+ static Class cClipboard;
40
+
41
+ void
42
+ Init_reflex_clipboard ()
43
+ {
44
+ Module mReflex = rb_define_module("Reflex");
45
+
46
+ cClipboard = rb_define_class_under(mReflex, "Clipboard", rb_cObject);
47
+ rb_define_alloc_func(cClipboard, alloc);
48
+ rb_define_singleton_method(cClipboard, "text=", RUBY_METHOD_FUNC(set_text), 1);
49
+ rb_define_singleton_method(cClipboard, "text", RUBY_METHOD_FUNC(get_text), 0);
50
+ rb_define_singleton_method(cClipboard, "clear", RUBY_METHOD_FUNC(clear), 0);
51
+ }
52
+
53
+
54
+ namespace Reflex
55
+ {
56
+
57
+
58
+ Class
59
+ clipboard_class ()
60
+ {
61
+ return cClipboard;
62
+ }
63
+
64
+
65
+ }// Reflex
@@ -0,0 +1,76 @@
1
+ #include "reflex/ruby/event.h"
2
+
3
+
4
+ #include <rays/ruby/color.h>
5
+ #include "defs.h"
6
+
7
+
8
+ RUCY_DEFINE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::ColorEvent)
9
+
10
+ #define THIS to<Reflex::ColorEvent*>(self)
11
+
12
+ #define CHECK RUCY_CHECK_PTR(Reflex::ColorEvent, self)
13
+
14
+
15
+ static
16
+ VALUE alloc(VALUE klass)
17
+ {
18
+ return new_type<Reflex::ColorEvent>(klass);
19
+ }
20
+
21
+ static
22
+ VALUE initialize(VALUE self, VALUE color)
23
+ {
24
+ CHECK;
25
+
26
+ if (color.is_nil())
27
+ argument_error(__FILE__, __LINE__);
28
+
29
+ *THIS = Reflex::ColorEvent(to<Rays::Color>(color));
30
+
31
+ return rb_call_super(0, NULL);
32
+ }
33
+
34
+ static
35
+ VALUE initialize_copy(VALUE self, VALUE obj)
36
+ {
37
+ CHECK;
38
+ *THIS = to<Reflex::ColorEvent&>(obj).dup();
39
+ return self;
40
+ }
41
+
42
+ static
43
+ VALUE get_color(VALUE self)
44
+ {
45
+ CHECK;
46
+ return value(THIS->color());
47
+ }
48
+
49
+
50
+ static Class cColorEvent;
51
+
52
+ void
53
+ Init_reflex_color_event ()
54
+ {
55
+ Module mReflex = rb_define_module("Reflex");
56
+
57
+ cColorEvent = mReflex.define_class("ColorEvent", Reflex::event_class());
58
+ rb_define_alloc_func(cColorEvent, alloc);
59
+ rb_define_private_method(cColorEvent, "initialize", RUBY_METHOD_FUNC(initialize), 1);
60
+ rb_define_private_method(cColorEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
61
+ rb_define_method(cColorEvent, "color", RUBY_METHOD_FUNC(get_color), 0);
62
+ }
63
+
64
+
65
+ namespace Reflex
66
+ {
67
+
68
+
69
+ Class
70
+ color_event_class ()
71
+ {
72
+ return cColorEvent;
73
+ }
74
+
75
+
76
+ }// Reflex
@@ -0,0 +1,113 @@
1
+ #include "reflex/ruby/color_picker.h"
2
+
3
+
4
+ #include <rays/ruby/color.h>
5
+ #include "reflex/ruby/window.h"
6
+ #include "defs.h"
7
+
8
+
9
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::ColorPicker)
10
+
11
+ #define THIS to<Reflex::ColorPicker*>(self)
12
+
13
+ #define CHECK RUCY_CHECK_OBJ(Reflex::ColorPicker, self)
14
+
15
+ #define CALL(fun) RUCY_CALL_SUPER(THIS, fun)
16
+
17
+
18
+ static
19
+ VALUE alloc(VALUE klass)
20
+ {
21
+ return value(new Reflex::RubyColorPicker<Reflex::ColorPicker>, klass);
22
+ }
23
+
24
+ static
25
+ VALUE pick_color(VALUE self, VALUE initial)
26
+ {
27
+ CHECK;
28
+
29
+ if (initial.is_nil())
30
+ THIS->pick_color();
31
+ else
32
+ THIS->pick_color(to<Rays::Color>(initial));
33
+ return self;
34
+ }
35
+
36
+ static
37
+ VALUE set_owner(VALUE self, VALUE owner)
38
+ {
39
+ CHECK;
40
+ THIS->set_owner(owner.is_nil() ? NULL : to<Reflex::Window*>(owner));
41
+ return owner;
42
+ }
43
+
44
+ static
45
+ VALUE get_owner(VALUE self)
46
+ {
47
+ CHECK;
48
+ return value(THIS->owner());
49
+ }
50
+
51
+ static
52
+ VALUE set_alpha(VALUE self, VALUE state)
53
+ {
54
+ CHECK;
55
+ THIS->set_alpha(to<bool>(state));
56
+ return state;
57
+ }
58
+
59
+ static
60
+ VALUE is_alpha(VALUE self)
61
+ {
62
+ CHECK;
63
+ return value(THIS->alpha());
64
+ }
65
+
66
+ static
67
+ VALUE on_color(VALUE self, VALUE event)
68
+ {
69
+ CHECK;
70
+
71
+ CALL(on_color(to<Reflex::ColorEvent*>(event)));
72
+ }
73
+
74
+ static
75
+ VALUE on_close(VALUE self, VALUE event)
76
+ {
77
+ CHECK;
78
+
79
+ CALL(on_close(to<Reflex::Event*>(event)));
80
+ }
81
+
82
+
83
+ static Class cColorPicker;
84
+
85
+ void
86
+ Init_reflex_color_picker ()
87
+ {
88
+ Module mReflex = rb_define_module("Reflex");
89
+
90
+ cColorPicker = rb_define_class_under(mReflex, "ColorPicker", rb_cObject);
91
+ rb_define_alloc_func(cColorPicker, alloc);
92
+ cColorPicker.define_method("pick_color!", pick_color);
93
+ rb_define_method(cColorPicker, "owner=", RUBY_METHOD_FUNC(set_owner), 1);
94
+ rb_define_method(cColorPicker, "owner", RUBY_METHOD_FUNC(get_owner), 0);
95
+ rb_define_method(cColorPicker, "alpha=", RUBY_METHOD_FUNC(set_alpha), 1);
96
+ cColorPicker.define_method("alpha?", is_alpha);
97
+ rb_define_method(cColorPicker, "on_color", RUBY_METHOD_FUNC(on_color), 1);
98
+ rb_define_method(cColorPicker, "on_close", RUBY_METHOD_FUNC(on_close), 1);
99
+ }
100
+
101
+
102
+ namespace Reflex
103
+ {
104
+
105
+
106
+ Class
107
+ color_picker_class ()
108
+ {
109
+ return cColorPicker;
110
+ }
111
+
112
+
113
+ }// Reflex
@@ -0,0 +1,135 @@
1
+ #include "reflex/ruby/constraint.h"
2
+
3
+
4
+ #include <rays/ruby/point.h>
5
+ #include "reflex/exception.h"
6
+ #include "reflex/ruby/view.h"
7
+ #include "reflex/ruby/pin.h"
8
+ #include "defs.h"
9
+ #include "selector.h"
10
+
11
+
12
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Constraint)
13
+
14
+ #define THIS to<Reflex::Constraint*>(self)
15
+
16
+ #define CHECK RUCY_CHECK_PTR(Reflex::Constraint, self)
17
+
18
+
19
+ static
20
+ VALUE alloc(VALUE klass)
21
+ {
22
+ Reflex::reflex_error(
23
+ __FILE__, __LINE__, "can not instantiate Constraint class");
24
+ }
25
+
26
+ static
27
+ VALUE remove(VALUE self)
28
+ {
29
+ CHECK;
30
+ THIS->remove();
31
+ return self;
32
+ }
33
+
34
+ static
35
+ VALUE get_pin(VALUE self, VALUE index)
36
+ {
37
+ CHECK;
38
+ return value(THIS->pin(to<int>(index)));
39
+ }
40
+
41
+ static
42
+ VALUE set_spring(VALUE self, VALUE hertz)
43
+ {
44
+ CHECK;
45
+ THIS->set_spring(hertz ? to<float>(hertz) : 0);
46
+ }
47
+
48
+ static
49
+ VALUE get_spring(VALUE self)
50
+ {
51
+ CHECK;
52
+ float hertz = THIS->spring();
53
+ return hertz > 0 ? value(hertz) : nil();
54
+ }
55
+
56
+ static
57
+ VALUE set_damping(VALUE self, VALUE ratio)
58
+ {
59
+ CHECK;
60
+ THIS->set_damping(to<float>(ratio));
61
+ }
62
+
63
+ static
64
+ VALUE get_damping(VALUE self)
65
+ {
66
+ CHECK;
67
+ return value(THIS->damping());
68
+ }
69
+
70
+ static
71
+ VALUE set_collide(VALUE self, VALUE state)
72
+ {
73
+ CHECK;
74
+ THIS->set_collide(to<bool>(state));
75
+ }
76
+
77
+ static
78
+ VALUE can_collide(VALUE self)
79
+ {
80
+ CHECK;
81
+ return value(THIS->can_collide());
82
+ }
83
+
84
+ static
85
+ VALUE is_removed(VALUE self)
86
+ {
87
+ CHECK;
88
+ return value(THIS->is_removed());
89
+ }
90
+
91
+ static
92
+ VALUE is_active(VALUE self)
93
+ {
94
+ CHECK;
95
+ return value(THIS->operator bool());
96
+ }
97
+
98
+
99
+ static Class cConstraint;
100
+
101
+ void
102
+ Init_reflex_constraint ()
103
+ {
104
+ Module mReflex = rb_define_module("Reflex");
105
+
106
+ cConstraint = rb_define_class_under(mReflex, "Constraint", rb_cObject);
107
+ rb_define_alloc_func(cConstraint, alloc);
108
+ rb_define_method(cConstraint, "remove", RUBY_METHOD_FUNC(remove), 0);
109
+ rb_define_private_method(cConstraint, "get_pin", RUBY_METHOD_FUNC(get_pin), 1);
110
+ rb_define_method(cConstraint, "spring=", RUBY_METHOD_FUNC(set_spring), 1);
111
+ rb_define_method(cConstraint, "spring", RUBY_METHOD_FUNC(get_spring), 0);
112
+ rb_define_method(cConstraint, "damping=", RUBY_METHOD_FUNC(set_damping), 1);
113
+ rb_define_method(cConstraint, "damping", RUBY_METHOD_FUNC(get_damping), 0);
114
+ rb_define_method(cConstraint, "collide=", RUBY_METHOD_FUNC(set_collide), 1);
115
+ cConstraint.define_method("collide?", can_collide);
116
+ cConstraint.define_method("removed?", is_removed);
117
+ cConstraint.define_method("active?", is_active);
118
+
119
+ define_selector_methods<Reflex::Constraint>(cConstraint);
120
+ define_wrapper_equality_methods<Reflex::Constraint>(cConstraint);
121
+ }
122
+
123
+
124
+ namespace Reflex
125
+ {
126
+
127
+
128
+ Class
129
+ constraint_class ()
130
+ {
131
+ return cConstraint;
132
+ }
133
+
134
+
135
+ }// Reflex
@@ -11,7 +11,7 @@ RUCY_DEFINE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::ContactEvent)
11
11
 
12
12
  #define THIS to<Reflex::ContactEvent*>(self)
13
13
 
14
- #define CHECK RUCY_CHECK_OBJ(Reflex::ContactEvent, self)
14
+ #define CHECK RUCY_CHECK_PTR(Reflex::ContactEvent, self)
15
15
 
16
16
 
17
17
  static
@@ -8,7 +8,7 @@ RUCY_DEFINE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::ControlChangeEvent)
8
8
 
9
9
  #define THIS to<Reflex::ControlChangeEvent*>(self)
10
10
 
11
- #define CHECK RUCY_CHECK_OBJ(Reflex::ControlChangeEvent, self)
11
+ #define CHECK RUCY_CHECK_PTR(Reflex::ControlChangeEvent, self)
12
12
 
13
13
 
14
14
  static
@@ -8,7 +8,7 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Device)
8
8
 
9
9
  #define THIS to<Reflex::Device*>(self)
10
10
 
11
- #define CHECK RUCY_CHECK_OBJECT(Reflex::Device, self)
11
+ #define CHECK RUCY_CHECK_OBJ(Reflex::Device, self)
12
12
 
13
13
 
14
14
  static
@@ -9,7 +9,7 @@ RUCY_DEFINE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::DeviceEvent)
9
9
 
10
10
  #define THIS to<Reflex::DeviceEvent*>(self)
11
11
 
12
- #define CHECK RUCY_CHECK_OBJ(Reflex::DeviceEvent, self)
12
+ #define CHECK RUCY_CHECK_PTR(Reflex::DeviceEvent, self)
13
13
 
14
14
 
15
15
  static
@@ -10,7 +10,7 @@ RUCY_DEFINE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::DrawEvent)
10
10
 
11
11
  #define THIS to<Reflex::DrawEvent*>(self)
12
12
 
13
- #define CHECK RUCY_CHECK_OBJ(Reflex::DrawEvent, self)
13
+ #define CHECK RUCY_CHECK_PTR(Reflex::DrawEvent, self)
14
14
 
15
15
 
16
16
  static
@@ -8,7 +8,7 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::EllipseShape)
8
8
 
9
9
  #define THIS to<Reflex::EllipseShape*>(self)
10
10
 
11
- #define CHECK RUCY_CHECK_OBJ(Reflex::EllipseShape, self)
11
+ #define CHECK RUCY_CHECK_PTR(Reflex::EllipseShape, self)
12
12
 
13
13
  #define CALL(fun) RUCY_CALL_SUPER(THIS, fun)
14
14
 
@@ -9,7 +9,7 @@ RUCY_DEFINE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Event)
9
9
 
10
10
  #define THIS to<Reflex::Event*>(self)
11
11
 
12
- #define CHECK RUCY_CHECK_OBJ(Reflex::Event, self)
12
+ #define CHECK RUCY_CHECK_PTR(Reflex::Event, self)
13
13
 
14
14
 
15
15
  static