Commit 0df3730d authored by Hixie's avatar Hixie

Just-in-time mutations of GestureDetector

This allows us to adjust exactly which gestures we're listening for
during layout, which I'll use to kill a SizeObserver.
parent d1154c25
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.flutter.MaterialGallery" android:versionCode="1" android:versionName="0.0.1"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.flutter.MaterialGallery" android:versionCode="1" android:versionName="0.0.1">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" /> <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET"/>
<application android:icon="@mipmap/ic_launcher" android:label="Flutter Material" android:name="org.domokit.sky.shell.SkyApplication"> <application android:icon="@mipmap/ic_launcher" android:label="Flutter Material" android:name="org.domokit.sky.shell.SkyApplication">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize" android:hardwareAccelerated="true" android:launchMode="singleTask" android:name="org.domokit.sky.shell.SkyActivity" android:theme="@android:style/Theme.Black.NoTitleBar"> <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize" android:hardwareAccelerated="true" android:launchMode="singleTask" android:name="org.domokit.sky.shell.SkyActivity" android:theme="@android:style/Theme.Black.NoTitleBar">
......
...@@ -143,6 +143,8 @@ class VerticalDragGestureRecognizer extends _DragGestureRecognizer<double> { ...@@ -143,6 +143,8 @@ class VerticalDragGestureRecognizer extends _DragGestureRecognizer<double> {
double get _initialPendingDragDelta => 0.0; double get _initialPendingDragDelta => 0.0;
double _getDragDelta(PointerEvent event) => event.delta.dy; double _getDragDelta(PointerEvent event) => event.delta.dy;
bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragDelta.abs() > kTouchSlop; bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragDelta.abs() > kTouchSlop;
String toStringShort() => 'vertical drag';
} }
class HorizontalDragGestureRecognizer extends _DragGestureRecognizer<double> { class HorizontalDragGestureRecognizer extends _DragGestureRecognizer<double> {
...@@ -163,6 +165,8 @@ class HorizontalDragGestureRecognizer extends _DragGestureRecognizer<double> { ...@@ -163,6 +165,8 @@ class HorizontalDragGestureRecognizer extends _DragGestureRecognizer<double> {
double get _initialPendingDragDelta => 0.0; double get _initialPendingDragDelta => 0.0;
double _getDragDelta(PointerEvent event) => event.delta.dx; double _getDragDelta(PointerEvent event) => event.delta.dx;
bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragDelta.abs() > kTouchSlop; bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragDelta.abs() > kTouchSlop;
String toStringShort() => 'horizontal drag';
} }
class PanGestureRecognizer extends _DragGestureRecognizer<Offset> { class PanGestureRecognizer extends _DragGestureRecognizer<Offset> {
...@@ -185,4 +189,6 @@ class PanGestureRecognizer extends _DragGestureRecognizer<Offset> { ...@@ -185,4 +189,6 @@ class PanGestureRecognizer extends _DragGestureRecognizer<Offset> {
bool get _hasSufficientPendingDragDeltaToAccept { bool get _hasSufficientPendingDragDeltaToAccept {
return _pendingDragDelta.distance > kPanSlop; return _pendingDragDelta.distance > kPanSlop;
} }
String toStringShort() => 'pan';
} }
...@@ -34,4 +34,6 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer { ...@@ -34,4 +34,6 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
if (event is PointerUpEvent) if (event is PointerUpEvent)
resolve(GestureDisposition.rejected); resolve(GestureDisposition.rejected);
} }
String toStringShort() => 'long press';
} }
...@@ -250,6 +250,8 @@ class ImmediateMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Im ...@@ -250,6 +250,8 @@ class ImmediateMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Im
_ImmediatePointerState createNewPointerState(PointerDownEvent event) { _ImmediatePointerState createNewPointerState(PointerDownEvent event) {
return new _ImmediatePointerState(event.position); return new _ImmediatePointerState(event.position);
} }
String toStringShort() => 'multidrag';
} }
...@@ -277,6 +279,8 @@ class HorizontalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_H ...@@ -277,6 +279,8 @@ class HorizontalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_H
_HorizontalPointerState createNewPointerState(PointerDownEvent event) { _HorizontalPointerState createNewPointerState(PointerDownEvent event) {
return new _HorizontalPointerState(event.position); return new _HorizontalPointerState(event.position);
} }
String toStringShort() => 'horizontal multidrag';
} }
...@@ -304,6 +308,8 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Ver ...@@ -304,6 +308,8 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Ver
_VerticalPointerState createNewPointerState(PointerDownEvent event) { _VerticalPointerState createNewPointerState(PointerDownEvent event) {
return new _VerticalPointerState(event.position); return new _VerticalPointerState(event.position);
} }
String toStringShort() => 'vertical multidrag';
} }
...@@ -373,4 +379,6 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Dela ...@@ -373,4 +379,6 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Dela
_DelayedPointerState createNewPointerState(PointerDownEvent event) { _DelayedPointerState createNewPointerState(PointerDownEvent event) {
return new _DelayedPointerState(event.position, _delay); return new _DelayedPointerState(event.position, _delay);
} }
String toStringShort() => 'long multidrag';
} }
...@@ -212,6 +212,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { ...@@ -212,6 +212,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
} }
} }
String toStringShort() => 'double tap';
} }
...@@ -385,4 +386,5 @@ class MultiTapGestureRecognizer extends GestureRecognizer { ...@@ -385,4 +386,5 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
_gestureArena = null; _gestureArena = null;
} }
String toStringShort() => 'multitap';
} }
...@@ -42,6 +42,9 @@ abstract class GestureRecognizer extends GestureArenaMember { ...@@ -42,6 +42,9 @@ abstract class GestureRecognizer extends GestureArenaMember {
/// GestureDetector widget calls this method). /// GestureDetector widget calls this method).
void dispose() { } void dispose() { }
/// Returns a very short pretty description of the gesture that the
/// recognizer looks for, like 'tap' or 'horizontal drag'.
String toStringShort() => toString();
} }
/// Base class for gesture recognizers that can only recognize one /// Base class for gesture recognizers that can only recognize one
......
...@@ -135,4 +135,6 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -135,4 +135,6 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
} }
_state = ScaleState.ready; _state = ScaleState.ready;
} }
String toStringShort() => 'scale';
} }
...@@ -102,4 +102,6 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer { ...@@ -102,4 +102,6 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
_wonArena = false; _wonArena = false;
_finalPosition = null; _finalPosition = null;
} }
String toStringShort() => 'tap';
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment