processing 0.5.17 → 0.5.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d69cca41be46b8a061bcafc55fd36cf71d50616b5b5697ab558dfac1c9c2449c
4
- data.tar.gz: 4b3869b1fb410a2da488c03dd58e95fa1f0c42521888869bd70c0c18904831dc
3
+ metadata.gz: 38d42dd83841388f9b8370f48c36eabcaae5dce9f9ae584449d8825e2590f7d8
4
+ data.tar.gz: 46b6326966f81f0a9c40973462dbc58ce6c3806824f8dffed255233301f2797f
5
5
  SHA512:
6
- metadata.gz: 0db54f243695541c85db93d6f28bf3bc42dc76d68e40e3d63cc4e3524110f33372987be661a9fe1e58698d7c3eae40c32b6a76f7660102efbd952591f041db33
7
- data.tar.gz: e0719f14ed2fddc28d2dc908339fb633a3dcf645f20a98a52a333541078154aab4c5bcdb1dd36032b1dabbed8f229915ee8b36549085a785446b6aae38e6debc
6
+ metadata.gz: 60eb487e89d54e1961c7dcf522b14693083d6b84883aa482d310b87ad05a462ffbf837860b9bbcfc7f045fcdf446fbf32ee92b5ea1e565a87595ce281fa8076e
7
+ data.tar.gz: b898bb281b641d2f7ac64523c5d8a0ca7d8ee8e86f0e4f2a3af47d0f51cb5d739cdd9fe28f26bb864177b56a51425c732a0b526592c45d95d340cd233e5f53a7
data/ChangeLog.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # processing ChangeLog
2
2
 
3
3
 
4
+ ## [v0.5.18] - 2023-06-11
5
+
6
+ - mousePressed, mouseReleased, mouseMoved, mouseDragged, mouseClicked ignore multiple touches
7
+ - Fix that pointer event handles only the first pointer’s type and ignoring rest pointer's types
8
+
9
+
4
10
  ## [v0.5.17] - 2023-06-07
5
11
 
6
12
  - Add Image#set() and Image#get()
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.17
1
+ 0.5.18
@@ -42,8 +42,8 @@ module Processing
42
42
  @key__ = nil
43
43
  @keyCode__ = nil
44
44
  @keysPressed__ = Set.new
45
- @pointerPos__ =
46
- @pointerPrevPos__ = Rays::Point.new 0
45
+ @pointer__ = nil
46
+ @pointerPrev__ = nil
47
47
  @pointersPressed__ = []
48
48
  @pointersReleased__ = []
49
49
  @touches__ = []
@@ -92,19 +92,24 @@ module Processing
92
92
  mouse_middle: CENTER
93
93
  }
94
94
 
95
- updatePointerStates = -> event, pressed = nil {
96
- @pointerPrevPos__ = @pointerPos__
97
- @pointerPos__ = event.pos.dup
98
- @touches__ = event.pointers.map {|p| Touch.new(p.id, *p.pos.to_a)}
99
- if pressed != nil
100
- event.types
101
- .tap {|types| types.delete :mouse}
102
- .map {|type| mouseButtonMap[type] || type}
103
- .each do |type|
104
- (pressed ? @pointersPressed__ : @pointersReleased__).push type
105
- @pointersPressed__.delete type unless pressed
106
- end
95
+ updatePointerStates = -> event {
96
+ pointer = event.find {|p| p.id == @pointer__&.id} || event.first
97
+ if !mousePressed || pointer.id == @pointer__&.id
98
+ @pointerPrev__, @pointer__ = @pointer__, pointer.dup
107
99
  end
100
+ @touches__ = event.map {|p| Touch.new(p.id, *p.pos.to_a)}
101
+ }
102
+
103
+ updatePointersPressedAndReleased = -> event, pressed {
104
+ event.map(&:types).flatten
105
+ .tap {|types| types.delete :mouse}
106
+ .map {|type| mouseButtonMap[type] || type}
107
+ .each do |type|
108
+ (pressed ? @pointersPressed__ : @pointersReleased__).push type
109
+ if !pressed && index = @pointersPressed__.index(type)
110
+ @pointersPressed__.delete_at index
111
+ end
112
+ end
108
113
  }
109
114
 
110
115
  @window__.key_down = proc do |e|
@@ -119,29 +124,29 @@ module Processing
119
124
  end
120
125
 
121
126
  @window__.pointer_down = proc do |e|
122
- updatePointerStates.call e, true
123
- @pointerDownStartPos__ = @pointerPos__.dup
124
- (@touchStartedBlock__ || @mousePressedBlock__)&.call
127
+ updatePointerStates.call e
128
+ updatePointersPressedAndReleased.call e, true
129
+ @mousePressedBlock__&.call if e.any? {|p| p.id == @pointer__.id}
130
+ @touchStartedBlock__&.call
125
131
  end
126
132
 
127
133
  @window__.pointer_up = proc do |e|
128
- updatePointerStates.call e, false
129
- (@touchEndedBlock__ || @mouseReleasedBlock__)&.call
130
- if startPos = @pointerDownStartPos__
131
- @mouseClickedBlock__&.call if (@pointerPos__ - startPos).length < 3
132
- @pointerDownStartPos__ = nil
134
+ updatePointerStates.call e
135
+ updatePointersPressedAndReleased.call e, false
136
+ if e.any? {|p| p.id == @pointer__.id}
137
+ @mouseReleasedBlock__&.call
138
+ @mouseClickedBlock__&.call if
139
+ (@pointer__.pos - @pointer__.down.pos).length < 3
133
140
  end
141
+ @touchEndedBlock__&.call
134
142
  @pointersReleased__.clear
135
143
  end
136
144
 
137
145
  @window__.pointer_move = proc do |e|
138
146
  updatePointerStates.call e
139
- (@touchMovedBlock__ || @mouseMovedBlock__)&.call
140
- end
141
-
142
- @window__.pointer_drag = proc do |e|
143
- updatePointerStates.call e
144
- (@touchMovedBlock__ || @mouseDraggedBlock__)&.call
147
+ mouseMoved = e.drag? ? @mouseDraggedBlock__ : @mouseMovedBlock__
148
+ mouseMoved&.call if e.any? {|p| p.id == @pointer__.id}
149
+ @touchMovedBlock__&.call
145
150
  end
146
151
 
147
152
  @window__.move = proc do |e|
@@ -513,7 +518,7 @@ module Processing
513
518
  # @return [Numeric] horizontal position of mouse
514
519
  #
515
520
  def mouseX()
516
- @pointerPos__.x
521
+ @pointer__&.x || 0
517
522
  end
518
523
 
519
524
  # Returns mouse y position
@@ -521,7 +526,7 @@ module Processing
521
526
  # @return [Numeric] vertical position of mouse
522
527
  #
523
528
  def mouseY()
524
- @pointerPos__.y
529
+ @pointer__&.y || 0
525
530
  end
526
531
 
527
532
  # Returns mouse x position in previous frame
@@ -529,7 +534,7 @@ module Processing
529
534
  # @return [Numeric] horizontal position of mouse
530
535
  #
531
536
  def pmouseX()
532
- @pointerPrevPos__.x
537
+ @pointerPrev__&.x || 0
533
538
  end
534
539
 
535
540
  # Returns mouse y position in previous frame
@@ -537,7 +542,7 @@ module Processing
537
542
  # @return [Numeric] vertical position of mouse
538
543
  #
539
544
  def pmouseY()
540
- @pointerPrevPos__.y
545
+ @pointerPrev__&.y || 0
541
546
  end
542
547
 
543
548
  # Returns which mouse button was pressed
@@ -8,7 +8,7 @@ module Processing
8
8
 
9
9
  attr_accessor :setup, :update, :draw,
10
10
  :key_down, :key_up,
11
- :pointer_down, :pointer_up, :pointer_move, :pointer_drag,
11
+ :pointer_down, :pointer_up, :pointer_move,
12
12
  :move, :resize, :motion,
13
13
  :before_draw, :after_draw, :update_canvas
14
14
 
@@ -117,7 +117,7 @@ module Processing
117
117
  block = case e.action
118
118
  when :down then @pointer_down
119
119
  when :up, :cancel then @pointer_up
120
- when :move then e.drag? ? @pointer_drag : @pointer_move
120
+ when :move then @pointer_move
121
121
  end
122
122
  draw_canvas {call_block block, e} if block
123
123
  end
data/processing.gemspec CHANGED
@@ -25,10 +25,10 @@ Gem::Specification.new do |s|
25
25
  s.platform = Gem::Platform::RUBY
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
- s.add_runtime_dependency 'xot', '~> 0.1.38'
29
- s.add_runtime_dependency 'rucy', '~> 0.1.38'
30
- s.add_runtime_dependency 'rays', '~> 0.1.40'
31
- s.add_runtime_dependency 'reflexion', '~> 0.1.43'
28
+ s.add_runtime_dependency 'xot', '~> 0.1.39'
29
+ s.add_runtime_dependency 'rucy', '~> 0.1.39'
30
+ s.add_runtime_dependency 'rays', '~> 0.1.42'
31
+ s.add_runtime_dependency 'reflexion', '~> 0.1.45'
32
32
 
33
33
  s.add_development_dependency 'rake'
34
34
  s.add_development_dependency 'test-unit'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.17
4
+ version: 0.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-07 00:00:00.000000000 Z
11
+ date: 2023-06-11 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.38
19
+ version: 0.1.39
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.38
26
+ version: 0.1.39
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.38
33
+ version: 0.1.39
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.38
40
+ version: 0.1.39
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rays
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.40
47
+ version: 0.1.42
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.40
54
+ version: 0.1.42
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: reflexion
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.43
61
+ version: 0.1.45
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.43
68
+ version: 0.1.45
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement