gesture.dart 1.84 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2016 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 'message.dart';

class Tap extends CommandWithTarget {
8
  @override
9 10 11 12
  final String kind = 'tap';

  Tap(ObjectRef targetRef) : super(targetRef);

13
  static Tap deserialize(Map<String, String> json) {
14 15 16
    return new Tap(new ObjectRef(json['targetRef']));
  }

17
  @override
18
  Map<String, String> serialize() => super.serialize();
19 20 21 22 23 24 25
}

class TapResult extends Result {
  static TapResult fromJson(Map<String, dynamic> json) {
    return new TapResult();
  }

26
  @override
27 28
  Map<String, dynamic> toJson() => {};
}
29 30 31 32


/// Command the driver to perform a scrolling action.
class Scroll extends CommandWithTarget {
33
  @override
34 35 36 37 38 39 40 41 42 43
  final String kind = 'scroll';

  Scroll(
    ObjectRef targetRef,
    this.dx,
    this.dy,
    this.duration,
    this.frequency
  ) : super(targetRef);

44
  static Scroll deserialize(Map<String, dynamic> json) {
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
    return new Scroll(
      new ObjectRef(json['targetRef']),
      double.parse(json['dx']),
      double.parse(json['dy']),
      new Duration(microseconds: int.parse(json['duration'])),
      int.parse(json['frequency'])
    );
  }

  /// Delta X offset per move event.
  final double dx;

  /// Delta Y offset per move event.
  final double dy;

  /// The duration of the scrolling action
  final Duration duration;

  /// The frequency in Hz of the generated move events.
  final int frequency;

66
  @override
67 68 69 70 71
  Map<String, String> serialize() => super.serialize()..addAll({
    'dx': '$dx',
    'dy': '$dy',
    'duration': '${duration.inMicroseconds}',
    'frequency': '$frequency',
72 73 74 75 76 77 78 79
  });
}

class ScrollResult extends Result {
  static ScrollResult fromJson(Map<String, dynamic> json) {
    return new ScrollResult();
  }

80
  @override
81 82
  Map<String, dynamic> toJson() => {};
}