reflexion 0.1.23 → 0.1.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/capture_event.cpp +6 -5
  3. data/.doc/ext/reflex/contact_event.cpp +14 -12
  4. data/.doc/ext/reflex/draw_event.cpp +10 -8
  5. data/.doc/ext/reflex/event.cpp +2 -10
  6. data/.doc/ext/reflex/focus_event.cpp +14 -13
  7. data/.doc/ext/reflex/frame_event.cpp +17 -17
  8. data/.doc/ext/reflex/key_event.cpp +20 -19
  9. data/.doc/ext/reflex/pointer_event.cpp +1 -1
  10. data/.doc/ext/reflex/scroll_event.cpp +14 -17
  11. data/.doc/ext/reflex/timer.cpp +9 -1
  12. data/.doc/ext/reflex/timer_event.cpp +4 -13
  13. data/.doc/ext/reflex/update_event.cpp +6 -5
  14. data/.doc/ext/reflex/wheel_event.cpp +39 -22
  15. data/VERSION +1 -1
  16. data/ext/reflex/capture_event.cpp +6 -5
  17. data/ext/reflex/contact_event.cpp +16 -14
  18. data/ext/reflex/draw_event.cpp +9 -7
  19. data/ext/reflex/event.cpp +2 -11
  20. data/ext/reflex/focus_event.cpp +14 -13
  21. data/ext/reflex/frame_event.cpp +16 -16
  22. data/ext/reflex/key_event.cpp +20 -19
  23. data/ext/reflex/pointer_event.cpp +1 -1
  24. data/ext/reflex/scroll_event.cpp +15 -18
  25. data/ext/reflex/timer.cpp +15 -6
  26. data/ext/reflex/timer_event.cpp +9 -19
  27. data/ext/reflex/update_event.cpp +6 -5
  28. data/ext/reflex/wheel_event.cpp +40 -21
  29. data/include/reflex/event.h +224 -115
  30. data/include/reflex/shape.h +2 -2
  31. data/lib/reflex/contact_event.rb +7 -7
  32. data/lib/reflex/focus_event.rb +8 -8
  33. data/lib/reflex/key_event.rb +8 -8
  34. data/lib/reflex/pointer.rb +3 -3
  35. data/lib/reflex/timer_event.rb +2 -1
  36. data/lib/reflex/wheel_event.rb +1 -9
  37. data/lib/reflex/window.rb +1 -1
  38. data/reflex.gemspec +4 -4
  39. data/src/event.cpp +630 -76
  40. data/src/event.h +15 -0
  41. data/src/image_view.cpp +2 -2
  42. data/src/ios/view_controller.mm +1 -1
  43. data/src/osx/event.h +1 -1
  44. data/src/osx/event.mm +9 -9
  45. data/src/osx/native_window.mm +1 -1
  46. data/src/shape.cpp +11 -13
  47. data/src/shape.h +1 -1
  48. data/src/view.cpp +137 -89
  49. data/src/view.h +5 -6
  50. data/src/window.cpp +44 -38
  51. data/src/world.cpp +6 -4
  52. data/test/test_capture_event.rb +16 -0
  53. data/test/test_contact_event.rb +40 -0
  54. data/test/test_draw_event.rb +35 -0
  55. data/test/test_event.rb +20 -6
  56. data/test/test_focus_event.rb +34 -0
  57. data/test/test_frame_event.rb +38 -0
  58. data/test/test_key_event.rb +33 -0
  59. data/test/test_pointer.rb +14 -14
  60. data/test/test_pointer_event.rb +1 -1
  61. data/test/test_scroll_event.rb +39 -0
  62. data/test/test_timer_event.rb +38 -0
  63. data/test/test_update_event.rb +29 -0
  64. data/test/test_wheel_event.rb +40 -0
  65. metadata +29 -11
@@ -28,78 +28,129 @@ namespace Reflex
28
28
 
29
29
  Event ();
30
30
 
31
+ ~Event ();
32
+
31
33
  void block ();
32
34
 
33
35
  bool is_blocked () const;
34
36
 
35
37
  double time () const;
36
38
 
37
- private:
39
+ struct Data;
40
+
41
+ Xot::PSharedImpl<Data> self;
38
42
 
39
- bool blocked;
43
+ protected:
40
44
 
41
- double time_;
45
+ Event (const Event* src);
42
46
 
43
47
  };// Event
44
48
 
45
49
 
46
- struct UpdateEvent : public Event
50
+ class UpdateEvent : public Event
47
51
  {
48
52
 
49
- double now;
53
+ public:
54
+
55
+ UpdateEvent ();
56
+
57
+ UpdateEvent (double now, float dt);
50
58
 
51
- float dt;
59
+ UpdateEvent dup () const;
60
+
61
+ double now () const;
62
+
63
+ float dt () const;
64
+
65
+ struct Data;
66
+
67
+ Xot::PSharedImpl<Data> self;
68
+
69
+ private:
52
70
 
53
- UpdateEvent (double now = 0, float dt = 0);
71
+ UpdateEvent (const UpdateEvent* src);
54
72
 
55
73
  };// UpdateEvent
56
74
 
57
75
 
58
- struct DrawEvent : public Event
76
+ class DrawEvent : public Event
59
77
  {
60
78
 
61
- View* view;
79
+ public:
80
+
81
+ DrawEvent ();
82
+
83
+ DrawEvent (float dt, float fps);
84
+
85
+ DrawEvent dup () const;
62
86
 
63
- Painter* painter;
87
+ Painter* painter ();
64
88
 
65
- Bounds bounds;
89
+ const Painter* painter () const;
66
90
 
67
- float dt, fps;
91
+ const Bounds& bounds () const;
68
92
 
69
- DrawEvent (float dt = 0, float fps = 0);
93
+ float dt () const;
94
+
95
+ float fps () const;
96
+
97
+ struct Data;
98
+
99
+ Xot::PSharedImpl<Data> self;
100
+
101
+ private:
102
+
103
+ DrawEvent (const DrawEvent* src);
70
104
 
71
105
  };// DrawEvent
72
106
 
73
107
 
74
- struct FrameEvent : public Event
108
+ class FrameEvent : public Event
75
109
  {
76
110
 
77
- Bounds frame;
111
+ public:
112
+
113
+ FrameEvent ();
78
114
 
79
- coord dx, dy;
115
+ FrameEvent (
116
+ const Bounds& frame,
117
+ coord dx, coord dy,
118
+ coord dwidth, coord dheight,
119
+ float angle, float dangle);
80
120
 
81
- union
82
- {
83
- struct {coord dwidth, dheight;};
121
+ FrameEvent (
122
+ const Bounds& frame, const Bounds& prev_frame,
123
+ float angle, float prev_angle);
84
124
 
85
- struct {coord dw, dh;};
86
- };
125
+ FrameEvent dup () const;
87
126
 
88
- float angle, dangle;
127
+ const Bounds& frame () const;
89
128
 
90
- FrameEvent (
91
- const Bounds& frame = 0, coord dx = 0, coord dy = 0, coord dwidth = 0, coord dheight = 0,
92
- float angle = 0, float dangle = 0);
129
+ coord dx () const;
93
130
 
94
- FrameEvent (
95
- const Bounds& frame, const Bounds& prev_frame,
96
- float angle = 0, float prev_angle = 0);
131
+ coord dy () const;
97
132
 
98
- bool is_move () const;
133
+ coord dwidth () const;
99
134
 
100
- bool is_resize () const;
135
+ coord dheight () const;
101
136
 
102
- bool is_rotate () const;
137
+ float angle () const;
138
+
139
+ float dangle () const;
140
+
141
+ bool is_move () const;
142
+
143
+ bool is_resize () const;
144
+
145
+ bool is_rotate () const;
146
+
147
+ struct Data;
148
+
149
+ Xot::PSharedImpl<Data> self;
150
+
151
+ private:
152
+
153
+ FrameEvent (const FrameEvent* src);
103
154
 
104
155
  };// FrameEvent
105
156
 
@@ -107,31 +158,29 @@ namespace Reflex
107
158
  struct ScrollEvent : public Event
108
159
  {
109
160
 
110
- union
111
- {
112
- struct {coord x, y, z;};
161
+ public:
162
+
163
+ ScrollEvent ();
164
+
165
+ ScrollEvent (coord x, coord y, coord z, coord dx, coord dy, coord dz);
113
166
 
114
- Coord3 scroll_;
115
- };
167
+ ScrollEvent dup () const;
116
168
 
117
- union
118
- {
119
- struct {coord dx, dy, dz;};
169
+ Point& scroll ();
120
170
 
121
- Coord3 delta_;
122
- };
171
+ const Point& scroll () const;
123
172
 
124
- ScrollEvent ();
173
+ Point& dscroll ();
125
174
 
126
- ScrollEvent (coord x, coord y, coord z, coord dx, coord dy, coord dz);
175
+ const Point& dscroll () const;
127
176
 
128
- Point& scroll ();
177
+ struct Data;
129
178
 
130
- const Point& scroll () const;
179
+ Xot::PSharedImpl<Data> self;
131
180
 
132
- Point& delta ();
181
+ private:
133
182
 
134
- const Point& delta () const;
183
+ ScrollEvent (const ScrollEvent* src);
135
184
 
136
185
  };// ScrollEvent
137
186
 
@@ -139,15 +188,29 @@ namespace Reflex
139
188
  struct FocusEvent : public Event
140
189
  {
141
190
 
142
- enum Type {NONE = 0, FOCUS, BLUR};
191
+ public:
192
+
193
+ enum Action {ACTION_NONE = 0, FOCUS, BLUR};
143
194
 
144
- Type type;
195
+ FocusEvent ();
145
196
 
146
- View *current, *last;
197
+ FocusEvent (Action action, View* current, View* last);
147
198
 
148
- FocusEvent ();
199
+ FocusEvent dup () const;
149
200
 
150
- FocusEvent (Type type, View* current, View* last);
201
+ Action action () const;
202
+
203
+ View* current () const;
204
+
205
+ View* last () const;
206
+
207
+ struct Data;
208
+
209
+ Xot::PSharedImpl<Data> self;
210
+
211
+ private:
212
+
213
+ FocusEvent (const FocusEvent* src);
151
214
 
152
215
  };// FocusEvent
153
216
 
@@ -155,51 +218,51 @@ namespace Reflex
155
218
  struct KeyEvent : public Event
156
219
  {
157
220
 
158
- enum Type {NONE = 0, DOWN, UP};
221
+ public:
159
222
 
160
- Type type;
223
+ enum Action {ACTION_NONE = 0, DOWN, UP};
161
224
 
162
- String chars;
225
+ KeyEvent ();
163
226
 
164
- int code;
227
+ KeyEvent (
228
+ Action action, const char* chars, int code,
229
+ uint modifiers = 0, int repeat = 0);
165
230
 
166
- uint modifiers;
231
+ KeyEvent dup () const;
167
232
 
168
- int repeat;
233
+ Action action () const;
169
234
 
170
- bool captured;
235
+ const char* chars () const;
171
236
 
172
- KeyEvent ();
237
+ int code () const;
173
238
 
174
- KeyEvent (
175
- Type type, const char* chars, int code,
176
- uint modifiers = 0, int repeat = 0);
239
+ uint modifiers () const;
177
240
 
178
- };// KeyEvent
241
+ int repeat () const;
179
242
 
243
+ bool is_captured () const;
180
244
 
181
- class PointerEvent : public Event
182
- {
245
+ struct Data;
183
246
 
184
- typedef PointerEvent This;
247
+ Xot::PSharedImpl<Data> self;
185
248
 
186
- public:
249
+ private:
187
250
 
188
- PointerEvent (bool captured = false);
251
+ KeyEvent (const KeyEvent* src);
189
252
 
190
- PointerEvent (
191
- const Pointer& pointer,
192
- bool captured = false);
253
+ };// KeyEvent
254
+
255
+
256
+ class PointerEvent : public Event
257
+ {
193
258
 
194
- PointerEvent (
195
- const Pointer* pointers, size_t size,
196
- bool captured = false);
259
+ public:
197
260
 
198
- PointerEvent (const This& obj);
261
+ PointerEvent ();
199
262
 
200
- PointerEvent& operator = (const This& obj);
263
+ PointerEvent (const Pointer* pointers, size_t size);
201
264
 
202
- ~PointerEvent ();
265
+ PointerEvent dup () const;
203
266
 
204
267
  size_t size () const;
205
268
 
@@ -211,7 +274,11 @@ namespace Reflex
211
274
 
212
275
  struct Data;
213
276
 
214
- Xot::PImpl<Data> self;
277
+ Xot::PSharedImpl<Data> self;
278
+
279
+ private:
280
+
281
+ PointerEvent (const PointerEvent* src);
215
282
 
216
283
  };// PointerEvent
217
284
 
@@ -219,35 +286,33 @@ namespace Reflex
219
286
  struct WheelEvent : public Event
220
287
  {
221
288
 
222
- union
223
- {
224
- struct {coord dx, dy, dz;};
289
+ public:
225
290
 
226
- Coord3 delta_;
227
- };
291
+ WheelEvent ();
228
292
 
229
- union
230
- {
231
- struct {coord x, y, z;};
293
+ WheelEvent (
294
+ coord x, coord y, coord z, coord dx, coord dy, coord dz,
295
+ uint modifiers = 0);
232
296
 
233
- Coord3 position_;
234
- };
297
+ WheelEvent dup () const;
235
298
 
236
- uint modifiers;
299
+ Point& position ();
237
300
 
238
- WheelEvent ();
301
+ const Point& position () const;
239
302
 
240
- WheelEvent (
241
- coord dx, coord dy, coord dz, coord x = 0, coord y = 0, coord z = 0,
242
- uint modifiers = 0);
303
+ Point& dposition ();
243
304
 
244
- Point& position ();
305
+ const Point& dposition () const;
245
306
 
246
- const Point& position () const;
307
+ uint modifiers () const;
247
308
 
248
- Point& delta ();
309
+ struct Data;
310
+
311
+ Xot::PSharedImpl<Data> self;
249
312
 
250
- const Point& delta () const;
313
+ private:
314
+
315
+ WheelEvent (const WheelEvent* src);
251
316
 
252
317
  };// WheelEvent
253
318
 
@@ -255,11 +320,25 @@ namespace Reflex
255
320
  struct CaptureEvent : public Event
256
321
  {
257
322
 
258
- uint begin, end;
323
+ public:
324
+
325
+ CaptureEvent ();
326
+
327
+ CaptureEvent (uint begin, uint end);
328
+
329
+ CaptureEvent dup () const;
330
+
331
+ uint begin () const;
259
332
 
260
- CaptureEvent ();
333
+ uint end () const;
261
334
 
262
- CaptureEvent (uint begin, uint end);
335
+ struct Data;
336
+
337
+ Xot::PSharedImpl<Data> self;
338
+
339
+ private:
340
+
341
+ CaptureEvent (const CaptureEvent* src);
263
342
 
264
343
  };// CaptureEvent
265
344
 
@@ -267,21 +346,35 @@ namespace Reflex
267
346
  struct TimerEvent : public Event
268
347
  {
269
348
 
270
- Timer::Ref timer;
349
+ public:
350
+
351
+ TimerEvent ();
352
+
353
+ TimerEvent (Timer* timer);
354
+
355
+ TimerEvent dup () const;
356
+
357
+ Timer* timer ();
358
+
359
+ const Timer* timer () const;
360
+
361
+ View* owner () const;
362
+
363
+ int id () const;
271
364
 
272
- TimerEvent (Timer* timer = NULL);
365
+ float interval () const;
273
366
 
274
- View* owner () const;
367
+ int count () const;
275
368
 
276
- int id () const;
369
+ bool is_finished () const;
277
370
 
278
- float interval () const;
371
+ struct Data;
279
372
 
280
- void set_count (int count);
373
+ Xot::PSharedImpl<Data> self;
281
374
 
282
- int count () const;
375
+ private:
283
376
 
284
- bool is_finished () const;
377
+ TimerEvent (const TimerEvent* src);
285
378
 
286
379
  };// TimerEvent
287
380
 
@@ -289,17 +382,33 @@ namespace Reflex
289
382
  struct ContactEvent : public Event
290
383
  {
291
384
 
292
- enum Type {NONE = 0, BEGIN, END};
385
+ public:
386
+
387
+ enum Action {ACTION_NONE = 0, BEGIN, END};
388
+
389
+ ContactEvent ();
390
+
391
+ ContactEvent (Action action, Shape* shape);
392
+
393
+ ContactEvent dup () const;
293
394
 
294
- Type type;
395
+ Action action () const;
295
396
 
296
- Shape* shape;
397
+ Shape* shape ();
297
398
 
298
- View* view;
399
+ const Shape* shape () const;
299
400
 
300
- ContactEvent ();
401
+ View* view ();
402
+
403
+ const View* view () const;
404
+
405
+ struct Data;
406
+
407
+ Xot::PSharedImpl<Data> self;
408
+
409
+ private:
301
410
 
302
- ContactEvent (Type type, Shape* shape);
411
+ ContactEvent (const ContactEvent* src);
303
412
 
304
413
  };// ContactEvent
305
414
 
@@ -16,8 +16,8 @@ namespace Reflex
16
16
 
17
17
 
18
18
  class Event;
19
- struct DrawEvent;
20
- struct FrameEvent;
19
+ class DrawEvent;
20
+ class FrameEvent;
21
21
  struct ContactEvent;
22
22
 
23
23
  class View;
@@ -10,20 +10,20 @@ module Reflex
10
10
 
11
11
  class ContactEvent < Event
12
12
 
13
- alias get_type type
13
+ alias get_action action
14
14
 
15
- const_symbol_reader :type, **{
16
- none: TYPE_NONE,
17
- begin: TYPE_BEGIN,
18
- end: TYPE_END
15
+ const_symbol_reader :action, **{
16
+ none: ACTION_NONE,
17
+ begin: ContactEvent::BEGIN,
18
+ end: ContactEvent::END
19
19
  }
20
20
 
21
21
  def begin?()
22
- get_type == TYPE_BEGIN
22
+ get_action == ContactEvent::BEGIN
23
23
  end
24
24
 
25
25
  def end?()
26
- get_type == TYPE_END
26
+ get_action == ContactEvent::END
27
27
  end
28
28
 
29
29
  def inspect()
@@ -10,24 +10,24 @@ module Reflex
10
10
 
11
11
  class FocusEvent < Event
12
12
 
13
- alias get_type type
13
+ alias get_action action
14
14
 
15
- const_symbol_reader :type, **{
16
- none: TYPE_NONE,
17
- focus: TYPE_FOCUS,
18
- blur: TYPE_BLUR
15
+ const_symbol_reader :action, **{
16
+ none: ACTION_NONE,
17
+ focus: FOCUS,
18
+ blur: BLUR
19
19
  }
20
20
 
21
21
  def focus?()
22
- get_type == TYPE_FOCUS
22
+ get_action == FOCUS
23
23
  end
24
24
 
25
25
  def blur?()
26
- get_type == TYPE_BLUR
26
+ get_action == BLUR
27
27
  end
28
28
 
29
29
  def inspect()
30
- "#<Reflex::FocusEvent type:#{type} current:#{current} last:#{last}>"
30
+ "#<Reflex::FocusEvent action:#{action} current:#{current} last:#{last}>"
31
31
  end
32
32
 
33
33
  end# FocusEvent
@@ -10,20 +10,20 @@ module Reflex
10
10
 
11
11
  class KeyEvent < Event
12
12
 
13
- alias get_type type
13
+ alias get_action action
14
14
 
15
- const_symbol_reader :type, **{
16
- none: TYPE_NONE,
17
- down: TYPE_DOWN,
18
- up: TYPE_UP
15
+ const_symbol_reader :action, **{
16
+ none: ACTION_NONE,
17
+ down: DOWN,
18
+ up: UP
19
19
  }
20
20
 
21
21
  def down?()
22
- get_type == TYPE_DOWN
22
+ get_action == DOWN
23
23
  end
24
24
 
25
25
  def up?()
26
- get_type == TYPE_UP
26
+ get_action == UP
27
27
  end
28
28
 
29
29
  def repeat?()
@@ -31,7 +31,7 @@ module Reflex
31
31
  end
32
32
 
33
33
  def inspect()
34
- "#<Reflex::KeyEvent type:#{type} chars:'#{chars}' code:#{code} mod:#{modifiers} repeat:#{repeat} captured?:#{captured?}>"
34
+ "#<Reflex::KeyEvent action:#{action} chars:'#{chars}' code:#{code} mod:#{modifiers} repeat:#{repeat} captured?:#{captured?}>"
35
35
  end
36
36
 
37
37
  end# KeyEvent
@@ -13,10 +13,10 @@ module Reflex
13
13
 
14
14
  include Comparable
15
15
 
16
- alias type get_type
16
+ alias types get_type
17
17
  alias action get_action
18
18
 
19
- bit_flag_reader :type, **{
19
+ bit_flag_reader :types, **{
20
20
  none: TYPE_NONE,
21
21
  mouse: MOUSE,
22
22
  mouse_left: MOUSE_LEFT,
@@ -98,7 +98,7 @@ module Reflex
98
98
  end
99
99
 
100
100
  def inspect()
101
- "#<Reflex::Pointer id:#{id} #{type} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} click:#{click_count} drag:#{drag?} time:#{time.round 2}>"
101
+ "#<Reflex::Pointer id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} click:#{click_count} drag:#{drag?} time:#{time.round 2}>"
102
102
  end
103
103
 
104
104
  end# Pointer
@@ -15,7 +15,8 @@ module Reflex
15
15
  def_delegators :timer,
16
16
  :name=, :name,
17
17
  :add_tag, :remove_tag, :each_tag,
18
- :selector=, :selector
18
+ :selector=, :selector,
19
+ :count=
19
20
 
20
21
  alias view owner
21
22
 
@@ -9,16 +9,8 @@ module Reflex
9
9
 
10
10
  class WheelEvent < Event
11
11
 
12
- def position()
13
- Point.new x, y, z
14
- end
15
-
16
- def delta()
17
- Point.new dx, dy, dz
18
- end
19
-
20
12
  def inspect()
21
- "#<Reflex::WheelEvent dx:#{dx} dy:#{dy} dz:#{dz} x:#{x} y:#{y} z:#{z} mod:#{modifiers}>"
13
+ "#<Reflex::WheelEvent x:#{x} y:#{y} z:#{z} dx:#{dx} dy:#{dy} dz:#{dz} mod:#{modifiers}>"
22
14
  end
23
15
 
24
16
  end# WheelEvent
data/lib/reflex/window.rb CHANGED
@@ -24,7 +24,7 @@ module Reflex
24
24
  :timeout, :delay, :interval,
25
25
  :add_child, :add,
26
26
  :remove_child, :remove,
27
- :find_child, :find, :find_children,
27
+ :children, :find_child, :find, :find_children,
28
28
  :style, :styles, :scroll_to, :scroll_by, :scroll,
29
29
  :meter2pixel, :meter, :wall,
30
30
  :zoom=, :zoom,
data/reflex.gemspec CHANGED
@@ -28,10 +28,10 @@ Gem::Specification.new do |s|
28
28
  s.platform = Gem::Platform::RUBY
29
29
  s.required_ruby_version = '>= 2.6.0'
30
30
 
31
- s.add_runtime_dependency 'xot', '~> 0.1.23'
32
- s.add_runtime_dependency 'rucy', '~> 0.1.23'
33
- s.add_runtime_dependency 'beeps', '~> 0.1.23'
34
- s.add_runtime_dependency 'rays', '~> 0.1.23'
31
+ s.add_runtime_dependency 'xot', '~> 0.1.24'
32
+ s.add_runtime_dependency 'rucy', '~> 0.1.24'
33
+ s.add_runtime_dependency 'beeps', '~> 0.1.24'
34
+ s.add_runtime_dependency 'rays', '~> 0.1.24'
35
35
 
36
36
  s.files = `git ls-files`.split $/
37
37
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}