reflexion 0.5.2 → 0.6.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 (145) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/application.cpp +19 -1
  3. data/.doc/ext/reflex/chase_constraint.cpp +84 -0
  4. data/.doc/ext/reflex/clipboard.cpp +65 -0
  5. data/.doc/ext/reflex/constraint.cpp +135 -0
  6. data/.doc/ext/reflex/key_event.cpp +6 -6
  7. data/.doc/ext/reflex/link_constraint.cpp +178 -0
  8. data/.doc/ext/reflex/menu.cpp +302 -0
  9. data/.doc/ext/reflex/native.cpp +22 -4
  10. data/.doc/ext/reflex/pin.cpp +156 -0
  11. data/.doc/ext/reflex/pointer.cpp +2 -0
  12. data/.doc/ext/reflex/pointer_event.cpp +1 -1
  13. data/.doc/ext/reflex/reflex.cpp +42 -7
  14. data/.doc/ext/reflex/selector.cpp +4 -4
  15. data/.doc/ext/reflex/snap_constraint.cpp +125 -0
  16. data/.doc/ext/reflex/style_length.cpp +3 -2
  17. data/.doc/ext/reflex/view.cpp +96 -23
  18. data/.doc/ext/reflex/wheel_constraint.cpp +142 -0
  19. data/.doc/ext/reflex/window.cpp +59 -17
  20. data/.github/workflows/release-gem.yml +10 -1
  21. data/.github/workflows/test.yml +9 -0
  22. data/ChangeLog.md +30 -0
  23. data/README.md +1 -0
  24. data/VERSION +1 -1
  25. data/ext/reflex/application.cpp +21 -1
  26. data/ext/reflex/chase_constraint.cpp +89 -0
  27. data/ext/reflex/clipboard.cpp +69 -0
  28. data/ext/reflex/constraint.cpp +146 -0
  29. data/ext/reflex/key_event.cpp +6 -6
  30. data/ext/reflex/link_constraint.cpp +194 -0
  31. data/ext/reflex/menu.cpp +330 -0
  32. data/ext/reflex/native.cpp +22 -4
  33. data/ext/reflex/pin.cpp +165 -0
  34. data/ext/reflex/pointer.cpp +2 -0
  35. data/ext/reflex/pointer_event.cpp +1 -1
  36. data/ext/reflex/reflex.cpp +42 -7
  37. data/ext/reflex/selector.cpp +4 -4
  38. data/ext/reflex/selector.h +1 -1
  39. data/ext/reflex/snap_constraint.cpp +135 -0
  40. data/ext/reflex/style_length.cpp +3 -2
  41. data/ext/reflex/view.cpp +117 -37
  42. data/ext/reflex/wheel_constraint.cpp +154 -0
  43. data/ext/reflex/window.cpp +65 -18
  44. data/include/reflex/application.h +9 -0
  45. data/include/reflex/clipboard.h +53 -0
  46. data/include/reflex/constraint.h +275 -0
  47. data/include/reflex/defs.h +204 -195
  48. data/include/reflex/event.h +2 -0
  49. data/include/reflex/menu.h +120 -0
  50. data/include/reflex/pin.h +68 -0
  51. data/include/reflex/pointer.h +4 -0
  52. data/include/reflex/ruby/clipboard.h +23 -0
  53. data/include/reflex/ruby/constraint.h +94 -0
  54. data/include/reflex/ruby/menu.h +103 -0
  55. data/include/reflex/ruby/pin.h +40 -0
  56. data/include/reflex/ruby/view.h +36 -0
  57. data/include/reflex/ruby/window.h +36 -18
  58. data/include/reflex/view.h +39 -12
  59. data/include/reflex/window.h +17 -4
  60. data/include/reflex.h +5 -0
  61. data/lib/reflex/chase_constraint.rb +15 -0
  62. data/lib/reflex/clipboard.rb +19 -0
  63. data/lib/reflex/constraint.rb +29 -0
  64. data/lib/reflex/extension.rb +1 -1
  65. data/lib/reflex/helper.rb +28 -0
  66. data/lib/reflex/key_event.rb +7 -12
  67. data/lib/reflex/link_constraint.rb +31 -0
  68. data/lib/reflex/menu.rb +76 -0
  69. data/lib/reflex/pin.rb +39 -0
  70. data/lib/reflex/pointer.rb +18 -0
  71. data/lib/reflex/pointer_event.rb +1 -1
  72. data/lib/reflex/snap_constraint.rb +28 -0
  73. data/lib/reflex/view.rb +56 -4
  74. data/lib/reflex/wheel_constraint.rb +28 -0
  75. data/lib/reflex/wheel_event.rb +9 -0
  76. data/lib/reflex.rb +15 -6
  77. data/pod.rake +4 -2
  78. data/reflex.gemspec +3 -3
  79. data/samples/constraint.rb +152 -0
  80. data/samples/menu.rb +29 -0
  81. data/src/application.cpp +21 -2
  82. data/src/application.h +5 -0
  83. data/src/clipboard.cpp +81 -0
  84. data/src/constraint.cpp +1662 -0
  85. data/src/constraint.h +64 -0
  86. data/src/event.cpp +7 -1
  87. data/src/event.h +1 -2
  88. data/src/ios/application.mm +5 -0
  89. data/src/ios/clipboard.mm +44 -0
  90. data/src/ios/event.h +6 -2
  91. data/src/ios/event.mm +31 -12
  92. data/src/ios/menu.mm +36 -0
  93. data/src/ios/view_controller.mm +45 -12
  94. data/src/ios/window.mm +6 -0
  95. data/src/menu.cpp +325 -0
  96. data/src/menu.h +65 -0
  97. data/src/osx/app_delegate.mm +74 -125
  98. data/src/osx/application.mm +16 -0
  99. data/src/osx/clipboard.mm +45 -0
  100. data/src/osx/event.mm +40 -10
  101. data/src/osx/menu.h +25 -0
  102. data/src/osx/menu.mm +372 -0
  103. data/src/osx/native_window.mm +27 -0
  104. data/src/osx/opengl_view.mm +51 -0
  105. data/src/osx/window.mm +11 -0
  106. data/src/pin.cpp +137 -0
  107. data/src/pointer.cpp +27 -16
  108. data/src/pointer.h +6 -0
  109. data/src/sdl/application.cpp +5 -0
  110. data/src/sdl/clipboard.cpp +39 -0
  111. data/src/sdl/event.cpp +20 -3
  112. data/src/sdl/event.h +6 -3
  113. data/src/sdl/menu.cpp +35 -0
  114. data/src/sdl/window.cpp +26 -8
  115. data/src/view.cpp +313 -52
  116. data/src/view.h +18 -2
  117. data/src/win32/application.cpp +5 -0
  118. data/src/win32/clipboard.cpp +210 -0
  119. data/src/win32/event.cpp +11 -1
  120. data/src/win32/event.h +2 -0
  121. data/src/win32/menu.cpp +352 -0
  122. data/src/win32/menu.h +27 -0
  123. data/src/win32/window.cpp +62 -0
  124. data/src/win32/window.h +3 -0
  125. data/src/window.cpp +235 -22
  126. data/src/window.h +13 -2
  127. data/src/world.cpp +77 -14
  128. data/src/world.h +9 -2
  129. data/test/helper.rb +7 -0
  130. data/test/test_application.rb +11 -0
  131. data/test/test_chase_constraint.rb +124 -0
  132. data/test/test_clipboard.rb +54 -0
  133. data/test/test_constraint.rb +186 -0
  134. data/test/test_key_event.rb +6 -0
  135. data/test/test_link_constraint.rb +239 -0
  136. data/test/test_menu.rb +207 -0
  137. data/test/test_pin.rb +65 -0
  138. data/test/test_pointer.rb +23 -9
  139. data/test/test_pointer_event.rb +1 -1
  140. data/test/test_snap_constraint.rb +142 -0
  141. data/test/test_view.rb +113 -23
  142. data/test/test_wheel_constraint.rb +127 -0
  143. data/test/test_wheel_event.rb +15 -9
  144. data/test/test_window.rb +10 -0
  145. metadata +82 -8
