reflexion 0.1.38 → 0.1.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/capture_event.cpp +1 -1
  3. data/.doc/ext/reflex/event.cpp +7 -2
  4. data/.doc/ext/reflex/frame_event.cpp +25 -8
  5. data/.doc/ext/reflex/motion_event.cpp +4 -4
  6. data/.doc/ext/reflex/pointer.cpp +15 -6
  7. data/.doc/ext/reflex/pointer_event.cpp +0 -1
  8. data/.doc/ext/reflex/polygon_shape.cpp +1 -1
  9. data/.doc/ext/reflex/scroll_event.cpp +1 -1
  10. data/.doc/ext/reflex/style.cpp +2 -2
  11. data/.doc/ext/reflex/wheel_event.cpp +1 -1
  12. data/ChangeLog.md +14 -6
  13. data/VERSION +1 -1
  14. data/ext/reflex/capture_event.cpp +1 -1
  15. data/ext/reflex/defs.h +2 -2
  16. data/ext/reflex/event.cpp +7 -2
  17. data/ext/reflex/frame_event.cpp +26 -7
  18. data/ext/reflex/motion_event.cpp +4 -4
  19. data/ext/reflex/pointer.cpp +16 -6
  20. data/ext/reflex/pointer_event.cpp +0 -1
  21. data/ext/reflex/polygon_shape.cpp +1 -1
  22. data/ext/reflex/scroll_event.cpp +1 -1
  23. data/ext/reflex/selector.h +1 -1
  24. data/ext/reflex/style.cpp +2 -2
  25. data/ext/reflex/wheel_event.cpp +1 -1
  26. data/include/reflex/event.h +29 -13
  27. data/include/reflex/pointer.h +5 -3
  28. data/include/reflex/shape.h +1 -1
  29. data/lib/reflex/frame_event.rb +12 -2
  30. data/lib/reflex/pointer.rb +1 -1
  31. data/lib/reflex/pointer_event.rb +2 -2
  32. data/reflex.gemspec +4 -4
  33. data/src/body.h +1 -1
  34. data/src/event.cpp +83 -14
  35. data/src/event.h +11 -5
  36. data/src/fixture.h +1 -1
  37. data/src/ios/application.h +1 -1
  38. data/src/ios/event.mm +2 -1
  39. data/src/osx/application.h +1 -1
  40. data/src/osx/event.h +12 -6
  41. data/src/osx/event.mm +2 -1
  42. data/src/osx/native_window.mm +1 -1
  43. data/src/pointer.cpp +34 -18
  44. data/src/pointer.h +4 -2
  45. data/src/selector.h +1 -1
  46. data/src/shape.h +1 -1
  47. data/src/style.h +1 -1
  48. data/src/timer.h +1 -1
  49. data/src/view.cpp +149 -67
  50. data/src/view.h +1 -1
  51. data/src/win32/defs.h +1 -1
  52. data/src/window.cpp +25 -22
  53. data/src/window.h +15 -6
  54. data/src/world.h +1 -1
  55. data/test/test_event.rb +18 -15
  56. data/test/test_frame_event.rb +20 -16
  57. data/test/test_pointer.rb +20 -16
  58. data/test/test_pointer_event.rb +21 -21
  59. metadata +10 -10
data/src/window.cpp CHANGED
@@ -17,7 +17,15 @@ namespace Reflex
17
17
 
18
18
  using ExtractedPointerIDSet = std::set<Pointer::ID>;
19
19
 
20
- using CaptureTargetIDList = Window::Data::CaptureTargetIDList;
20
+ using PointerData = Window::Data::PointerData;
21
+
22
+ using TargetPointerMap = Window::Data::TargetPointerMap;
23
+
24
+
25
+ Window::Data::PointerData::PointerData (uint view_index)
26
+ : view_index(view_index)
27
+ {
28
+ }
21
29
 
22
30
 
23
31
  void
@@ -68,10 +76,9 @@ namespace Reflex
68
76
  }
69
77
 
70
78
  void
