#ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_
#define UI_EVENTS_GESTURE_DETECTION_GESTURE_PROVIDER_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/events/gesture_detection/gesture_detection_export.h"
#include "ui/events/gesture_detection/gesture_detector.h"
#include "ui/events/gesture_detection/scale_gesture_detector.h"
#include "ui/events/gesture_detection/snap_scroll_controller.h"
namespace ui {
struct GestureEventData;
class GESTURE_DETECTION_EXPORT GestureProviderClient {
public:
virtual ~GestureProviderClient() {}
virtual void OnGestureEvent(const GestureEventData& gesture) = 0;
};
class GESTURE_DETECTION_EXPORT GestureProvider {
public:
struct GESTURE_DETECTION_EXPORT Config {
Config();
~Config();
GestureDetector::Config gesture_detector_config;
ScaleGestureDetector::Config scale_gesture_detector_config;
SnapScrollController::Config snap_scroll_controller_config;
bool disable_click_delay;
};
GestureProvider(const Config& config, GestureProviderClient* client);
~GestureProvider();
bool OnTouchEvent(const MotionEvent& event);
void ResetGestureDetectors();
void SetMultiTouchSupportEnabled(bool enabled);
void SetDoubleTapSupportForPlatformEnabled(bool enabled);
void SetDoubleTapSupportForPageEnabled(bool enabled);
bool IsScrollInProgress() const;
bool IsPinchInProgress() const;
bool IsDoubleTapInProgress() const;
bool IsDoubleTapSupported() const;
bool IsClickDelayDisabled() const;
const ui::MotionEvent* current_down_event() const {
return current_down_event_.get();
}
private:
void InitGestureDetectors(const Config& config);
bool CanHandle(const MotionEvent& event) const;
void Fling(const MotionEvent& e, float velocity_x, float velocity_y);
void Send(const GestureEventData& gesture);
void SendTapCancelIfNecessary(const MotionEvent& event);
void SendTapCancelIfNecessary(const GestureEventData& event);
bool SendLongTapIfNecessary(const MotionEvent& event);
void EndTouchScrollIfNecessary(const MotionEvent& event,
bool send_scroll_end_event);
void UpdateDoubleTapDetectionSupport();
GestureProviderClient* const client_;
class GestureListenerImpl;
friend class GestureListenerImpl;
scoped_ptr<GestureListenerImpl> gesture_listener_;
class ScaleGestureListenerImpl;
friend class ScaleGestureListenerImpl;
scoped_ptr<ScaleGestureListenerImpl> scale_gesture_listener_;
scoped_ptr<MotionEvent> current_down_event_;
bool needs_show_press_event_;
bool needs_tap_ending_event_;
bool touch_scroll_in_progress_;
bool pinch_in_progress_;
bool double_tap_support_for_page_;
bool double_tap_support_for_platform_;
base::TimeTicks current_longpress_time_;
};
}
#endif