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.
5 #ifndef UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_
6 #define UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_
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"
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
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
{
36 explicit TouchExplorationController(aura::Window
* root_window
);
37 virtual ~TouchExplorationController();
40 scoped_ptr
<ui::Event
> CreateMouseMoveEvent(const gfx::PointF
& location
,
43 void EnterTouchToMouseMode();
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
;
51 // A set of touch ids for fingers currently touching the screen.
52 std::vector
<int> touch_ids_
;
54 // Map of touch ids to their last known location.
55 std::map
<int, gfx::PointF
> touch_locations_
;
57 // Initialized from RewriteEvent() and dispatched in NextDispatchEvent().
58 scoped_ptr
<ui::Event
> next_dispatch_event_
;
60 aura::Window
* root_window_
;
62 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController
);
67 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_