1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_LISTENERS_H_ 6 #define UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_LISTENERS_H_ 7 8 #include "ui/events/gesture_detection/gesture_detection_export.h" 9 10 namespace ui { 11 12 class MotionEvent; 13 class ScaleGestureDetector; 14 15 // Client through which |ScaleGestureDetector| signals scale detection. 16 class GESTURE_DETECTION_EXPORT ScaleGestureListener { 17 public: ~ScaleGestureListener()18 virtual ~ScaleGestureListener() {} 19 virtual bool OnScale(const ScaleGestureDetector& detector, 20 const MotionEvent& e) = 0; 21 virtual bool OnScaleBegin(const ScaleGestureDetector& detector, 22 const MotionEvent& e) = 0; 23 virtual void OnScaleEnd(const ScaleGestureDetector& detector, 24 const MotionEvent& e) = 0; 25 }; 26 27 // A convenience class to extend when you only want to listen for a subset of 28 // scaling-related events. This implements all methods in 29 // |ScaleGestureListener| but does nothing. 30 // |OnScale()| returns false so that a subclass can retrieve the accumulated 31 // scale factor in an overridden |OnScaleEnd()|. 32 // |OnScaleBegin() returns true. 33 class GESTURE_DETECTION_EXPORT SimpleScaleGestureListener 34 : public ScaleGestureListener { 35 public: 36 // ScaleGestureListener implementation. 37 bool OnScale(const ScaleGestureDetector&, const MotionEvent&) override; 38 bool OnScaleBegin(const ScaleGestureDetector&, const MotionEvent&) override; 39 void OnScaleEnd(const ScaleGestureDetector&, const MotionEvent&) override; 40 }; 41 42 } // namespace ui 43 44 #endif // UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_LISTENERS_H_ 45