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
30213814
Commit
30213814
authored
Oct 09, 2015
by
Kris Giesing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hold and sweep semantics to gesture arena
parent
42469d2c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
arena.dart
packages/flutter/lib/src/gestures/arena.dart
+27
-0
binding.dart
packages/flutter/lib/src/rendering/binding.dart
+2
-0
No files found.
packages/flutter/lib/src/gestures/arena.dart
View file @
30213814
...
...
@@ -45,6 +45,7 @@ class GestureArenaEntry {
class
_GestureArenaState
{
final
List
<
GestureArenaMember
>
members
=
new
List
<
GestureArenaMember
>();
bool
isOpen
=
true
;
bool
isHeld
=
false
;
void
add
(
GestureArenaMember
member
)
{
assert
(
isOpen
);
...
...
@@ -72,6 +73,32 @@ class GestureArena {
_tryToResolveArena
(
key
,
state
);
}
/// Force resolution on this arena, giving the win to the first member
void
sweep
(
Object
key
)
{
_GestureArenaState
state
=
_arenas
[
key
];
if
(
state
==
null
)
return
;
// This arena either never existed or has been resolved.
assert
(!
state
.
isOpen
);
if
(
state
.
isHeld
)
return
;
// This arena is being held for a long-lived member
if
(!
state
.
members
.
isEmpty
)
{
// First member wins
state
.
members
.
first
.
acceptGesture
(
key
);
// Give all the other members the bad news
for
(
int
i
=
1
;
i
<
state
.
members
.
length
;
i
++)
state
.
members
[
i
].
rejectGesture
(
key
);
}
_arenas
.
remove
(
key
);
}
/// Prevent the arena from being swept
void
hold
(
Object
key
)
{
_GestureArenaState
state
=
_arenas
[
key
];
if
(
state
==
null
)
return
;
// This arena either never existed or has been resolved.
state
.
isHeld
=
true
;
}
void
_tryToResolveArena
(
Object
key
,
_GestureArenaState
state
)
{
assert
(
_arenas
[
key
]
==
state
);
assert
(!
state
.
isOpen
);
...
...
packages/flutter/lib/src/rendering/binding.dart
View file @
30213814
...
...
@@ -167,6 +167,8 @@ class FlutterBinding extends HitTestTarget {
pointerRouter
.
route
(
event
);
if
(
event
.
type
==
'pointerdown'
)
GestureArena
.
instance
.
close
(
event
.
pointer
);
else
if
(
event
.
type
==
'pointerup'
)
GestureArena
.
instance
.
sweep
(
event
.
pointer
);
}
}
}
...
...
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