Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7eb387b1
Commit
7eb387b1
authored
Dec 05, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #760 from Hixie/move-pointer-fixes
Cleanup for the Pointer changes.
parents
e0107b05
2965dcb6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
65 deletions
+60
-65
drag.dart
packages/flutter/lib/src/gestures/drag.dart
+1
-2
events.dart
packages/flutter/lib/src/gestures/events.dart
+14
-14
node.dart
packages/flutter_sprites/lib/src/node.dart
+2
-2
sprite_box.dart
packages/flutter_sprites/lib/src/sprite_box.dart
+40
-44
virtual_joystick.dart
packages/flutter_sprites/lib/src/virtual_joystick.dart
+3
-3
No files found.
packages/flutter/lib/src/gestures/drag.dart
View file @
7eb387b1
...
...
@@ -25,8 +25,7 @@ typedef void GesturePanEndCallback(Offset velocity);
typedef
void
_GesturePolymorphicUpdateCallback
<
T
>(
T
delta
);
bool
_isFlingGesture
(
Offset
velocity
)
{
if
(
velocity
==
null
)
return
false
;
assert
(
velocity
!=
null
);
double
velocitySquared
=
velocity
.
dx
*
velocity
.
dx
+
velocity
.
dy
*
velocity
.
dy
;
return
velocitySquared
>
kMinFlingVelocity
*
kMinFlingVelocity
&&
velocitySquared
<
kMaxFlingVelocity
*
kMaxFlingVelocity
;
...
...
packages/flutter/lib/src/gestures/events.dart
View file @
7eb387b1
...
...
@@ -193,8 +193,8 @@ class PointerAddedEvent extends PointerEvent {
PointerDeviceKind
kind:
PointerDeviceKind
.
touch
,
Point
position:
Point
.
origin
,
bool
obscured:
false
,
double
pressureMin:
0
.0
,
double
pressureMax:
0
.0
,
double
pressureMin:
1
.0
,
double
pressureMax:
1
.0
,
double
distance:
0.0
,
double
distanceMax:
0.0
,
double
radiusMin:
0.0
,
...
...
@@ -224,8 +224,8 @@ class PointerRemovedEvent extends PointerEvent {
int
pointer:
0
,
PointerDeviceKind
kind:
PointerDeviceKind
.
touch
,
bool
obscured:
false
,
double
pressureMin:
0
.0
,
double
pressureMax:
0
.0
,
double
pressureMin:
1
.0
,
double
pressureMax:
1
.0
,
double
distanceMax:
0.0
,
double
radiusMin:
0.0
,
double
radiusMax:
0.0
...
...
@@ -251,9 +251,9 @@ class PointerDownEvent extends PointerEvent {
Point
position:
Point
.
origin
,
int
buttons:
0
,
bool
obscured:
false
,
double
pressure:
0
.0
,
double
pressureMin:
0
.0
,
double
pressureMax:
0
.0
,
double
pressure:
1
.0
,
double
pressureMin:
1
.0
,
double
pressureMax:
1
.0
,
double
distanceMax:
0.0
,
double
radiusMajor:
0.0
,
double
radiusMinor:
0.0
,
...
...
@@ -293,9 +293,9 @@ class PointerMoveEvent extends PointerEvent {
int
buttons:
0
,
bool
down:
false
,
bool
obscured:
false
,
double
pressure:
0
.0
,
double
pressureMin:
0
.0
,
double
pressureMax:
0
.0
,
double
pressure:
1
.0
,
double
pressureMin:
1
.0
,
double
pressureMax:
1
.0
,
double
distance:
0.0
,
double
distanceMax:
0.0
,
double
radiusMajor:
0.0
,
...
...
@@ -335,8 +335,8 @@ class PointerUpEvent extends PointerEvent {
Point
position:
Point
.
origin
,
int
buttons:
0
,
bool
obscured:
false
,
double
pressureMin:
0
.0
,
double
pressureMax:
0
.0
,
double
pressureMin:
1
.0
,
double
pressureMax:
1
.0
,
double
distance:
0.0
,
double
distanceMax:
0.0
,
double
radiusMin:
0.0
,
...
...
@@ -369,8 +369,8 @@ class PointerCancelEvent extends PointerEvent {
Point
position:
Point
.
origin
,
int
buttons:
0
,
bool
obscured:
false
,
double
pressureMin:
0
.0
,
double
pressureMax:
0
.0
,
double
pressureMin:
1
.0
,
double
pressureMax:
1
.0
,
double
distance:
0.0
,
double
distanceMax:
0.0
,
double
radiusMin:
0.0
,
...
...
packages/flutter_sprites/lib/src/node.dart
View file @
7eb387b1
...
...
@@ -769,10 +769,10 @@ class Node {
/// }
///
/// bool handleEvent(SpriteBoxEvent event) {
/// if (event.type ==
'pointerdown
) {
/// if (event.type ==
PointerDownEvent
) {
/// opacity = 0.5;
/// }
/// else if (event.type ==
'pointerup'
) {
/// else if (event.type ==
PointerUpEvent
) {
/// opacity = 1.0;
/// }
/// return true;
...
...
packages/flutter_sprites/lib/src/sprite_box.dart
View file @
7eb387b1
...
...
@@ -187,57 +187,53 @@ class SpriteBox extends RenderBox {
}
}
void
handleEvent
(
Input
Event
event
,
_SpriteBoxHitTestEntry
entry
)
{
void
handleEvent
(
Pointer
Event
event
,
_SpriteBoxHitTestEntry
entry
)
{
if
(!
attached
)
return
;
if
(
event
is
PointerInputEvent
)
{
if
(
event
.
type
==
'pointerdown'
)
{
// Build list of event targets
if
(
_eventTargets
==
null
)
{
_eventTargets
=
<
Node
>[];
_addEventTargets
(
_rootNode
,
_eventTargets
);
}
if
(
event
is
PointerDownEvent
)
{
// Build list of event targets
if
(
_eventTargets
==
null
)
{
_eventTargets
=
<
Node
>[];
_addEventTargets
(
_rootNode
,
_eventTargets
);
}
// Find the once that are hit by the pointer
List
<
Node
>
nodeTargets
=
<
Node
>[];
for
(
int
i
=
_eventTargets
.
length
-
1
;
i
>=
0
;
i
--)
{
Node
node
=
_eventTargets
[
i
];
// Check if the node is ready to handle a pointer
if
(
node
.
handleMultiplePointers
||
node
.
_handlingPointer
==
null
)
{
// Do the hit test
Point
posInNodeSpace
=
node
.
convertPointToNodeSpace
(
entry
.
localPosition
);
if
(
node
.
isPointInside
(
posInNodeSpace
))
{
nodeTargets
.
add
(
node
);
node
.
_handlingPointer
=
event
.
pointer
;
}
// Find the once that are hit by the pointer
List
<
Node
>
nodeTargets
=
<
Node
>[];
for
(
int
i
=
_eventTargets
.
length
-
1
;
i
>=
0
;
i
--)
{
Node
node
=
_eventTargets
[
i
];
// Check if the node is ready to handle a pointer
if
(
node
.
handleMultiplePointers
||
node
.
_handlingPointer
==
null
)
{
// Do the hit test
Point
posInNodeSpace
=
node
.
convertPointToNodeSpace
(
entry
.
localPosition
);
if
(
node
.
isPointInside
(
posInNodeSpace
))
{
nodeTargets
.
add
(
node
);
node
.
_handlingPointer
=
event
.
pointer
;
}
}
entry
.
nodeTargets
=
nodeTargets
;
}
// Pass the event down to nodes that were hit by the pointerdown
List
<
Node
>
targets
=
entry
.
nodeTargets
;
for
(
Node
node
in
targets
)
{
// Check if this event should be dispatched
if
(
node
.
handleMultiplePointers
||
event
.
pointer
==
node
.
_handlingPointer
)
{
// Dispatch event
bool
consumedEvent
=
node
.
handleEvent
(
new
SpriteBoxEvent
(
new
Point
(
event
.
x
,
event
.
y
),
event
.
type
,
event
.
pointer
));
if
(
consumedEvent
==
null
||
consumedEvent
)
break
;
}
}
entry
.
nodeTargets
=
nodeTargets
;
}
// De-register pointer for nodes that doesn't handle multiple pointers
for
(
Node
node
in
targets
)
{
if
(
event
.
type
==
'pointerup'
||
event
.
type
==
'pointercancel'
)
{
node
.
_handlingPointer
=
null
;
}
// Pass the event down to nodes that were hit by the pointerdown
List
<
Node
>
targets
=
entry
.
nodeTargets
;
for
(
Node
node
in
targets
)
{
// Check if this event should be dispatched
if
(
node
.
handleMultiplePointers
||
event
.
pointer
==
node
.
_handlingPointer
)
{
// Dispatch event
bool
consumedEvent
=
node
.
handleEvent
(
new
SpriteBoxEvent
(
new
Point
(
event
.
x
,
event
.
y
),
event
.
runtimeType
,
event
.
pointer
));
if
(
consumedEvent
==
null
||
consumedEvent
)
break
;
}
}
// De-register pointer for nodes that doesn't handle multiple pointers
for
(
Node
node
in
targets
)
{
if
(
event
is
PointerUpEvent
||
event
is
PointerCancelEvent
)
node
.
_handlingPointer
=
null
;
}
}
bool
hitTest
(
HitTestResult
result
,
{
Point
position
})
{
...
...
@@ -531,13 +527,13 @@ class SpriteBoxEvent {
/// }
final
Point
boxPosition
;
/// The type of event, there are currently four valid types,
'pointerdown', 'pointermoved', 'pointerup'
, and
///
'pointercancel'
.
/// The type of event, there are currently four valid types,
PointerDownEvent, PointerMoveEvent, PointerUpEvent
, and
///
PointerCancelEvent
.
///
/// if (event.type ==
'pointerdown'
) {
/// if (event.type ==
PointerDownEvent
) {
/// // Do something!
/// }
final
String
type
;
final
Type
type
;
/// The id of the pointer. Each pointer on the screen will have a unique pointer id.
///
...
...
packages/flutter_sprites/lib/src/virtual_joystick.dart
View file @
7eb387b1
...
...
@@ -31,18 +31,18 @@ class VirtualJoystick extends NodeWithSize {
Paint
_paintControl
;
bool
handleEvent
(
SpriteBoxEvent
event
)
{
if
(
event
.
type
==
"pointerdown"
)
{
if
(
event
.
type
==
PointerDownEvent
)
{
_pointerDownAt
=
event
.
boxPosition
;
actions
.
stopAll
();
_isDown
=
true
;
}
else
if
(
event
.
type
==
"pointerup"
||
event
.
type
==
"pointercancel"
)
{
else
if
(
event
.
type
==
PointerUpEvent
||
event
.
type
==
PointerCancelEvent
)
{
_pointerDownAt
=
null
;
_value
=
Point
.
origin
;
ActionTween
moveToCenter
=
new
ActionTween
((
a
)
=>
_handlePos
=
a
,
_handlePos
,
_center
,
0.4
,
Curves
.
elasticOut
);
actions
.
run
(
moveToCenter
);
_isDown
=
false
;
}
else
if
(
event
.
type
==
"pointermove"
)
{
}
else
if
(
event
.
type
==
PointerMoveEvent
)
{
Offset
movedDist
=
event
.
boxPosition
-
_pointerDownAt
;
_value
=
new
Point
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment