Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: ui/events/gesture_detection/scale_gesture_detector.h

Issue 501503003: Avoid an extra GestureDetector instance for double-tap drag zooming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/events/gesture_detection/scale_gesture_detector.h
diff --git a/ui/events/gesture_detection/scale_gesture_detector.h b/ui/events/gesture_detection/scale_gesture_detector.h
index 7f647c0684cceae31232928ab811f0003d7a87a5..dc317439ceb487f1f0ea20e1c028b1b08c13650b 100644
--- a/ui/events/gesture_detection/scale_gesture_detector.h
+++ b/ui/events/gesture_detection/scale_gesture_detector.h
@@ -5,10 +5,8 @@
#ifndef UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_
#define UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "ui/events/gesture_detection/gesture_detection_export.h"
-#include "ui/events/gesture_detection/gesture_detector.h"
namespace ui {
@@ -18,12 +16,16 @@ class MotionEvent;
// * platform/frameworks/base/core/java/android/view/ScaleGestureDetector.java
// * Change-Id: I3e7926a4f6f9ab4951f380bd004499c78b3bda69
// * Please update the Change-Id as upstream Android changes are pulled.
-class ScaleGestureDetector : public GestureDetector::SimpleGestureListener {
+class ScaleGestureDetector {
public:
struct GESTURE_DETECTION_EXPORT Config {
Config();
~Config();
- GestureDetector::Config gesture_detector_config;
+
+ // Distance the current span can deviate from the initial span before
+ // scaling will start (in dips). The span is the diameter of the circle with
+ // a radius of average pointer deviation from the focial point.
tdresser 2014/08/22 20:45:40 focial -> focal
jdduke (slow) 2014/08/22 21:26:55 Bah, yeah I'll do it now.
+ float span_slop;
// Minimum accepted value for TouchMajor while scaling (in dips).
float min_scaling_touch_major;
@@ -31,9 +33,6 @@ class ScaleGestureDetector : public GestureDetector::SimpleGestureListener {
// Minimum span needed to initiate a scaling gesture (in dips).
float min_scaling_span;
- // Whether double-tap drag scaling is enabled.
- bool quick_scale_enabled;
-
// Minimum pinch span change before pinch occurs (in dips). See
// crbug.com/373318.
float min_pinch_update_span_delta;
@@ -82,10 +81,14 @@ class ScaleGestureDetector : public GestureDetector::SimpleGestureListener {
// the rest of the MotionEvents in this event stream.
bool OnTouchEvent(const MotionEvent& event);
+ // This method may be called by the owner when a a double-tap event has been
+ // detected *for the same event stream* being fed to this instance of the
+ // ScaleGestureDetector. As call order is important here, the double-tap
+ // detector should always be offered events *before* the ScaleGestureDetector.
+ bool OnDoubleTap(const MotionEvent& event);
+
// Set whether the associated |ScaleGestureListener| should receive
// OnScale callbacks when the user performs a doubletap followed by a swipe.
- void SetQuickScaleEnabled(bool scales);
- bool IsQuickScaleEnabled() const;
bool IsInProgress() const;
bool InDoubleTapMode() const;
float GetFocusX() const;
@@ -103,9 +106,6 @@ class ScaleGestureDetector : public GestureDetector::SimpleGestureListener {
private:
enum DoubleTapMode { DOUBLE_TAP_MODE_NONE, DOUBLE_TAP_MODE_IN_PROGRESS };
- // DoubleTapListener implementation.
- virtual bool OnDoubleTap(const MotionEvent& ev) OVERRIDE;
-
// The TouchMajor/TouchMinor elements of a MotionEvent can flutter/jitter on
// some hardware/driver combos. Smooth out to get kinder, gentler behavior.
void AddTouchHistory(const MotionEvent& ev);
@@ -115,13 +115,8 @@ class ScaleGestureDetector : public GestureDetector::SimpleGestureListener {
ScaleGestureListener* const listener_;
- Config config_;
-
float focus_x_;
float focus_y_;
-
- bool quick_scale_enabled_;
-
float curr_span_;
float prev_span_;
float initial_span_;
@@ -149,8 +144,6 @@ class ScaleGestureDetector : public GestureDetector::SimpleGestureListener {
bool event_before_or_above_starting_gesture_event_;
- scoped_ptr<GestureDetector> gesture_detector_;
-
DISALLOW_COPY_AND_ASSIGN(ScaleGestureDetector);
};
« no previous file with comments | « ui/events/gesture_detection/gesture_provider_unittest.cc ('k') | ui/events/gesture_detection/scale_gesture_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698