@@ -0,0 +1,125 @@
1
+ #include "reflex/ruby/constraint.h"
2
+
3
+
4
+ #include "reflex/exception.h"
5
+ #include "defs.h"
6
+
7
+
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::SnapConstraint)
9
+
10
+ #define THIS to<Reflex::SnapConstraint*>(self)
11
+
12
+ #define CHECK RUCY_CHECK_OBJ(Reflex::SnapConstraint, self)
13
+
14
+
15
+ static
16
+ VALUE alloc(VALUE klass)
17
+ {
18
+ Reflex::reflex_error(
19
+ __FILE__, __LINE__, "can not instantiate SnapConstraint class");
20
+ }
21
+
22
+ static
23
+ VALUE set_angle(VALUE self, VALUE min, VALUE max)
24
+ {
25
+ CHECK;
26
+ THIS->set_angle(to<float>(min), to<float>(max));
27
+ }
28
+
29
+ static
30
+ VALUE clear_angle(VALUE self)
31
+ {
32
+ CHECK;
33
+ THIS->clear_angle();
34
+ }
35
+
36
+ static
37
+ VALUE angle_min(VALUE self)
38
+ {
39
+ CHECK;
40
+ return value(THIS->angle_min());
41
+ }
42
+
43
+ static
44
+ VALUE angle_max(VALUE self)
45
+ {
46
+ CHECK;
47
+ return value(THIS->angle_max());
48
+ }
49
+
50
+ static
51
+ VALUE has_angle(VALUE self)
52
+ {
53
+ CHECK;
54
+ return value(THIS->has_angle());
55
+ }
56
+
57
+ static
58
+ VALUE set_motor(VALUE self, VALUE degrees_per_second)
59
+ {
60
+ CHECK;
61
+
62
+ if (degrees_per_second.is_nil())
63
+ THIS->clear_motor();
64
+ else
65
+ THIS->set_motor(to<float>(degrees_per_second));
66
+ }
67
+
68
+ static
69
+ VALUE get_motor(VALUE self)
70
+ {
71
+ CHECK;
72
+ return THIS->has_motor() ? value(THIS->motor()) : nil();
73
+ }
74
+
75
+ static
76
+ VALUE set_force(VALUE self, VALUE max_torque)
77
+ {
78
+ CHECK;
79
+ if (max_torque.is_nil())
80
+ THIS->clear_force();
81
+ else
82
+ THIS->set_force(to<float>(max_torque));
83
+ }
84
+
85
+ static
86
+ VALUE get_force(VALUE self)
87
+ {
88
+ CHECK;
89
+ return THIS->has_force() ? value(THIS->force()) : nil();
90
+ }
91
+
92
+
93
+ static Class cSnapConstraint;
94
+
95
+ void
96
+ Init_reflex_snap_constraint ()
97
+ {
98
+ Module mReflex = rb_define_module("Reflex");
99
+
100
+ cSnapConstraint = mReflex.define_class("SnapConstraint", Reflex::constraint_class());
101
+ rb_define_alloc_func(cSnapConstraint, alloc);
102
+ cSnapConstraint.define_private_method( "set_angle!", set_angle);
103
+ cSnapConstraint.define_private_method("clear_angle!", clear_angle);
104
+ cSnapConstraint.define_private_method( "angle_min!", angle_min);
105
+ cSnapConstraint.define_private_method( "angle_max!", angle_max);
106
+ cSnapConstraint.define_private_method( "has_angle!", has_angle);
107
+ rb_define_method(cSnapConstraint, "motor=", RUBY_METHOD_FUNC(set_motor), 1);
108
+ rb_define_method(cSnapConstraint, "motor", RUBY_METHOD_FUNC(get_motor), 0);
109
+ rb_define_method(cSnapConstraint, "force=", RUBY_METHOD_FUNC(set_force), 1);
110
+ rb_define_method(cSnapConstraint, "force", RUBY_METHOD_FUNC(get_force), 0);
111
+ }
112
+
113
+
114
+ namespace Reflex
115
+ {
116
+
117
+
118
+ Class
119
+ snap_constraint_class ()
120
+ {
121
+ return cSnapConstraint;
122
+ }
123
+
124
+
125
+ }// Reflex
@@ -213,13 +213,14 @@ namespace Rucy
213
213
  template <> REFLEX_EXPORT Reflex::StyleLength
214
214
  value_to<Reflex::StyleLength> (int argc, const Value* argv, bool convert)
215
215
  {
216
- if (argc == 1 && argv->is_array())
216
+ if (argc == 1 && argv && argv->is_array())
217
217
  {
218
218
  argc = argv->size();
219
219
  argv = argv->as_array();
220
220
  }
221
221
 
222
- assert(argc > 0 && argv);
222
+ if (argc <= 0 || !argv)
223
+ argument_error(__FILE__, __LINE__);
223
224
 
224
225
  if (convert)
225
226
  {
@@ -10,6 +10,7 @@
10
10
  #include "reflex/ruby/timer.h"
11
11
  #include "reflex/ruby/style.h"
12
12
  #include "reflex/ruby/shape.h"
13
+ #include "reflex/ruby/constraint.h"
13
14
  #include "reflex/ruby/filter.h"
14
15
  #include "reflex/ruby/window.h"
15
16
  #include "defs.h"
@@ -94,7 +95,7 @@ static
94
95
  VALUE start_timer(VALUE self)
95
96
  {
96
97
  CHECK;
97
- check_arg_count(__FILE__, __LINE__, "View#start_timer", argc, 1, 2);
98
+ check_arg_count(__FILE__, __LINE__, "View#start_timer!", argc, 1, 2);
98
99
 
99
100
  Reflex::Timer* timer = THIS->start_timer(
100
101
  to<float>(argv[0]),
@@ -154,10 +155,10 @@ VALUE to_screen(VALUE self, VALUE point)
154
155
  }
155
156
 
156
157
  static
157
- VALUE add_child(VALUE self, VALUE child)
158
+ VALUE add_child(VALUE self, VALUE child, VALUE index)
158
159
  {
159
160
  CHECK;
160
- THIS->add_child(to<Reflex::View*>(child));
161
+ THIS->add_child(to<Reflex::View*>(child), index.is_nil() ? -1 : to<int>(index));
161
162
  return child;
162
163
  }
163
164
 
@@ -196,9 +197,11 @@ VALUE each_child(VALUE self)
196
197
  {
197
198
  CHECK;
198
199
 
200
+ Reflex::View::ChildList children(THIS->child_begin(), THIS->child_end());
201
+
199
202
  Value ret;
200
- for (auto it = THIS->child_begin(), end = THIS->child_end(); it != end; ++it)
201
- ret = rb_yield(value(it->get()));
203
+ for (auto& child : children)
204
+ ret = yield(value(child.get()));
202
205
  return ret;
203
206
  }
204
207
 
@@ -251,10 +254,11 @@ VALUE each_style(VALUE self)
251
254
  {
252
255
  CHECK;
253
256
 
257
+ Reflex::View::StyleList styles(THIS->style_begin(), THIS->style_end());
258
+
254
259
  Value ret;
255
- Reflex::View::style_iterator end = THIS->style_end();
256
- for (Reflex::View::style_iterator it = THIS->style_begin(); it != end; ++it)
257
- ret = rb_yield(value(*it));
260
+ for (auto& style : styles)
261
+ ret = yield(value(style));
258
262
  return ret;
259
263
  }
260
264
 
@@ -290,10 +294,10 @@ VALUE get_shape(VALUE self)
290
294
  }
291
295
 
292
296
  static
293
- VALUE add_shape(VALUE self, VALUE shape)
297
+ VALUE add_shape(VALUE self, VALUE shape, VALUE index)
294
298
  {
295
299
  CHECK;
296
- THIS->add_shape(to_shape(shape));
300
+ THIS->add_shape(to_shape(shape), index.is_nil() ? -1 : to<int>(index));
297
301
  return shape;
298
302
  }
299
303
 
@@ -330,10 +334,45 @@ VALUE each_shape(VALUE self)
330
334
  {
331
335
  CHECK;
332
336
 
337
+ Reflex::View::ShapeList shapes(THIS->shape_begin(), THIS->shape_end());
338
+
333
339
  Value ret;
334
- Reflex::View::shape_iterator end = THIS->shape_end();
335
- for (Reflex::View::shape_iterator it = THIS->shape_begin(); it != end; ++it)
336
- ret = rb_yield(value(it->get()));
340
+ for (auto& shape : shapes)
341
+ ret = yield(value(shape.get()));
342
+ return ret;
343
+ }
344
+
345
+ static
346
+ VALUE clear_constraints(VALUE self)
347
+ {
348
+ CHECK;
349
+ THIS->clear_constraints();
350
+ return self;
351
+ }
352
+
353
+ static
354
+ VALUE find_constraints(VALUE self)
355
+ {
356
+ CHECK;
357
+ check_arg_count(__FILE__, __LINE__, "View#find_constraints", argc, 1);
358
+
359
+ auto constraints =
360
+ THIS->find_constraints(to<Reflex::Selector>(argv[0])) |
361
+ std::views::transform([](auto& ref) {return value(ref.get());});
362
+ return array(constraints.begin(), constraints.end());
363
+ }
364
+
365
+ static
366
+ VALUE each_constraint(VALUE self)
367
+ {
368
+ CHECK;
369
+
370
+ Reflex::View::ConstraintList constraints(
371
+ THIS->constraint_begin(), THIS->constraint_end());
372
+
373
+ Value ret;
374
+ for (auto& constraint : constraints)
375
+ ret = yield(value(constraint.get()));
337
376
  return ret;
338
377
  }
339
378
 
@@ -822,10 +861,8 @@ static
822
861
  VALUE update_world(VALUE self)
823
862
  {
824
863
  CHECK;
825
- check_arg_count(__FILE__, __LINE__, "View#update_world", argc, 0, 1);
826
864
 
827
- float duration = argc >= 1 ? to<float>(argv[0]) : 0;
828
- THIS->update_world(duration);
865
+ THIS->update_world();
829
866
  return self;
830
867
  }
831
868
 
@@ -906,6 +943,20 @@ VALUE on_detach(VALUE self, VALUE event)
906
943
  CALL(on_detach(to<Reflex::Event*>(event)));
907
944
  }
908
945
 
946
+ static
947
+ VALUE on_activate(VALUE self, VALUE event)
948
+ {
949
+ CHECK;
950
+ CALL(on_activate(to<Reflex::Event*>(event)));
951
+ }
952
+
953
+ static
954
+ VALUE on_deactivate(VALUE self, VALUE event)
955
+ {
956
+ CHECK;
957
+ CALL(on_deactivate(to<Reflex::Event*>(event)));
958
+ }
959
+
909
960
  static
910
961
  VALUE on_show(VALUE self, VALUE event)
911
962
  {
@@ -1032,6 +1083,20 @@ VALUE on_pointer_cancel(VALUE self, VALUE event)
1032
1083
  CALL(on_pointer_cancel(to<Reflex::PointerEvent*>(event)));
1033
1084
  }
1034
1085
 
1086
+ static
1087
+ VALUE on_pointer_enter(VALUE self, VALUE event)
1088
+ {
1089
+ CHECK;
1090
+ CALL(on_pointer_enter(to<Reflex::PointerEvent*>(event)));
1091
+ }
1092
+
1093
+ static
1094
+ VALUE on_pointer_leave(VALUE self, VALUE event)
1095
+ {
1096
+ CHECK;
1097
+ CALL(on_pointer_leave(to<Reflex::PointerEvent*>(event)));
1098
+ }
1099
+
1035
1100
  static
1036
1101
  VALUE on_wheel(VALUE self, VALUE event)
1037
1102
  {
@@ -1133,7 +1198,7 @@ Init_reflex_view ()
1133
1198
  rb_define_method(cView, "focus", RUBY_METHOD_FUNC(focus), -1);
1134
1199
  rb_define_method(cView, "blur", RUBY_METHOD_FUNC(blur), 0);
1135
1200
  cView.define_method("focus?", has_focus);
1136
- rb_define_private_method(cView, "start_timer", RUBY_METHOD_FUNC(start_timer), -1);
1201
+ cView.define_private_method("start_timer!", start_timer);
1137
1202
  rb_define_method(cView, "update_layout", RUBY_METHOD_FUNC(update_layout), 0);
1138
1203
 
1139
1204
  rb_define_method(cView, "from_parent", RUBY_METHOD_FUNC(from_parent), 1);
@@ -1143,25 +1208,29 @@ Init_reflex_view ()
1143
1208
  rb_define_method(cView, "from_screen", RUBY_METHOD_FUNC(from_screen), 1);
1144
1209
  rb_define_method(cView, "to_screen", RUBY_METHOD_FUNC(to_screen), 1);
1145
1210
 
1146
- rb_define_method(cView, "add_child", RUBY_METHOD_FUNC(add_child), 1);
1211
+ cView.define_method( "add_child!", add_child);
1147
1212
  rb_define_method(cView, "remove_child", RUBY_METHOD_FUNC(remove_child), 1);
1148
1213
  rb_define_method(cView, "clear_children", RUBY_METHOD_FUNC(clear_children), 0);
1149
1214
  rb_define_method(cView, "find_children", RUBY_METHOD_FUNC(find_children), -1);
1150
- rb_define_method(cView, "each_child", RUBY_METHOD_FUNC(each_child), 0);
1215
+ cView.define_private_method("each_child!", each_child);
1151
1216
 
1152
1217
  rb_define_method(cView, "add_style", RUBY_METHOD_FUNC(add_style), 1);
1153
1218
  rb_define_method(cView, "remove_style", RUBY_METHOD_FUNC(remove_style), 1);
1154
1219
  rb_define_method(cView, "get_style", RUBY_METHOD_FUNC(get_style), 1);
1155
1220
  rb_define_method(cView, "find_styles", RUBY_METHOD_FUNC(find_styles), -1);
1156
- rb_define_method(cView, "each_style", RUBY_METHOD_FUNC(each_style), 0);
1221
+ cView.define_private_method("each_style!", each_style);
1157
1222
 
1158
1223
  rb_define_method(cView, "shape=", RUBY_METHOD_FUNC(set_shape), 1);
1159
1224
  rb_define_method(cView, "shape", RUBY_METHOD_FUNC(get_shape), 0);
1160
- rb_define_method(cView, "add_shape", RUBY_METHOD_FUNC(add_shape), 1);
1225
+ cView.define_method( "add_shape!", add_shape);
1161
1226
  rb_define_method(cView, "remove_shape", RUBY_METHOD_FUNC(remove_shape), 1);
1162
1227
  rb_define_method(cView, "clear_shapes", RUBY_METHOD_FUNC(clear_shapes), 0);
1163
1228
  rb_define_method(cView, "find_shapes", RUBY_METHOD_FUNC(find_shapes), -1);
1164
- rb_define_method(cView, "each_shape", RUBY_METHOD_FUNC(each_shape), 0);
1229
+ cView.define_private_method("each_shape!", each_shape);
1230
+
1231
+ rb_define_method(cView, "clear_constraints", RUBY_METHOD_FUNC(clear_constraints), 0);
1232
+ rb_define_method(cView, "find_constraints", RUBY_METHOD_FUNC(find_constraints), -1);
1233
+ cView.define_private_method("each_constraint!", each_constraint);
1165
1234
 
1166
1235
  rb_define_method(cView, "filter=", RUBY_METHOD_FUNC(set_filter), 1);
1167
1236
  rb_define_method(cView, "filter", RUBY_METHOD_FUNC(get_filter), 0);
@@ -1218,7 +1287,7 @@ Init_reflex_view ()
1218
1287
  rb_define_method(cView, "gravity_scale", RUBY_METHOD_FUNC(get_gravity_scale), 0);
1219
1288
 
1220
1289
  rb_define_method(cView, "create_world", RUBY_METHOD_FUNC(create_world), 1);
1221
- rb_define_method(cView, "update_world", RUBY_METHOD_FUNC(update_world), -1);
1290
+ rb_define_method(cView, "update_world", RUBY_METHOD_FUNC(update_world), 0);
1222
1291
  rb_define_method(cView, "meter2pixel", RUBY_METHOD_FUNC(meter2pixel), -1);
1223
1292
  rb_define_method(cView, "gravity=", RUBY_METHOD_FUNC(set_gravity), -1);
1224
1293
  rb_define_method(cView, "gravity", RUBY_METHOD_FUNC(get_gravity), 0);
@@ -1230,6 +1299,8 @@ Init_reflex_view ()
1230
1299
 
1231
1300
  rb_define_method(cView, "on_attach", RUBY_METHOD_FUNC(on_attach), 1);
1232
1301
  rb_define_method(cView, "on_detach", RUBY_METHOD_FUNC(on_detach), 1);
1302
+ rb_define_method(cView, "on_activate", RUBY_METHOD_FUNC(on_activate), 1);
1303
+ rb_define_method(cView, "on_deactivate", RUBY_METHOD_FUNC(on_deactivate), 1);
1233
1304
  rb_define_method(cView, "on_show", RUBY_METHOD_FUNC(on_show), 1);
1234
1305
  rb_define_method(cView, "on_hide", RUBY_METHOD_FUNC(on_hide), 1);
1235
1306
  rb_define_method(cView, "on_update", RUBY_METHOD_FUNC(on_update), 1);
@@ -1248,6 +1319,8 @@ Init_reflex_view ()
1248
1319
  rb_define_method(cView, "on_pointer_up", RUBY_METHOD_FUNC(on_pointer_up), 1);
1249
1320
  rb_define_method(cView, "on_pointer_move", RUBY_METHOD_FUNC(on_pointer_move), 1);
1250
1321
  rb_define_method(cView, "on_pointer_cancel", RUBY_METHOD_FUNC(on_pointer_cancel), 1);
1322
+ rb_define_method(cView, "on_pointer_enter", RUBY_METHOD_FUNC(on_pointer_enter), 1);
1323
+ rb_define_method(cView, "on_pointer_leave", RUBY_METHOD_FUNC(on_pointer_leave), 1);
1251
1324
  rb_define_method(cView, "on_wheel", RUBY_METHOD_FUNC(on_wheel), 1);
1252
1325
  rb_define_method(cView, "on_midi", RUBY_METHOD_FUNC(on_midi), 1);
1253
1326
  rb_define_method(cView, "on_note", RUBY_METHOD_FUNC(on_note), 1);
@@ -0,0 +1,142 @@
1
+ #include "reflex/ruby/constraint.h"
2
+
3
+
4
+ #include <rays/ruby/point.h>
5
+ #include "reflex/exception.h"
6
+ #include "defs.h"
7
+
8
+
9
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::WheelConstraint)
10
+
11
+ #define THIS to<Reflex::WheelConstraint*>(self)
12
+
13
+ #define CHECK RUCY_CHECK_OBJ(Reflex::WheelConstraint, self)
14
+
15
+
16
+ static
17
+ VALUE alloc(VALUE klass)
18
+ {
19
+ Reflex::reflex_error(
20
+ __FILE__, __LINE__, "can not instantiate WheelConstraint class");
21
+ }
22
+
23
+ static
24
+ VALUE set_axis(VALUE self)
25
+ {
26
+ CHECK;
27
+ THIS->set_axis(to<Rays::Point>(argc, argv));
28
+ }
29
+
30
+ static
31
+ VALUE get_axis(VALUE self)
32
+ {
33
+ CHECK;
34
+ return value(THIS->axis());
35
+ }
36
+
37
+ static
38
+ VALUE set_range(VALUE self, VALUE min, VALUE max)
39
+ {
40
+ CHECK;
41
+ THIS->set_range(to<coord>(min), to<coord>(max));
42
+ }
43
+
44
+ static
45
+ VALUE clear_range(VALUE self)
46
+ {
47
+ CHECK;
48
+ THIS->clear_range();
49
+ }
50
+
51
+ static
52
+ VALUE range_min(VALUE self)
53
+ {
54
+ CHECK;
55
+ return value(THIS->range_min());
56
+ }
57
+
58
+ static
59
+ VALUE range_max(VALUE self)
60
+ {
61
+ CHECK;
62
+ return value(THIS->range_max());
63
+ }
64
+
65
+ static
66
+ VALUE has_range(VALUE self)
67
+ {
68
+ CHECK;
69
+ return value(THIS->has_range());
70
+ }
71
+
72
+ static
73
+ VALUE set_motor(VALUE self, VALUE degrees_per_second)
74
+ {
75
+ CHECK;
76
+ if (degrees_per_second.is_nil())
77
+ THIS->clear_motor();
78
+ else
79
+ THIS->set_motor(to<float>(degrees_per_second));
80
+ }
81
+
82
+ static
83
+ VALUE get_motor(VALUE self)
84
+ {
85
+ CHECK;
86
+ return THIS->has_motor() ? value(THIS->motor()) : nil();
87
+ }
88
+
89
+ static
90
+ VALUE set_force(VALUE self, VALUE max_torque)
91
+ {
92
+ CHECK;
93
+ if (max_torque.is_nil())
94
+ THIS->clear_force();
95
+ else
96
+ THIS->set_force(to<float>(max_torque));
97
+ }
98
+
99
+ static
100
+ VALUE get_force(VALUE self)
101
+ {
102
+ CHECK;
103
+ return THIS->has_force() ? value(THIS->force()) : nil();
104
+ }
105
+
106
+
107
+ static Class cWheelConstraint;
108
+
109
+ void
110
+ Init_reflex_wheel_constraint ()
111
+ {
112
+ Module mReflex = rb_define_module("Reflex");
113
+
114
+ cWheelConstraint = mReflex.define_class(
115
+ "WheelConstraint", Reflex::constraint_class());
116
+ rb_define_alloc_func(cWheelConstraint, alloc);
117
+ rb_define_method(cWheelConstraint, "axis=", RUBY_METHOD_FUNC(set_axis), -1);
118
+ rb_define_method(cWheelConstraint, "axis", RUBY_METHOD_FUNC(get_axis), 0);
119
+ cWheelConstraint.define_private_method( "set_range!", set_range);
120
+ cWheelConstraint.define_private_method("clear_range!", clear_range);
121
+ cWheelConstraint.define_private_method( "range_min!", range_min);
122
+ cWheelConstraint.define_private_method( "range_max!", range_max);
123
+ cWheelConstraint.define_private_method( "has_range!", has_range);
124
+ rb_define_method(cWheelConstraint, "motor=", RUBY_METHOD_FUNC(set_motor), 1);
125
+ rb_define_method(cWheelConstraint, "motor", RUBY_METHOD_FUNC(get_motor), 0);
126
+ rb_define_method(cWheelConstraint, "force=", RUBY_METHOD_FUNC(set_force), 1);
127
+ rb_define_method(cWheelConstraint, "force", RUBY_METHOD_FUNC(get_force), 0);
128
+ }
129
+
130
+
131
+ namespace Reflex
132
+ {
133
+
134
+
135
+ Class
136
+ wheel_constraint_class ()
137
+ {
138
+ return cWheelConstraint;
139
+ }
140
+
141
+
142
+ }// Reflex
@@ -3,8 +3,9 @@
3
3
 
4
4
  #include <rays/ruby/bounds.h>
5
5
  #include <rays/ruby/painter.h>
6
- #include "reflex/ruby/screen.h"
7
6
  #include "reflex/ruby/view.h"
7
+ #include "reflex/ruby/menu.h"
8
+ #include "reflex/ruby/screen.h"
8
9
  #include "defs.h"
9
10
 
10
11
 
@@ -76,6 +77,13 @@ VALUE to_screen(VALUE self, VALUE point)
76
77
  return value(THIS->to_screen(to<Rays::Point>(point)));
77
78
  }
78
79
 
80
+ static
81
+ VALUE is_active(VALUE self)
82
+ {
83
+ CHECK;
84
+ return value(THIS->active());
85
+ }
86
+
79
87
  static
80
88
  VALUE set_title(VALUE self, VALUE title)
81
89
  {
@@ -106,6 +114,21 @@ VALUE get_frame(VALUE self)
106
114
  return value(THIS->frame());
107
115
  }
108
116
 
117
+ static
118
+ VALUE set_menu(VALUE self, VALUE menu)
119
+ {
120
+ CHECK;
121
+ THIS->set_menu(menu ? to<Reflex::Menu*>(menu) : NULL);
122
+ return menu;
123
+ }
124
+
125
+ static
126
+ VALUE get_menu(VALUE self)
127
+ {
128
+ CHECK;
129
+ return value(THIS->menu());
130
+ }
131
+
109
132
  static
110
133
  VALUE set_closable(VALUE self, VALUE state)
111
134
  {
@@ -239,20 +262,6 @@ VALUE get_painter(VALUE self)
239
262
  return value(THIS->painter());
240
263
  }
241
264
 
242
- static
243
- VALUE on_activate(VALUE self, VALUE event)
244
- {
245
- CHECK;
246
- CALL(on_activate(to<Reflex::Event*>(event)));
247
- }
248
-
249
- static
250
- VALUE on_deactivate(VALUE self, VALUE event)
251
- {
252
- CHECK;
253
- CALL(on_deactivate(to<Reflex::Event*>(event)));
254
- }
255
-
256
265
  static
