Commit 4e1108e7 authored by Adam Barth's avatar Adam Barth

Improve dartdoc comments for gestures.dart (#4000)

Also, make some previously private classes public for better
documentation.
parent d2c8c82f
...@@ -54,7 +54,11 @@ typedef void GesturePanEndCallback(Velocity velocity); ...@@ -54,7 +54,11 @@ typedef void GesturePanEndCallback(Velocity velocity);
/// [GesturePanDownCallback] did not complete. /// [GesturePanDownCallback] did not complete.
typedef void GesturePanCancelCallback(); typedef void GesturePanCancelCallback();
typedef void _GesturePolymorphicUpdateCallback<T>(T delta); /// Signature for when a pointer that is in contact with the screen and moving
/// has moved again. For one-dimensional drags (e.g., horizontal or vertical),
/// T is `double`, as in [GestureDragUpdateCallback]. For two-dimensional drags
/// (e.g., pans), T is `Offset`, as in GesturePanUpdateCallback.
typedef void GesturePolymorphicUpdateCallback<T>(T delta);
bool _isFlingGesture(Velocity velocity) { bool _isFlingGesture(Velocity velocity) {
assert(velocity != null); assert(velocity != null);
...@@ -62,7 +66,25 @@ bool _isFlingGesture(Velocity velocity) { ...@@ -62,7 +66,25 @@ bool _isFlingGesture(Velocity velocity) {
return speedSquared > kMinFlingVelocity * kMinFlingVelocity; return speedSquared > kMinFlingVelocity * kMinFlingVelocity;
} }
abstract class _DragGestureRecognizer<T extends dynamic> extends OneSequenceGestureRecognizer { /// Recognizes movement.
///
/// In contrast to [MultiDragGestureRecognizer], [DragGestureRecognizer]
/// recognizes a single gesture sequence for all the pointers it watches, which
/// means that the recognizer has at most one drag sequence active at any given
/// time regardless of how many pointers are in contact with the screen.
///
/// [DragGestureRecognizer] is not intended to be used directly. Instead,
/// consider using one of its subclasses to recognize specific types for drag
/// gestures.
///
/// See also:
///
/// * [HorizontalDragGestureRecognizer]
/// * [VerticalDragGestureRecognizer]
/// * [PanGestureRecognizer]
// Having T extend dynamic makes it possible to use the += operator on
// _pendingDragDelta without causing an analysis error.
abstract class DragGestureRecognizer<T extends dynamic> extends OneSequenceGestureRecognizer {
/// A pointer has contacted the screen and might begin to move. /// A pointer has contacted the screen and might begin to move.
GestureDragDownCallback onDown; GestureDragDownCallback onDown;
...@@ -70,15 +92,14 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends OneSequenceGest ...@@ -70,15 +92,14 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends OneSequenceGest
GestureDragStartCallback onStart; GestureDragStartCallback onStart;
/// A pointer that is in contact with the screen and moving has moved again. /// A pointer that is in contact with the screen and moving has moved again.
_GesturePolymorphicUpdateCallback<T> onUpdate; GesturePolymorphicUpdateCallback<T> onUpdate;
/// A pointer that was previously in contact with the screen and moving is no /// A pointer that was previously in contact with the screen and moving is no
/// longer in contact with the screen and was moving at a specific velocity /// longer in contact with the screen and was moving at a specific velocity
/// when it stopped contacting the screen. /// when it stopped contacting the screen.
GestureDragEndCallback onEnd; GestureDragEndCallback onEnd;
/// Signature for when the pointer that previously triggered [onDown] did not /// The pointer that previously triggered [onDown] did not complete.
/// complete.
GestureDragCancelCallback onCancel; GestureDragCancelCallback onCancel;
_DragState _state = _DragState.ready; _DragState _state = _DragState.ready;
...@@ -184,7 +205,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends OneSequenceGest ...@@ -184,7 +205,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends OneSequenceGest
/// See also: /// See also:
/// ///
/// * [VerticalMultiDragGestureRecognizer] /// * [VerticalMultiDragGestureRecognizer]
class VerticalDragGestureRecognizer extends _DragGestureRecognizer<double> { class VerticalDragGestureRecognizer extends DragGestureRecognizer<double> {
@override @override
double get _initialPendingDragDelta => 0.0; double get _initialPendingDragDelta => 0.0;
...@@ -205,7 +226,7 @@ class VerticalDragGestureRecognizer extends _DragGestureRecognizer<double> { ...@@ -205,7 +226,7 @@ class VerticalDragGestureRecognizer extends _DragGestureRecognizer<double> {
/// See also: /// See also:
/// ///
/// * [HorizontalMultiDragGestureRecognizer] /// * [HorizontalMultiDragGestureRecognizer]
class HorizontalDragGestureRecognizer extends _DragGestureRecognizer<double> { class HorizontalDragGestureRecognizer extends DragGestureRecognizer<double> {
@override @override
double get _initialPendingDragDelta => 0.0; double get _initialPendingDragDelta => 0.0;
...@@ -225,7 +246,7 @@ class HorizontalDragGestureRecognizer extends _DragGestureRecognizer<double> { ...@@ -225,7 +246,7 @@ class HorizontalDragGestureRecognizer extends _DragGestureRecognizer<double> {
/// ///
/// * [ImmediateMultiDragGestureRecognizer] /// * [ImmediateMultiDragGestureRecognizer]
/// * [DelayedMultiDragGestureRecognizer] /// * [DelayedMultiDragGestureRecognizer]
class PanGestureRecognizer extends _DragGestureRecognizer<Offset> { class PanGestureRecognizer extends DragGestureRecognizer<Offset> {
@override @override
Offset get _initialPendingDragDelta => Offset.zero; Offset get _initialPendingDragDelta => Offset.zero;
......
...@@ -151,11 +151,9 @@ abstract class MultiDragPointerState { ...@@ -151,11 +151,9 @@ abstract class MultiDragPointerState {
/// Recognizes movement on a per-pointer basis. /// Recognizes movement on a per-pointer basis.
/// ///
/// In contrast to [HorizontalDragGestureRecognizer], /// In contrast to [DragGestureRecognizer], [MultiDragGestureRecognizer] watches
/// [VerticalDragGestureRecognizer], and [PanGestureRecognizer], /// each pointer separately, which means multiple drags can be recognized
/// [MultiDragGestureRecognizer] watches each pointer separately, which means /// concurrently if multiple pointers are in contact with the screen.
/// multiple drags can be recognized concurrently if multiple pointers are in
/// contact with the screen.
/// ///
/// [MultiDragGestureRecognizer] is not intended to be used directly. Instead, /// [MultiDragGestureRecognizer] is not intended to be used directly. Instead,
/// consider using one of its subclasses to recognize specific types for drag /// consider using one of its subclasses to recognize specific types for drag
......
...@@ -68,7 +68,7 @@ abstract class OneSequenceGestureRecognizer extends GestureRecognizer { ...@@ -68,7 +68,7 @@ abstract class OneSequenceGestureRecognizer extends GestureRecognizer {
@override @override
void rejectGesture(int pointer) { } void rejectGesture(int pointer) { }
/// Called when the number of pointers this recognizers is tracking changes from one to zero. /// Called when the number of pointers this recognizer is tracking changes from one to zero.
/// ///
/// The given pointer ID is the ID of the last pointer this recognizer was /// The given pointer ID is the ID of the last pointer this recognizer was
/// tracking. /// tracking.
...@@ -141,7 +141,7 @@ enum GestureRecognizerState { ...@@ -141,7 +141,7 @@ enum GestureRecognizerState {
/// The recognizer is ready to start recognizing a gesture. /// The recognizer is ready to start recognizing a gesture.
ready, ready,
/// The sequence of pointer events seen thus far are consistent with the /// The sequence of pointer events seen thus far is consistent with the
/// gesture the recognizer is attempting to recognize but the gesture has not /// gesture the recognizer is attempting to recognize but the gesture has not
/// been accepted definitively. /// been accepted definitively.
possible, possible,
......
...@@ -12,22 +12,22 @@ enum ScaleState { ...@@ -12,22 +12,22 @@ enum ScaleState {
/// The recognizer is ready to start recognizing a gesture. /// The recognizer is ready to start recognizing a gesture.
ready, ready,
/// The sequence of pointer events seen thus far are consistent with a scale /// The sequence of pointer events seen thus far is consistent with a scale
/// gesture but the gesture has not been accepted definitively. /// gesture but the gesture has not been accepted definitively.
possible, possible,
/// The sequence of pointer events seen thus far have been accepted /// The sequence of pointer events seen thus far has been accepted
/// definitively as a scale gesture. /// definitively as a scale gesture.
accepted, accepted,
/// The sequence of pointer events seen thus far have been accepted /// The sequence of pointer events seen thus far has been accepted
/// definitively as a scale gesture and the pointers established a focal point /// definitively as a scale gesture and the pointers established a focal point
/// and initial scale. /// and initial scale.
started, started,
} }
/// Signature for when the pointers in contact with the screen have begun /// Signature for when the pointers in contact with the screen have established
/// established a focal point and initial scale of 1.0. /// a focal point and initial scale of 1.0.
typedef void GestureScaleStartCallback(Point focalPoint); typedef void GestureScaleStartCallback(Point focalPoint);
/// Signature for when the pointers in contact with the screen have indicated a /// Signature for when the pointers in contact with the screen have indicated a
...@@ -45,8 +45,8 @@ typedef void GestureScaleEndCallback(); ...@@ -45,8 +45,8 @@ typedef void GestureScaleEndCallback();
/// change, the recognizer calls [onUpdate]. When the pointers are no longer in /// change, the recognizer calls [onUpdate]. When the pointers are no longer in
/// contact with the screen, the recognizer calls [onEnd]. /// contact with the screen, the recognizer calls [onEnd].
class ScaleGestureRecognizer extends OneSequenceGestureRecognizer { class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
/// The pointers in contact with the screen have begun established a focal /// The pointers in contact with the screen have established a focal point and
/// point and initial scale of 1.0. /// initial scale of 1.0.
GestureScaleStartCallback onStart; GestureScaleStartCallback onStart;
/// The pointers in contact with the screen have indicated a new focal point /// The pointers in contact with the screen have indicated a new focal point
......
...@@ -178,8 +178,8 @@ class GestureDetector extends StatelessWidget { ...@@ -178,8 +178,8 @@ class GestureDetector extends StatelessWidget {
/// The pointer that previously triggered [onPanDown] did not complete. /// The pointer that previously triggered [onPanDown] did not complete.
final GesturePanCancelCallback onPanCancel; final GesturePanCancelCallback onPanCancel;
/// The pointers in contact with the screen have begun established a focal /// The pointers in contact with the screen have established a focal point and
/// point and initial scale of 1.0. /// initial scale of 1.0.
final GestureScaleStartCallback onScaleStart; final GestureScaleStartCallback onScaleStart;
/// The pointers in contact with the screen have indicated a new focal point /// The pointers in contact with the screen have indicated a new focal point
......
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