71
- Window_register_capture (Window* window, View* view, Pointer::ID target)
79
+ Window_register_capture (
80
+ Window* window, View* view, Pointer::ID target, uint view_index)
72
81
  {
73
- assert(window);
74
-
75
82
  if (!view)
76
83
  argument_error(__FILE__, __LINE__);
77
84
 
@@ -81,19 +88,15 @@ namespace Reflex
81
88
  if (target < 0) return;
82
89
 
83
90
  auto& targets = window->self->captures[view];
84
- if (std::find(targets.begin(), targets.end(), target) != targets.end())
91
+ if (targets.find(target) != targets.end())
85
92
  return;
86
93
 
87
- targets.insert(
88
- target == CAPTURE_ALL ? targets.begin() : targets.end(),
89
- target);
94
+ targets.insert(std::make_pair(target, PointerData(view_index)));
90
95
  }
91
96
 
92
97
  void
93
98
  Window_unregister_capture (Window* window, View* view, Pointer::ID target)
94
99
  {
95
- assert(window);
96
-
97
100
  if (!view)
98
101
  argument_error(__FILE__, __LINE__);
99
102
 
@@ -101,7 +104,7 @@ namespace Reflex
101
104
  if (captures_it == window->self->captures.end()) return;
102
105
 
103
106
  auto& targets = captures_it->second;
104
- auto targets_it = std::find(targets.begin(), targets.end(), target);
107
+ auto targets_it = targets.find(target);
105
108
  if (targets_it == targets.end()) return;
106
109
 
107
110
  targets.erase(targets_it);
@@ -149,11 +152,11 @@ namespace Reflex
149
152
 
150
153
  static bool
151
154
  is_capturing (
152
- const View* view, const CaptureTargetIDList& targets, View::Capture type)
155
+ const View* view, const TargetPointerMap& targets, View::Capture type)
153
156
  {
154
157
  return
155
158
  !targets.empty() &&
156
- targets[0] == CAPTURE_ALL &&
159
+ targets.find(CAPTURE_ALL) != targets.end() &&
157
160
  (view->capture() & type) == type;
158
161
  }
159
162
 
@@ -224,26 +227,28 @@ namespace Reflex
224
227
  static void
225
228
  extract_pointer (
226
229
  PointerEvent* event, ExtractedPointerIDSet* extracteds,
227
- const Pointer& pointer)
230
+ const Pointer& pointer, uint view_index = 0)
228
231
  {
229
- assert(event && extracteds);
232
+ PointerEvent_add_pointer(event, pointer, [&](auto* p)
233
+ {
234
+ Pointer_set_view_index(p, view_index);
235
+ });
230
236
 
231
- PointerEvent_add_pointer(event, pointer);
232
237
  extracteds->insert(pointer.id());
233
238
  }
234
239
 
235
240
  static void
236
241
  extract_targeted_pointers (
237
242
  PointerEvent* event, ExtractedPointerIDSet* extracteds,
238
- const CaptureTargetIDList& targets, const PointerMap& pointers)
243
+ const TargetPointerMap& targets, const PointerMap& pointers)
239
244
  {
240
- assert(event && event->empty() && extracteds);
245
+ assert(event->empty());
241
246
 
242
- for (auto pointer_id : targets)
247
+ for (auto& [pointer_id, data] : targets)
243
248
  {
244
249
  auto it = pointers.find(pointer_id);
245
250
  if (it != pointers.end())
246
- extract_pointer(event, extracteds, it->second);
251
+ extract_pointer(event, extracteds, it->second, data.view_index);
247
252
  }
248
253
  }
249
254
 
@@ -252,8 +257,6 @@ namespace Reflex
252
257
  ExtractedPointerIDSet* extracteds,
253
258
  Window* window, const PointerMap& pointers)
254
259
  {
255
- assert(extracteds && window);
256
-
257
260
  for (auto& [view, targets] : window->self->captures)
258
261
  {
259
262
  if (!view->window() || targets.empty()) continue;
data/src/window.h CHANGED
@@ -9,8 +9,8 @@
9
9
  #include <xot/time.h>
10
10
  #include <rays/point.h>
11
11
  #include <rays/painter.h>
12
- #include <reflex/window.h>
13
- #include <reflex/view.h>
12
+ #include "reflex/window.h"
13
+ #include "reflex/view.h"
14
14
  #include "pointer.h"
15
15
 
16
16
 
@@ -24,9 +24,18 @@ namespace Reflex
24
24
  struct Window::Data
25
25
  {
26
26
 
27
- typedef std::vector<Pointer::ID> CaptureTargetIDList;
27
+ struct PointerData
28
+ {
29
+
30
+ uint view_index;
31
+
32
+ PointerData (uint view_index);
33
+
34
+ };// PointerData
35
+
36
+ typedef std::map<Pointer::ID, PointerData> TargetPointerMap;
28
37
 
29
- typedef std::map<View::Ref, CaptureTargetIDList> CaptureMap;
38
+ typedef std::map<View::Ref, TargetPointerMap> CaptureMap;
30
39
 
31
40
  int hide_count = 1;
32
41
 
@@ -92,10 +101,10 @@ namespace Reflex
92
101
  void Window_set_focus (Window* window, View* view);
93
102
 
94
103
  void Window_register_capture (
95
- Window* window, View* view, Pointer::ID target = CAPTURE_ALL);
104
+ Window* window, View* view, Pointer::ID target, uint view_index = 0);
96
105
 
97
106
  void Window_unregister_capture (
98
- Window* window, View* view, Pointer::ID target = CAPTURE_ALL);
107
+ Window* window, View* view, Pointer::ID target);
99
108
 
100
109
  void Window_call_draw_event (Window* window, DrawEvent* event);
101
110
 
data/src/world.h CHANGED
@@ -10,7 +10,7 @@
10
10
  #include <xot/pimpl.h>
11
11
  #include <rays/point.h>
12
12
  #include <rays/painter.h>
13
- #include <reflex/defs.h>
13
+ #include "reflex/defs.h"
14
14
 
15
15
 
16
16
  class b2World;
data/test/test_event.rb CHANGED
@@ -18,24 +18,27 @@ class TestEvent < Test::Unit::TestCase
18
18
  end
19
19
 
20
20
  def test_block()
21
- e = event
22
- assert_false e.blocked?
23
- e.block
24
- assert_true e.blocked?
25
- end
21
+ events = -> {
22
+ e1 = event
23
+ e2 = e1.dup
24
+ e3 = e2.dup
25
+ return e1, e2, e3
26
+ }
26
27
 
27
- def _test_block_propagation()
28
- e1 = event
29
- e2 = e1.dup
30
- e3 = e2.dup
31
- assert_false e1.blocked?
32
- assert_false e2.blocked?
33
- assert_false e3.blocked?
28
+ e1, e2, e3 = events.call
29
+ assert_equal [false, false, false], [e1.blocked?, e2.blocked?, e3.blocked?]
34
30
 
31
+ e1, e2, e3 = events.call
35
32
  e2.block
36
- assert_true e1.blocked?
37
- assert_true e2.blocked?
38
- assert_false e3.blocked?
33
+ assert_equal [true, true, false], [e1.blocked?, e2.blocked?, e3.blocked?]
34
+
35
+ e1, e2, e3 = events.call
36
+ e2.block false
37
+ assert_equal [false, true, false], [e1.blocked?, e2.blocked?, e3.blocked?]
38
+
39
+ e1, e2, e3 = events.call
40
+ e2.block true
41
+ assert_equal [true, true, false], [e1.blocked?, e2.blocked?, e3.blocked?]
39
42
  end
40
43
 
41
44
  def test_time()
@@ -12,30 +12,34 @@ class TestFrameEvent < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_initialize()
15
- e = event bounds(1, 2, 3, 4, 5, 6), 7, 8, 9, 10, 11, 12, 13, 14
15
+ e = event bounds(1, 2, 3, 4, 5, 6), 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
16
16
  assert_equal bounds(1, 2, 3, 4, 5, 6), e.frame
17
17
  assert_equal 7, e.dx
18
18
  assert_equal 8, e.dy
19
- assert_equal 9, e.dw
20
- assert_equal 10, e.dh
21
- assert_equal 11, e.zoom
22
- assert_equal 12, e.dzoom
23
- assert_equal 13, e.angle
24
- assert_equal 14, e.dangle
19
+ assert_equal 9, e.dz
20
+ assert_equal 10, e.dw
21
+ assert_equal 11, e.dh
22
+ assert_equal 12, e.dd
23
+ assert_equal 13, e. zoom
24
+ assert_equal 14, e.dzoom
25
+ assert_equal 15, e. angle
26
+ assert_equal 16, e.dangle
25
27
  end
26
28
 
27
29
  def test_dup()
28
- e1 = event bounds(1, 2, 3, 4, 5, 6), 7, 8, 9, 10, 11, 12, 13, 14
30
+ e1 = event bounds(1, 2, 3, 4, 5, 6), 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
29
31
  e2 = e1.dup
30
32
  assert_equal bounds(1, 2, 3, 4, 5, 6), e2.frame
31
33
  assert_equal 7, e2.dx
32
34
  assert_equal 8, e2.dy
33
- assert_equal 9, e2.dw
34
- assert_equal 10, e2.dh
35
- assert_equal 11, e2.zoom
36
- assert_equal 12, e2.dzoom
37
- assert_equal 13, e2.angle
38
- assert_equal 14, e2.dangle
35
+ assert_equal 9, e2.dz
36
+ assert_equal 10, e2.dw
37
+ assert_equal 11, e2.dh
38
+ assert_equal 12, e2.dd
39
+ assert_equal 13, e2. zoom
40
+ assert_equal 14, e2.dzoom
41
+ assert_equal 15, e2. angle
42
+ assert_equal 16, e2.dangle
39
43
 
40
44
  e1.block
41
45
  e3 = e1.dup
@@ -46,8 +50,8 @@ class TestFrameEvent < Test::Unit::TestCase
46
50
 
47
51
  def test_inspect()
48
52
  assert_equal(
49
- "#<Reflex::FrameEvent x:1(7) y:2(8) w:4(9) h:5(10) zoom:11(12) angle:13(14)>",
50
- event(bounds(1, 2, 3, 4, 5, 6), 7, 8, 9, 10, 11, 12, 13, 14).inspect)
53
+ "#<Reflex::FrameEvent x:1(7) y:2(8) z:3(9) w:4(10) h:5(11) d:6(12) zoom:13(14) angle:15(16)>",
54
+ event(bounds(1, 2, 3, 4, 5, 6), 7, 8, 9, 10, 11, 12, 13, 14, 15, 16).inspect)
51
55
  end
52
56
 
53
57
  end# TestFrameEvent
data/test/test_pointer.rb CHANGED
@@ -23,11 +23,11 @@ class TestPointer < Test::Unit::TestCase
23
23
 
24
24
  def pointer(
25
25
  id: 0, type: TYPE_NONE, action: ACTION_NONE,
26
- position: 0, modifiers: 0, click_count: 0, drag: false,
26
+ position: 0, modifiers: 0, drag: false, click_count: 0, view_index: 0,
27
27
  time: 0)
28
28
 
29
29
  Reflex::Pointer.new(
30
- id, type, action, position, modifiers, click_count, drag, time)
30
+ id, type, action, position, modifiers, drag, click_count, view_index, time)
31
31
  end
32
32
 
33
33
  def test_initialize()
@@ -35,18 +35,21 @@ class TestPointer < Test::Unit::TestCase
35
35
 
36
36
  p = pointer(
37
37
  id: 1, type: TOUCH, action: DOWN,
38
- position: [2, 3], modifiers: 4, click_count: 5, drag: true,
39
- time: 6)
40
-
41
- assert_equal 1, p.id
42
- assert_equal [:touch], p.types
43
- assert_equal :down, p.action
44
- assert_equal [2, 3], p.position.to_a
45
- assert_equal 4, p.modifiers
46
- assert_equal 5, p.click_count
47
- assert_equal true, p.drag?
48
- assert_equal 6, p.time
49
- assert_nil p.prev
38
+ position: [2, 3], modifiers: 4, drag: true, click_count: 5, view_index: 6,
39
+ time: 7)
40
+
41
+ assert_equal 1, p.id
42
+ assert_equal [:touch], p.types
43
+ assert_equal :down, p.action
44
+ assert_equal [2, 3], p.position.to_a
45
+ assert_equal 2, p.x
46
+ assert_equal 3, p.y
47
+ assert_equal 4, p.modifiers
48
+ assert_equal true, p.drag?
49
+ assert_equal 5, p.click_count
50
+ assert_equal 6, p.view_index
51
+ assert_equal 7, p.time
52
+ assert_nil p.prev
50
53
  end
51
54
 
52
55
  def test_types()
@@ -138,9 +141,10 @@ class TestPointer < Test::Unit::TestCase
138
141
  assert_not_equal pointer, pointer(action: Reflex::Pointer::UP)
139
142
  assert_not_equal pointer, pointer(position: 2)
140
143
  assert_not_equal pointer, pointer(modifiers: 3)
141
- assert_not_equal pointer, pointer(click_count: 4)
142
144
  assert_not_equal pointer, pointer(drag: true)