257
266
  VALUE on_show(VALUE self, VALUE event)
258
267
  {
@@ -278,6 +287,20 @@ VALUE on_close(VALUE self, VALUE event)
278
287
  CALL(on_close(to<Reflex::Event*>(event)));
279
288
  }
280
289
 
290
+ static
291
+ VALUE on_activate(VALUE self, VALUE event)
292
+ {
293
+ CHECK;
294
+ CALL(on_activate(to<Reflex::Event*>(event)));
295
+ }
296
+
297
+ static
298
+ VALUE on_deactivate(VALUE self, VALUE event)
299
+ {
300
+ CHECK;
301
+ CALL(on_deactivate(to<Reflex::Event*>(event)));
302
+ }
303
+
281
304
  static
282
305
  VALUE on_update(VALUE self, VALUE event)
283
306
  {
@@ -362,6 +385,20 @@ VALUE on_pointer_cancel(VALUE self, VALUE event)
362
385
  CALL(on_pointer_cancel(to<Reflex::PointerEvent*>(event)));
363
386
  }
364
387
 
388
+ static
389
+ VALUE on_pointer_enter(VALUE self, VALUE event)
390
+ {
391
+ CHECK;
392
+ CALL(on_pointer_enter(to<Reflex::PointerEvent*>(event)));
393
+ }
394
+
395
+ static
396
+ VALUE on_pointer_leave(VALUE self, VALUE event)
397
+ {
398
+ CHECK;
399
+ CALL(on_pointer_leave(to<Reflex::PointerEvent*>(event)));
400
+ }
401
+
365
402
  static
366
403
  VALUE on_wheel(VALUE self, VALUE event)
367
404
  {
@@ -420,10 +457,13 @@ Init_reflex_window ()
420
457
  rb_define_method(cWindow, "redraw", RUBY_METHOD_FUNC(redraw), 0);
421
458
  rb_define_method(cWindow, "from_screen", RUBY_METHOD_FUNC(from_screen), 1);
422
459
  rb_define_method(cWindow, "to_screen", RUBY_METHOD_FUNC(to_screen), 1);
460
+ cWindow.define_method("active?", is_active);
423
461
  rb_define_method(cWindow, "title=", RUBY_METHOD_FUNC(set_title), 1);
424
462
  rb_define_method(cWindow, "title", RUBY_METHOD_FUNC(get_title), 0);
425
463
  rb_define_method(cWindow, "frame=", RUBY_METHOD_FUNC(set_frame), -1);
426
464
  rb_define_method(cWindow, "frame", RUBY_METHOD_FUNC(get_frame), 0);
465
+ rb_define_method(cWindow, "menu=", RUBY_METHOD_FUNC(set_menu), 1);
466
+ rb_define_method(cWindow, "menu", RUBY_METHOD_FUNC(get_menu), 0);
427
467
  rb_define_method(cWindow, "closable=", RUBY_METHOD_FUNC(set_closable), 1);
428
468
  cWindow.define_method("closable?", is_closable);
429
469
  rb_define_method(cWindow, "minimizable=", RUBY_METHOD_FUNC(set_minimizable), 1);
@@ -439,11 +479,11 @@ Init_reflex_window ()
439
479
  rb_define_method(cWindow, "root", RUBY_METHOD_FUNC(get_root), 0);
440
480
  rb_define_method(cWindow, "focus", RUBY_METHOD_FUNC(get_focus), 0);
441
481
  rb_define_method(cWindow, "painter", RUBY_METHOD_FUNC(get_painter), 0);
442
- rb_define_method(cWindow, "on_activate", RUBY_METHOD_FUNC(on_activate), 1);
443
- rb_define_method(cWindow, "on_deactivate", RUBY_METHOD_FUNC(on_deactivate), 1);
444
482
  rb_define_method(cWindow, "on_show", RUBY_METHOD_FUNC(on_show), 1);
445
483
  rb_define_method(cWindow, "on_hide", RUBY_METHOD_FUNC(on_hide), 1);
446
484
  rb_define_method(cWindow, "on_close", RUBY_METHOD_FUNC(on_close), 1);
485
+ rb_define_method(cWindow, "on_activate", RUBY_METHOD_FUNC(on_activate), 1);
486
+ rb_define_method(cWindow, "on_deactivate", RUBY_METHOD_FUNC(on_deactivate), 1);
447
487
  rb_define_method(cWindow, "on_update", RUBY_METHOD_FUNC(on_update), 1);
448
488
  rb_define_method(cWindow, "on_draw", RUBY_METHOD_FUNC(on_draw), 1);
449
489
  rb_define_method(cWindow, "on_move", RUBY_METHOD_FUNC(on_move), 1);
@@ -456,6 +496,8 @@ Init_reflex_window ()
456
496
  rb_define_method(cWindow, "on_pointer_up", RUBY_METHOD_FUNC(on_pointer_up), 1);
457
497
  rb_define_method(cWindow, "on_pointer_move", RUBY_METHOD_FUNC(on_pointer_move), 1);
458
498
  rb_define_method(cWindow, "on_pointer_cancel", RUBY_METHOD_FUNC(on_pointer_cancel), 1);
499
+ rb_define_method(cWindow, "on_pointer_enter", RUBY_METHOD_FUNC(on_pointer_enter), 1);
500
+ rb_define_method(cWindow, "on_pointer_leave", RUBY_METHOD_FUNC(on_pointer_leave), 1);
459
501
  rb_define_method(cWindow, "on_wheel", RUBY_METHOD_FUNC(on_wheel), 1);
460
502
  rb_define_method(cWindow, "on_midi", RUBY_METHOD_FUNC(on_midi), 1);
461
503
  rb_define_method(cWindow, "on_note", RUBY_METHOD_FUNC(on_note), 1);
@@ -26,8 +26,17 @@ jobs:
26
26
  - name: setup dependencies
27
27
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
28
28
 
29
+ - name: packages
30
+ run: bundle exec rake packages
31
+
32
+ - name: setup zig
33
+ if: github.event.repository.name == 'reflex-terminal'
34
+ uses: mlugg/setup-zig@v2
35
+ with:
36
+ version: 0.16.0
37
+
29
38
  - name: test
30
- run: bundle exec rake packages test
39
+ run: bundle exec rake test
31
40
 
32
41
  - name: create gem
33
42
  id: gem
@@ -27,6 +27,15 @@ jobs:
27
27
  - name: packages
28
28
  run: bundle exec rake verbose packages
29
29
 
30
+ - name: setup zig
31
+ if: github.event.repository.name == 'reflex-terminal'
32
+ uses: mlugg/setup-zig@v2
33
+ with:
34
+ version: 0.16.0
35
+
36
+ - name: vendor
37
+ run: bundle exec rake vendor
38
+
30
39
  - name: lib
31
40
  run: bundle exec rake verbose lib
32
41