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
2994e47c
Commit
2994e47c
authored
Aug 27, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #899 from abarth/pointer_router
Add PointerRouter
parents
e30b436d
45f2c589
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
0 deletions
+49
-0
pointer_router.dart
packages/flutter/lib/base/pointer_router.dart
+40
-0
sky_binding.dart
packages/flutter/lib/rendering/sky_binding.dart
+4
-0
drag_target.dart
packages/flutter/lib/widgets/drag_target.dart
+3
-0
framework.dart
packages/flutter/lib/widgets/framework.dart
+2
-0
No files found.
packages/flutter/lib/base/pointer_router.dart
0 → 100644
View file @
2994e47c
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:sky'
as
sky
;
import
'package:sky/base/hit_test.dart'
;
typedef
void
_Route
(
sky
.
PointerEvent
event
);
class
PointerRouter
extends
HitTestTarget
{
final
Map
<
int
,
List
<
_Route
>>
_routeMap
=
new
Map
<
int
,
List
<
_Route
>>();
void
addRoute
(
int
pointer
,
_Route
route
)
{
List
<
_Route
>
routes
=
_routeMap
.
putIfAbsent
(
pointer
,
()
=>
new
List
<
_Route
>());
assert
(!
routes
.
contains
(
route
));
routes
.
add
(
route
);
}
void
removeRoute
(
int
pointer
,
_Route
route
)
{
assert
(
_routeMap
.
containsKey
(
pointer
));
List
<
_Route
>
routes
=
_routeMap
[
pointer
];
assert
(
routes
.
contains
(
route
));
routes
.
remove
(
route
);
if
(
routes
.
isEmpty
)
_routeMap
.
remove
(
pointer
);
}
EventDisposition
handleEvent
(
sky
.
Event
e
,
HitTestEntry
entry
)
{
if
(
e
is
!
sky
.
PointerEvent
)
return
EventDisposition
.
ignored
;
sky
.
PointerEvent
event
=
e
;
List
<
_Route
>
routes
=
_routeMap
[
event
.
pointer
];
if
(
routes
==
null
)
return
EventDisposition
.
ignored
;
for
(
_Route
route
in
new
List
<
_Route
>.
from
(
routes
))
route
(
event
);
return
EventDisposition
.
processed
;
}
}
packages/flutter/lib/rendering/sky_binding.dart
View file @
2994e47c
...
...
@@ -4,6 +4,7 @@
import
'dart:sky'
as
sky
;
import
'package:sky/base/pointer_router.dart'
;
import
'package:sky/base/hit_test.dart'
;
import
'package:sky/base/scheduler.dart'
as
scheduler
;
import
'package:sky/rendering/box.dart'
;
...
...
@@ -92,6 +93,8 @@ class SkyBinding {
}
}
final
PointerRouter
pointerRouter
=
new
PointerRouter
();
Map
<
int
,
PointerState
>
_stateForPointer
=
new
Map
<
int
,
PointerState
>();
PointerState
_createStateForPointer
(
sky
.
PointerEvent
event
,
Point
position
)
{
...
...
@@ -127,6 +130,7 @@ class SkyBinding {
HitTestResult
hitTest
(
Point
position
)
{
HitTestResult
result
=
new
HitTestResult
();
result
.
add
(
new
HitTestEntry
(
pointerRouter
));
_renderView
.
hitTest
(
result
,
position:
position
);
return
result
;
}
...
...
packages/flutter/lib/widgets/drag_target.dart
View file @
2994e47c
...
...
@@ -5,6 +5,7 @@
import
'dart:collection'
;
import
'package:sky/base/hit_test.dart'
;
import
'package:sky/rendering/object.dart'
;
import
'package:sky/rendering/sky_binding.dart'
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/framework.dart'
;
...
...
@@ -80,6 +81,8 @@ class DragController {
DragTarget
_getDragTarget
(
List
<
HitTestEntry
>
path
)
{
for
(
HitTestEntry
entry
in
path
.
reversed
)
{
if
(
entry
.
target
is
!
RenderObject
)
continue
;
for
(
Widget
widget
in
RenderObjectWrapper
.
getWidgetsForRenderObject
(
entry
.
target
))
{
if
(
widget
is
DragTarget
)
return
widget
;
...
...
packages/flutter/lib/widgets/framework.dart
View file @
2994e47c
...
...
@@ -1282,6 +1282,8 @@ class WidgetSkyBinding extends SkyBinding {
if
(
disposition
==
EventDisposition
.
consumed
)
return
EventDisposition
.
consumed
;
for
(
HitTestEntry
entry
in
result
.
path
.
reversed
)
{
if
(
entry
.
target
is
!
RenderObject
)
continue
;
for
(
Widget
target
in
RenderObjectWrapper
.
getWidgetsForRenderObject
(
entry
.
target
))
{
if
(
target
is
Listener
)
{
EventDisposition
targetDisposition
=
target
.
_handleEvent
(
event
);
...
...
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