143
- assert_not_equal pointer, pointer(time: 5)
145
+ assert_not_equal pointer, pointer(click_count: 4)
146
+ assert_not_equal pointer, pointer(view_index: 5)
147
+ assert_not_equal pointer, pointer(time: 6)
144
148
  end
145
149
 
146
150
  end# TestPointer
@@ -11,17 +11,17 @@ class TestPointerEvent < Test::Unit::TestCase
11
11
  DOWN = Reflex::Pointer::DOWN
12
12
  UP = Reflex::Pointer::UP
13
13
 
14
- def event(*args)
15
- Reflex::PointerEvent.new(*args)
14
+ def event(*args, **kwargs)
15
+ Reflex::PointerEvent.new(*args, **kwargs)
16
16
  end
17
17
 
18
18
  def pointer(
19
19
  id: 0, type: TYPE_NONE, action: ACTION_NONE,
20
- position: 0, modifiers: 0, click_count: 0, drag: false,
20
+ position: 0, modifiers: 0, drag: false, click_count: 0, view_index: 0,
21
21
  time: 0)
22
22
 
23
23
  Reflex::Pointer.new(
24
- id, type, action, position, modifiers, click_count, drag, time)
24
+ id, type, action, position, modifiers, drag, click_count, view_index, time)
25
25
  end
26
26
 
27
27
  def test_initialize()
@@ -31,30 +31,30 @@ class TestPointerEvent < Test::Unit::TestCase
31
31
 
32
32
  p1 = pointer(
33
33
  id: 1, type: TOUCH, action: DOWN,
34
- position: [2, 3], modifiers: 4, click_count: 5, drag: true,
35
- time: 6)
34
+ position: [2, 3], modifiers: 4, drag: true, click_count: 5, view_index: 6,
35
+ time: 7)
36
36
  p2 = pointer(
37
37
  id: 10, type: PEN, action: UP,
38
- position: [20, 30], modifiers: 40, click_count: 50, drag: false,
39
- time: 60)
38
+ position: [20, 30], modifiers: 40, drag: false, click_count: 50, view_index: 60,
39
+ time: 70)
40
40
  e = event p1, p2
41
41
 
42
42
  assert_equal [p1, p2], e.pointers.to_a
43
43
  assert_equal 2, e.size
44
44
  assert_equal false, e.empty?
45
45
  assert_equal false, e.captured?
46
-
47
- assert_equal 1, p1.id
48
- assert_equal [:touch], p1.types
49
- assert_equal :down, p1.action
50
- assert_equal [2, 3], p1.position.to_a
51
- assert_equal [2, 3], p1.pos .to_a
52
- assert_equal 2, p1.x
53
- assert_equal 3, p1.y
54
- assert_equal 4, p1.modifiers
55
- assert_equal 5, p1.click_count
56
- assert_equal true, p1.drag?
57
- assert_equal 6, p1.time
46
+ assert_equal 1, e.id
47
+ assert_equal [:touch], e.types
48
+ assert_equal :down, e.action
49
+ assert_equal [2, 3], e.position.to_a
50
+ assert_equal [2, 3], e.pos .to_a
51
+ assert_equal 2, e.x
52
+ assert_equal 3, e.y
53
+ assert_equal 4, e.modifiers
54
+ assert_equal true, e.drag?
55
+ assert_equal 5, e.click_count
56
+ assert_equal 6, e.view_index
57
+ assert_equal 7, e.time
58
58
  end
59
59
 
60
60
  def test_dup()
@@ -68,7 +68,7 @@ class TestPointerEvent < Test::Unit::TestCase
68
68
  end
69
69
 
70
70
  def test_size()
71
- assert_equal 1, event(pointer ).size
71
+ assert_equal 1, event(pointer) .size
72
72
  assert_equal 2, event(pointer, pointer).size
73
73
  end
74
74
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reflexion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.38
4
+ version: 0.1.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-12 00:00:00.000000000 Z
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.35
19
+ version: 0.1.36
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.35
26
+ version: 0.1.36
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rucy
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.35
33
+ version: 0.1.36
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.35
40
+ version: 0.1.36
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: beeps
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.36
47
+ version: 0.1.37
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.36
54
+ version: 0.1.37
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rays
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.36
61
+ version: 0.1.37
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.36
68
+ version: 0.1.37
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement