Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / chromeos / touch_exploration_controller.h
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_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_
6 #define UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_
7
8 #include "base/values.h"
9 #include "ui/chromeos/ui_chromeos_export.h"
10 #include "ui/events/event_rewriter.h"
11 #include "ui/gfx/geometry/point.h"
12
13 namespace aura {
14 class Window;
15 }
16
17 namespace ui {
18
19 class Event;
20
21 // TouchExplorationController is used in tandem with "Spoken Feedback" to
22 // make the touch UI accessible. TouchExplorationController rewrites the
23 // incoming touch events as follows:
24 // - When one finger is touching the screen, touch events are converted to mouse
25 //   moves. This is the "Touch Exploration Mode". (The idea is that mouse moves
26 //   will be subsequently used by another component to move focus between UI
27 //   elements, and the elements will be read out to the user.)
28 // - When more than one finger is touching the screen, touches from the
29 //   first (i.e. "oldest") finger are ignored, and the other touches go through
30 //   as is.
31 // The caller is expected to retain ownership of instances of this class and
32 // destroy them before |root_window| is destroyed.
33 class UI_CHROMEOS_EXPORT TouchExplorationController :
34     public ui::EventRewriter {
35  public:
36   explicit TouchExplorationController(aura::Window* root_window);
37   virtual ~TouchExplorationController();
38
39  private:
40   scoped_ptr<ui::Event> CreateMouseMoveEvent(const gfx::PointF& location,
41                                              int flags);
42
43   void EnterTouchToMouseMode();
44
45   // Overridden from ui::EventRewriter
46   virtual ui::EventRewriteStatus RewriteEvent(
47       const ui::Event& event, scoped_ptr<ui::Event>* rewritten_event) OVERRIDE;
48   virtual ui::EventRewriteStatus NextDispatchEvent(
49       const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) OVERRIDE;
50
51   // A set of touch ids for fingers currently touching the screen.
52   std::vector<int> touch_ids_;
53
54   // Map of touch ids to their last known location.
55   std::map<int, gfx::PointF> touch_locations_;
56
57   // Initialized from RewriteEvent() and dispatched in NextDispatchEvent().
58   scoped_ptr<ui::Event> next_dispatch_event_;
59
60   aura::Window* root_window_;
61
62   DISALLOW_COPY_AND_ASSIGN(TouchExplorationController);
63 };
64
65 }  // namespace ui
66
67 #endif  // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_