blob: 64ccf1573b58c5bab1464d26694467cd94b0cf38 [file] [log] [blame]
[email protected]cd57cc5a2012-10-12 22:43:411// Copyright 2011 The Chromium Authors. All rights reserved.
[email protected]0fb25002012-10-12 07:20:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
[email protected]cd57cc5a2012-10-12 22:43:414
[email protected]8fcbaa372012-11-05 04:12:415#ifndef CC_INPUT_HANDLER_H_
6#define CC_INPUT_HANDLER_H_
[email protected]cd57cc5a2012-10-12 22:43:417
8#include "base/basictypes.h"
[email protected]30faac92012-10-29 00:06:299#include "base/time.h"
[email protected]52347c842012-11-02 21:06:2010#include "cc/cc_export.h"
[email protected]cd57cc5a2012-10-12 22:43:4111
[email protected]d455d552012-11-02 00:19:0612namespace gfx {
13class Point;
[email protected]2f1acc262012-11-16 21:42:2214class PointF;
[email protected]c9c1ebe2012-11-05 20:46:1315class Vector2d;
[email protected]d455d552012-11-02 00:19:0616}
17
[email protected]cd57cc5a2012-10-12 22:43:4118namespace cc {
19
[email protected]96baf3e2012-10-22 23:09:5520// The InputHandler is a way for the embedders to interact with
[email protected]cd57cc5a2012-10-12 22:43:4121// the impl thread side of the compositor implementation.
22//
[email protected]96baf3e2012-10-22 23:09:5523// There is one InputHandler for every LayerTreeHost. It is
[email protected]cd57cc5a2012-10-12 22:43:4124// created on the main thread and used only on the impl thread.
25//
[email protected]96baf3e2012-10-22 23:09:5526// The InputHandler is constructed with a InputHandlerClient, which is the
[email protected]cd57cc5a2012-10-12 22:43:4127// interface by which the handler can manipulate the LayerTree.
[email protected]52347c842012-11-02 21:06:2028class CC_EXPORT InputHandlerClient {
[email protected]cd57cc5a2012-10-12 22:43:4129public:
30 enum ScrollStatus { ScrollOnMainThread, ScrollStarted, ScrollIgnored };
[email protected]7dfa6862013-01-31 01:29:0931 enum ScrollInputType { Gesture, Wheel, NonBubblingGesture };
[email protected]cd57cc5a2012-10-12 22:43:4132
[email protected]31bfe272012-10-19 18:49:5233 // Selects a layer to be scrolled at a given point in viewport (logical
34 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates
35 // can be scrolled, ScrollOnMainThread if the scroll event should instead be
36 // delegated to the main thread, or ScrollIgnored if there is nothing to be
37 // scrolled at the given coordinates.
[email protected]c9c1ebe2012-11-05 20:46:1338 virtual ScrollStatus scrollBegin(gfx::Point, ScrollInputType) = 0;
[email protected]cd57cc5a2012-10-12 22:43:4139
[email protected]31bfe272012-10-19 18:49:5240 // Scroll the selected layer starting at the given position. If the scroll
41 // type given to scrollBegin was a gesture, then the scroll point and delta
42 // should be in viewport (logical pixel) coordinates. Otherwise they are in
43 // scrolling layer's (logical pixel) space. If there is no room to move the
44 // layer in the requested direction, its first ancestor layer that can be
[email protected]a9710962012-11-14 20:11:0245 // scrolled will be moved instead. If no layer can be moved in the requested
46 // direction at all, then false is returned. If any layer is moved, then
47 // true is returned.
48 // Should only be called if scrollBegin() returned ScrollStarted.
49 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) = 0;
[email protected]cd57cc5a2012-10-12 22:43:4150
51 // Stop scrolling the selected layer. Should only be called if scrollBegin()
52 // returned ScrollStarted.
53 virtual void scrollEnd() = 0;
54
55 virtual void pinchGestureBegin() = 0;
[email protected]c9c1ebe2012-11-05 20:46:1356 virtual void pinchGestureUpdate(float magnifyDelta, gfx::Point anchor) = 0;
[email protected]cd57cc5a2012-10-12 22:43:4157 virtual void pinchGestureEnd() = 0;
58
[email protected]c9c1ebe2012-11-05 20:46:1359 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset,
[email protected]cd57cc5a2012-10-12 22:43:4160 bool anchorPoint,
61 float pageScale,
[email protected]30faac92012-10-29 00:06:2962 base::TimeTicks startTime,
63 base::TimeDelta duration) = 0;
[email protected]cd57cc5a2012-10-12 22:43:4164
[email protected]96baf3e2012-10-22 23:09:5565 // Request another callback to InputHandler::animate().
[email protected]cd57cc5a2012-10-12 22:43:4166 virtual void scheduleAnimation() = 0;
67
[email protected]2f1acc262012-11-16 21:42:2268 virtual bool haveTouchEventHandlersAt(const gfx::Point&) = 0;
69
[email protected]cd57cc5a2012-10-12 22:43:4170protected:
[email protected]96baf3e2012-10-22 23:09:5571 InputHandlerClient() { }
72 virtual ~InputHandlerClient() { }
[email protected]cd57cc5a2012-10-12 22:43:4173
74private:
[email protected]96baf3e2012-10-22 23:09:5575 DISALLOW_COPY_AND_ASSIGN(InputHandlerClient);
[email protected]cd57cc5a2012-10-12 22:43:4176};
77
[email protected]52347c842012-11-02 21:06:2078class CC_EXPORT InputHandler {
[email protected]cd57cc5a2012-10-12 22:43:4179public:
[email protected]96baf3e2012-10-22 23:09:5580 virtual ~InputHandler() { }
[email protected]cd57cc5a2012-10-12 22:43:4181
[email protected]96baf3e2012-10-22 23:09:5582 virtual void bindToClient(InputHandlerClient*) = 0;
[email protected]30faac92012-10-29 00:06:2983 virtual void animate(base::TimeTicks time) = 0;
[email protected]9b2c7efc2012-12-17 18:23:5584 virtual void mainThreadHasStoppedFlinging() = 0;
[email protected]cd57cc5a2012-10-12 22:43:4185
86protected:
[email protected]96baf3e2012-10-22 23:09:5587 InputHandler() { }
[email protected]cd57cc5a2012-10-12 22:43:4188
89private:
[email protected]96baf3e2012-10-22 23:09:5590 DISALLOW_COPY_AND_ASSIGN(InputHandler);
[email protected]cd57cc5a2012-10-12 22:43:4191};
92
93}
94
[email protected]8fcbaa372012-11-05 04:12:4195#endif // CC_INPUT_HANDLER_H_