blob: 7e4e4fa2350f4a9a5b0dcc20473ba53321dc183e [file] [log] [blame]
reveman39b32c872015-12-08 05:34:051// Copyright 2015 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 COMPONENTS_EXO_POINTER_DELEGATE_H_
6#define COMPONENTS_EXO_POINTER_DELEGATE_H_
7
8#include "base/time/time.h"
9#include "ui/events/event_constants.h"
10
11namespace gfx {
reveman79363c1c2016-05-02 23:58:5612class PointF;
denniskempin73513872016-03-02 21:31:0713class Vector2dF;
reveman39b32c872015-12-08 05:34:0514}
15
16namespace exo {
17class Pointer;
18class Surface;
19
20// Handles events on pointers in context-specific ways.
21class PointerDelegate {
22 public:
23 // Called at the top of the pointer's destructor, to give observers a
24 // chance to remove themselves.
25 virtual void OnPointerDestroying(Pointer* pointer) = 0;
26
27 // This should return true if |surface| is a valid target for this pointer.
28 // E.g. the surface is owned by the same client as the pointer.
29 virtual bool CanAcceptPointerEventsForSurface(Surface* surface) const = 0;
30
31 // Called when pointer enters a new valid target surface. |location|
32 // is the location of pointer relative to the origin of surface and
33 // |button_flags| contains all currently pressed buttons.
34 virtual void OnPointerEnter(Surface* surface,
reveman79363c1c2016-05-02 23:58:5635 const gfx::PointF& location,
reveman39b32c872015-12-08 05:34:0536 int pressed_button_flags) = 0;
37
38 // Called when pointer leaves a valid target surface.
39 virtual void OnPointerLeave(Surface* surface) = 0;
40
41 // Called when pointer moved within the current target surface.
majidvp9b3bda82016-06-09 18:12:0942 virtual void OnPointerMotion(base::TimeTicks time_stamp,
reveman79363c1c2016-05-02 23:58:5643 const gfx::PointF& location) = 0;
reveman39b32c872015-12-08 05:34:0544
45 // Called when pointer button state changed. |changed_button_flags| contains
46 // all buttons that changed. |pressed| is true if buttons entered pressed
47 // state.
majidvp9b3bda82016-06-09 18:12:0948 virtual void OnPointerButton(base::TimeTicks time_stamp,
reveman39b32c872015-12-08 05:34:0549 int changed_button_flags,
50 bool pressed) = 0;
51
denniskempin73513872016-03-02 21:31:0752 // Called when pointer is scrolling. |offset| contains the direction and
53 // distance of the change. |discrete| is true if the scrolling is caused
54 // by a discrete device such as a scroll wheel.
majidvp9b3bda82016-06-09 18:12:0955 virtual void OnPointerScroll(base::TimeTicks time_stamp,
denniskempin73513872016-03-02 21:31:0756 const gfx::Vector2dF& offset,
57 bool discrete) = 0;
58
59 // Called when a current kinetic scroll should be canceled.
majidvp9b3bda82016-06-09 18:12:0960 virtual void OnPointerScrollCancel(base::TimeTicks time_stamp) = 0;
denniskempin73513872016-03-02 21:31:0761
62 // Called when pointer scroll has stopped and a fling is happening (e.g.
63 // lifting the fingers from the touchpad after scrolling quickly)
majidvp9b3bda82016-06-09 18:12:0964 virtual void OnPointerScrollStop(base::TimeTicks time_stamp) = 0;
denniskempin73513872016-03-02 21:31:0765
66 // Called after all pointer information of this frame has been set and the
67 // client should evaluate the updated state. No events are being sent before
68 // this method is called.
69 virtual void OnPointerFrame() = 0;
reveman39b32c872015-12-08 05:34:0570
71 protected:
72 virtual ~PointerDelegate() {}
73};
74
75} // namespace exo
76
77#endif // COMPONENTS_EXO_POINTER_DELEGATE_H_