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
@@ -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
 
@@ -84,6 +85,14 @@ RUCY_DEF1(to_screen, point)
84
85
  }
85
86
  RUCY_END
86
87
 
88
+ static
89
+ RUCY_DEF0(is_active)
90
+ {
91
+ CHECK;
92
+ return value(THIS->active());
93
+ }
94
+ RUCY_END
95
+
87
96
  static
88
97
  RUCY_DEF1(set_title, title)
89
98
  {
@@ -118,6 +127,23 @@ RUCY_DEF0(get_frame)
118
127
  }
119
128
  RUCY_END
120
129
 
130
+ static
131
+ RUCY_DEF1(set_menu, menu)
132
+ {
133
+ CHECK;
134
+ THIS->set_menu(menu ? to<Reflex::Menu*>(menu) : NULL);
135
+ return menu;
136
+ }
137
+ RUCY_END
138
+
139
+ static
140
+ RUCY_DEF0(get_menu)
141
+ {
142
+ CHECK;
143
+ return value(THIS->menu());
144
+ }
145
+ RUCY_END
146
+
121
147
  static
122
148
  RUCY_DEF1(set_closable, state)
123
149
  {
@@ -266,46 +292,46 @@ RUCY_DEF0(get_painter)
266
292
  RUCY_END
267
293
 
268
294
  static
269
- RUCY_DEF1(on_activate, event)
295
+ RUCY_DEF1(on_show, event)
270
296
  {
271
297
  CHECK;
272
- CALL(on_activate(to<Reflex::Event*>(event)));
298
+
299
+ RUCY_SYM(call_show_block);
300
+ self.call(call_show_block);
301
+
302
+ CALL(on_show(to<Reflex::Event*>(event)));
273
303
  }
274
304
  RUCY_END
275
305
 
276
306
  static
277
- RUCY_DEF1(on_deactivate, event)
307
+ RUCY_DEF1(on_hide, event)
278
308
  {
279
309
  CHECK;
280
- CALL(on_deactivate(to<Reflex::Event*>(event)));
310
+ CALL(on_hide(to<Reflex::Event*>(event)));
281
311
  }
282
312
  RUCY_END
283
313
 
284
314
  static
285
- RUCY_DEF1(on_show, event)
315
+ RUCY_DEF1(on_close, event)
286
316
  {
287
317
  CHECK;
288
-
289
- RUCY_SYM(call_show_block);
290
- self.call(call_show_block);
291
-
292
- CALL(on_show(to<Reflex::Event*>(event)));
318
+ CALL(on_close(to<Reflex::Event*>(event)));
293
319
  }
294
320
  RUCY_END
295
321
 
296
322
  static
297
- RUCY_DEF1(on_hide, event)
323
+ RUCY_DEF1(on_activate, event)
298
324
  {
299
325
  CHECK;
300
- CALL(on_hide(to<Reflex::Event*>(event)));
326
+ CALL(on_activate(to<Reflex::Event*>(event)));
301
327
  }
302
328
  RUCY_END
303
329
 
304
330
  static
305
- RUCY_DEF1(on_close, event)
331
+ RUCY_DEF1(on_deactivate, event)
306
332
  {
307
333
  CHECK;
308
- CALL(on_close(to<Reflex::Event*>(event)));
334
+ CALL(on_deactivate(to<Reflex::Event*>(event)));
309
335
  }
310
336
  RUCY_END
311
337
 
@@ -405,6 +431,22 @@ RUCY_DEF1(on_pointer_cancel, event)
405
431
  }
406
432
  RUCY_END
407
433
 
434
+ static
435
+ RUCY_DEF1(on_pointer_enter, event)
436
+ {
437
+ CHECK;
438
+ CALL(on_pointer_enter(to<Reflex::PointerEvent*>(event)));
439
+ }
440
+ RUCY_END
441
+
442
+ static
443
+ RUCY_DEF1(on_pointer_leave, event)
444
+ {
445
+ CHECK;
446
+ CALL(on_pointer_leave(to<Reflex::PointerEvent*>(event)));
447
+ }
448
+ RUCY_END
449
+
408
450
  static
409
451
  RUCY_DEF1(on_wheel, event)
410
452
  {
@@ -469,10 +511,13 @@ Init_reflex_window ()
469
511
  cWindow.define_method("redraw", redraw);
470
512
  cWindow.define_method("from_screen", from_screen);
471
513
  cWindow.define_method( "to_screen", to_screen);
514
+ cWindow.define_method("active?", is_active);
472
515
  cWindow.define_method("title=", set_title);
473
- cWindow.define_method("title", get_title);
516
+ cWindow.define_method("title", get_title);
474
517
  cWindow.define_method("frame=", set_frame);
475
518
  cWindow.define_method("frame", get_frame);
519
+ cWindow.define_method("menu=", set_menu);
520
+ cWindow.define_method("menu", get_menu);
476
521
  cWindow.define_method("closable=", set_closable);
477
522
  cWindow.define_method("closable?", is_closable);
478
523
  cWindow.define_method("minimizable=", set_minimizable);
@@ -488,11 +533,11 @@ Init_reflex_window ()
488
533
  cWindow.define_method("root", get_root);
489
534
  cWindow.define_method("focus", get_focus);
490
535
  cWindow.define_method("painter", get_painter);
491
- cWindow.define_method("on_activate", on_activate);
492
- cWindow.define_method("on_deactivate", on_deactivate);
493
536
  cWindow.define_method("on_show", on_show);
494
537
  cWindow.define_method("on_hide", on_hide);
495
538
  cWindow.define_method("on_close", on_close);
539
+ cWindow.define_method("on_activate", on_activate);
540
+ cWindow.define_method("on_deactivate", on_deactivate);
496
541
  cWindow.define_method("on_update", on_update);
497
542
  cWindow.define_method("on_draw", on_draw);
498
543
  cWindow.define_method("on_move", on_move);
@@ -505,6 +550,8 @@ Init_reflex_window ()
505
550
  cWindow.define_method("on_pointer_up", on_pointer_up);
506
551
  cWindow.define_method("on_pointer_move", on_pointer_move);
507
552
  cWindow.define_method("on_pointer_cancel", on_pointer_cancel);
553
+ cWindow.define_method("on_pointer_enter", on_pointer_enter);
554
+ cWindow.define_method("on_pointer_leave", on_pointer_leave);
508
555
  cWindow.define_method("on_wheel", on_wheel);
509
556
  cWindow.define_method("on_midi", on_midi);
510
557
  cWindow.define_method("on_note", on_note);
@@ -16,6 +16,9 @@ namespace Reflex
16
16
  {
17
17
 
18
18
 
19
+ class Menu;
20
+
21
+
19
22
  class Application : public Xot::RefCountable<>
20
23
  {
21
24
 
@@ -41,6 +44,12 @@ namespace Reflex
41
44
 
42
45
  virtual const char* name () const;
43
46
 
47
+ virtual void set_menu (Menu* menu);
48
+
49
+ virtual Menu* menu ();
50
+
51
+ virtual const Menu* menu () const;
52
+
44
53
  virtual window_iterator window_begin ();
45
54
 
46
55
  virtual const_window_iterator window_begin () const;
@@ -0,0 +1,53 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_CLIPBOARD_H__
4
+ #define __REFLEX_CLIPBOARD_H__
5
+
6
+
7
+ #include <xot/pimpl.h>
8
+ #include <reflex/defs.h>
9
+
10
+
11
+ namespace Reflex
12
+ {
13
+
14
+
15
+ class Clipboard
16
+ {
17
+
18
+ public:
19
+
20
+ Clipboard (const char* text = NULL);
21
+
22
+ ~Clipboard ();
23
+
24
+ void set_text (const char* text);
25
+
26
+ const char* text () const;
27
+
28
+ void set_image (const Image& image);
29
+
30
+ const Image* image () const;
31
+
32
+ void clear ();
33
+
34
+ operator bool () const;
35
+
36
+ bool operator ! () const;
37
+
38
+ struct Data;
39
+
40
+ Xot::PSharedImpl<Data> self;
41
+
42
+ };// Clipboard
43
+
44
+
45
+ void set_clipboard (const Clipboard& clipboard);
46
+
47
+ Clipboard get_clipboard ();
48
+
49
+
50
+ }// Reflex
51
+
52
+
53
+ #endif//EOH
@@ -0,0 +1,275 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_CONSTRAINT_H__
4
+ #define __REFLEX_CONSTRAINT_H__
5
+
6
+
7
+ #include <xot/ref.h>
8
+ #include <xot/pimpl.h>
9
+ #include <rays/point.h>
10
+ #include <reflex/defs.h>
11
+ #include <reflex/selector.h>
12
+
13
+
14
+ namespace Reflex
15
+ {
16
+
17
+
18
+ class View;
19
+ class Pin;
20
+
21
+
22
+ class Constraint : public Xot::RefCountable<>, public HasSelector
23
+ {
24
+
25
+ typedef Constraint This;
26
+
27
+ public:
28
+
29
+ typedef Xot::Ref<This> Ref;
30
+
31
+ virtual ~Constraint ();
32
+
33
+ virtual void remove ();
34
+
35
+ virtual const Pin& pin (size_t index) const;
36
+
37
+ virtual View* view (size_t index);
38
+
39
+ virtual const View* view (size_t index) const;
40
+
41
+ virtual void set_spring (float hertz);
42
+
43
+ virtual float spring () const;
44
+
45
+ virtual void set_damping (float ratio);
46
+
47
+ virtual float damping () const;
48
+
49
+ virtual void set_collide (bool state);
50
+
51
+ virtual bool can_collide () const;
52
+
53
+ virtual bool is_removed () const;
54
+
55
+ virtual operator bool () const;
56
+
57
+ virtual bool operator ! () const;
58
+
59
+ struct Data;
60
+
61
+ Xot::PImpl<Data> self;
62
+
63
+ protected:
64
+
65
+ Constraint (Data* data);
66
+
67
+ virtual SelectorPtr* get_selector_ptr () override;
68
+
69
+ };// Constraint
70
+
71
+
72
+ class SnapConstraint : public Constraint
73
+ {
74
+
75
+ typedef Constraint Super;
76
+
77
+ public:
78
+
79
+ virtual ~SnapConstraint ();
80
+
81
+ virtual void set_angle (float min_degree, float max_degree);
82
+
83
+ virtual void clear_angle ();
84
+
85
+ virtual float angle_min () const;
86
+
87
+ virtual float angle_max () const;
88
+
89
+ virtual bool has_angle () const;
90
+
91
+ virtual void set_motor (float degrees_per_second);
92
+
93
+ virtual void clear_motor ();
94
+
95
+ virtual float motor () const;
96
+
97
+ virtual bool has_motor () const;
98
+
99
+ virtual void set_force (float max_torque);
100
+ // the default is 1000 * mass, and 0 makes the motor powerless
101
+
102
+ virtual void clear_force ();
103
+
104
+ virtual float force () const;
105
+
106
+ virtual bool has_force () const;
107
+
108
+ protected:
109
+
110
+ SnapConstraint ();
111
+
112
+ friend class Pin;
113
+
114
+ friend SnapConstraint* SnapConstraint_create ();
115
+
116
+ };// SnapConstraint
117
+
118
+
119
+ class LinkConstraint : public Constraint
120
+ {
121
+
122
+ typedef Constraint Super;
123
+
124
+ public:
125
+
126
+ virtual ~LinkConstraint ();
127
+
128
+ virtual void set_axis (coord x, coord y);
129
+
130
+ virtual void set_axis (const Point& direction);
131
+
132
+ virtual void clear_axis ();
133
+
134
+ virtual const Point& axis () const;
135
+
136
+ virtual bool has_axis () const;
137
+
138
+ virtual void set_distance (coord distance);
139
+
140
+ virtual void clear_distance ();
141
+
142
+ virtual coord distance () const;
143
+
144
+ virtual bool has_distance () const;
145
+
146
+ virtual coord current_distance () const;
147
+
148
+ virtual void set_range (coord min, coord max);
149
+
150
+ virtual void clear_range ();
151
+
152
+ virtual coord range_min () const;
153
+
154
+ virtual coord range_max () const;
155
+
156
+ virtual bool has_range () const;
157
+
158
+ virtual void set_motor (coord pixels_per_second);
159
+
160
+ virtual void clear_motor ();
161
+
162
+ virtual coord motor () const;
163
+
164
+ virtual bool has_motor () const;
165
+
166
+ virtual void set_force (float max_force);
167
+ // the default is 1000 * mass, and 0 makes it powerless
168
+
169
+ virtual void clear_force ();
170
+
171
+ virtual float force () const;
172
+
173
+ virtual bool has_force () const;
174
+
175
+ protected:
176
+
177
+ LinkConstraint ();
178
+
179
+ friend class Pin;
180
+
181
+ friend LinkConstraint* LinkConstraint_create ();
182
+
183
+ };// LinkConstraint
184
+
185
+
186
+ class WheelConstraint : public Constraint
187
+ {
188
+
189
+ typedef Constraint Super;
190
+
191
+ public:
192
+
193
+ virtual ~WheelConstraint ();
194
+
195
+ virtual void set_axis (coord x, coord y);
196
+
197
+ virtual void set_axis (const Point& direction);
198
+
199
+ virtual const Point& axis () const;
200
+
201
+ virtual void set_range (coord min, coord max);
202
+
203
+ virtual void clear_range ();
204
+
205
+ virtual coord range_min () const;
206
+
207
+ virtual coord range_max () const;
208
+
209
+ virtual bool has_range () const;
210
+
211
+ virtual void set_motor (float degrees_per_second);
212
+
213
+ virtual void clear_motor ();
214
+
215
+ virtual float motor () const;
216
+
217
+ virtual bool has_motor () const;
218
+
219
+ virtual void set_force (float max_torque);
220
+ // the default is 1000 * mass, and 0 makes the motor powerless
221
+
222
+ virtual void clear_force ();
223
+
224
+ virtual float force () const;
225
+
226
+ virtual bool has_force () const;
227
+
228
+ protected:
229
+
230
+ WheelConstraint ();
231
+
232
+ friend class Pin;
233
+
234
+ friend WheelConstraint* WheelConstraint_create ();
235
+
236
+ };// WheelConstraint
237
+
238
+
239
+ class ChaseConstraint : public Constraint
240
+ {
241
+
242
+ typedef Constraint Super;
243
+
244
+ public:
245
+
246
+ virtual ~ChaseConstraint ();
247
+
248
+ virtual void set_target (const Pin& target);
249
+
250
+ virtual const Pin& target () const;
251
+
252
+ virtual void set_force (float max_force);
253
+ // the default is 1000 * mass, and 0 makes it powerless
254
+
255
+ virtual void clear_force ();
256
+
257
+ virtual float force () const;
258
+
259
+ virtual bool has_force () const;
260
+
261
+ protected:
262
+
263
+ ChaseConstraint ();
264
+
265
+ friend class Pin;
266
+
267
+ friend ChaseConstraint* ChaseConstraint_create ();
268
+
269
+ };// ChaseConstraint
270
+
271
+
272
+ }// Reflex
273
+
274
+
275
+ #endif//EOH