Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: ui/chromeos/touch_exploration_controller.h

Issue 420073003: Two Finger Tap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improved descriptions Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ 5 #ifndef UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_
6 #define UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ 6 #define UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_
7 7
8 #include "base/time/tick_clock.h" 8 #include "base/time/tick_clock.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 22 matching lines...) Expand all
33 public: 33 public:
34 virtual ~TouchExplorationControllerDelegate() {} 34 virtual ~TouchExplorationControllerDelegate() {}
35 35
36 // This function should be called whenever the delegate wants to play a sound 36 // This function should be called whenever the delegate wants to play a sound
37 // when the volume adjusts. 37 // when the volume adjusts.
38 virtual void PlayVolumeAdjustSound() = 0; 38 virtual void PlayVolumeAdjustSound() = 0;
39 39
40 // Takes an int from 0.0 to 100.0 that indicates the percent the volume 40 // Takes an int from 0.0 to 100.0 that indicates the percent the volume
41 // should be set to. 41 // should be set to.
42 virtual void SetOutputLevel(int volume) = 0; 42 virtual void SetOutputLevel(int volume) = 0;
43
44 // Silences spoken feedback.
45 virtual void SilenceSpokenFeedback() = 0;
43 }; 46 };
44 47
45 // TouchExplorationController is used in tandem with "Spoken Feedback" to 48 // TouchExplorationController is used in tandem with "Spoken Feedback" to
46 // make the touch UI accessible. Gestures performed in the middle of the screen 49 // make the touch UI accessible. Gestures performed in the middle of the screen
47 // are mapped to accessiblity key shortcuts while gestures performed on the edge 50 // are mapped to accessiblity key shortcuts while gestures performed on the edge
48 // of the screen can change settings. 51 // of the screen can change settings.
49 // 52 //
50 // ** Short version ** 53 // ** Short version **
51 // 54 //
52 // At a high-level, single-finger events are used for accessibility - 55 // At a high-level, single-finger events are used for accessibility -
53 // exploring the screen gets turned into mouse moves (which can then be 56 // exploring the screen gets turned into mouse moves (which can then be
54 // spoken by an accessibility service running), a single tap while the user 57 // spoken by an accessibility service running), a single tap while the user
55 // is in touch exploration or a double-tap simulates a click, and gestures 58 // is in touch exploration or a double-tap simulates a click, and gestures
56 // can be used to send high-level accessibility commands. For example, a swipe 59 // can be used to send high-level accessibility commands. For example, a swipe
57 // right would correspond to the keyboard short cut shift+search+right. 60 // right would correspond to the keyboard short cut shift+search+right.
58 // When two or more fingers are pressed initially, from then on the events 61 // When two or more fingers are pressed initially, from then on the events
59 // are passed through, but with the initial finger removed - so if you swipe 62 // are passed through, but with the initial finger removed - so if you swipe
60 // down with two fingers, the running app will see a one-finger swipe. Slide 63 // down with two fingers, the running app will see a one-finger swipe. Slide
61 // gestures performed on the edge of the screen can change settings 64 // gestures performed on the edge of the screen can change settings
62 // continuously. For example, sliding a finger along the right side of the 65 // continuously. For example, sliding a finger along the right side of the
63 // screen will change the volume. 66 // screen will change the volume. When a user double taps and holds with one
64 // When a user double taps and holds with one finger, the finger is passed 67 // finger, the finger is passed through as if accessibility was turned off. If
65 // through as if accessibility was turned off. 68 // the user taps the screen with two fingers, the user can silence spoken
69 // feedback if it is playing.
66 // 70 //
67 // ** Long version ** 71 // ** Long version **
68 // 72 //
69 // Here are the details of the implementation: 73 // Here are the details of the implementation:
70 // 74 //
71 // When the first touch is pressed, a 300 ms grace period timer starts. 75 // When the first touch is pressed, a 300 ms grace period timer starts.
72 // 76 //
73 // If the user keeps their finger down for more than 300 ms and doesn't 77 // If the user keeps their finger down for more than 300 ms and doesn't
74 // perform a supported accessibility gesture in that time (e.g. swipe right), 78 // perform a supported accessibility gesture in that time (e.g. swipe right),
75 // they enter touch exploration mode, and all movements are translated into 79 // they enter touch exploration mode, and all movements are translated into
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // perform other touch accessibility movements, the user must lift their finger. 131 // perform other touch accessibility movements, the user must lift their finger.
128 // If additional fingers are added while in this state, the user will transition 132 // If additional fingers are added while in this state, the user will transition
129 // to passthrough. 133 // to passthrough.
130 // 134 //
131 // Currently, only the right edge is mapped to control the volume. Volume 135 // Currently, only the right edge is mapped to control the volume. Volume
132 // control along the edge of the screen is directly proportional to where the 136 // control along the edge of the screen is directly proportional to where the
133 // user's finger is located on the screen. The top right corner of the screen 137 // user's finger is located on the screen. The top right corner of the screen
134 // automatically sets the volume to 100% and the bottome right corner of the 138 // automatically sets the volume to 100% and the bottome right corner of the
135 // screen automatically sets the volume to 0% once the user has moved past slop. 139 // screen automatically sets the volume to 0% once the user has moved past slop.
136 // 140 //
141 // If the user taps the screen with two fingers and lifts both fingers before
142 // the grace period has passed, spoken feedback is silenced.
143 //
137 // Once touch exploration mode has been activated, 144 // Once touch exploration mode has been activated,
138 // it remains in that mode until all fingers have been released. 145 // it remains in that mode until all fingers have been released.
139 // 146 //
140 // The caller is expected to retain ownership of instances of this class and 147 // The caller is expected to retain ownership of instances of this class and
141 // destroy them before |root_window| is destroyed. 148 // destroy them before |root_window| is destroyed.
142 class UI_CHROMEOS_EXPORT TouchExplorationController 149 class UI_CHROMEOS_EXPORT TouchExplorationController
143 : public ui::EventRewriter, 150 : public ui::EventRewriter,
144 public ui::GestureProviderAuraClient { 151 public ui::GestureProviderAuraClient {
145 public: 152 public:
146 explicit TouchExplorationController( 153 explicit TouchExplorationController(
(...skipping 29 matching lines...) Expand all
176 ui::EventRewriteStatus InOneFingerPassthrough( 183 ui::EventRewriteStatus InOneFingerPassthrough(
177 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 184 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
178 ui::EventRewriteStatus InGestureInProgress( 185 ui::EventRewriteStatus InGestureInProgress(
179 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 186 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
180 ui::EventRewriteStatus InTouchExploreSecondPress( 187 ui::EventRewriteStatus InTouchExploreSecondPress(
181 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 188 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
182 ui::EventRewriteStatus InWaitForOneFinger( 189 ui::EventRewriteStatus InWaitForOneFinger(
183 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 190 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
184 ui::EventRewriteStatus InSlideGesture( 191 ui::EventRewriteStatus InSlideGesture(
185 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 192 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
193 ui::EventRewriteStatus InTwoFingerTap(
194 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
186 195
187 // Returns the current time of the tick clock. 196 // Returns the current time of the tick clock.
188 base::TimeDelta Now(); 197 base::TimeDelta Now();
189 198
190 // This timer is started every time we get the first press event, and 199 // This timer is started every time we get the first press event, and
191 // it fires after the double-click timeout elapses (300 ms by default). 200 // it fires after the double-click timeout elapses (300 ms by default).
192 // If the user taps and releases within 300 ms and doesn't press again, 201 // If the user taps and releases within 300 ms and doesn't press again,
193 // we treat that as a single mouse move (touch exploration) event. 202 // we treat that as a single mouse move (touch exploration) event.
194 void StartTapTimer(); 203 void StartTapTimer();
195 void OnTapTimerFired(); 204 void OnTapTimerFired();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // passthrough, touch exploration, and gestures, they must release 316 // passthrough, touch exploration, and gestures, they must release
308 // all fingers except before completing any more actions. This state is 317 // all fingers except before completing any more actions. This state is
309 // generally useful for developing new features, because it creates a 318 // generally useful for developing new features, because it creates a
310 // simple way to handle a dead end in user flow. 319 // simple way to handle a dead end in user flow.
311 WAIT_FOR_ONE_FINGER, 320 WAIT_FOR_ONE_FINGER,
312 321
313 // If the user is within the given bounds from an edge of the screen, not 322 // If the user is within the given bounds from an edge of the screen, not
314 // including corners, then the resulting movements will be interpreted as 323 // including corners, then the resulting movements will be interpreted as
315 // slide gestures. 324 // slide gestures.
316 SLIDE_GESTURE, 325 SLIDE_GESTURE,
326
327 // If the user taps the screen with two fingers and releases both fingers
328 // before the grace period has passed, spoken feedback will be silenced.
329 TWO_FINGER_TAP,
317 }; 330 };
318 331
319 enum ScreenLocation { 332 enum ScreenLocation {
320 // Hot "edges" of the screen are each represented by a respective bit. 333 // Hot "edges" of the screen are each represented by a respective bit.
321 NO_EDGE = 0, 334 NO_EDGE = 0,
322 RIGHT_EDGE = 1 << 0, 335 RIGHT_EDGE = 1 << 0,
323 TOP_EDGE = 1 << 1, 336 TOP_EDGE = 1 << 1,
324 LEFT_EDGE = 1 << 2, 337 LEFT_EDGE = 1 << 2,
325 BOTTOM_EDGE = 1 << 3, 338 BOTTOM_EDGE = 1 << 3,
326 }; 339 };
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // When touch_exploration_controller gets time relative to real time during 406 // When touch_exploration_controller gets time relative to real time during
394 // testing, this clock is set to the simulated clock and used. 407 // testing, this clock is set to the simulated clock and used.
395 base::TickClock* tick_clock_; 408 base::TickClock* tick_clock_;
396 409
397 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); 410 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController);
398 }; 411 };
399 412
400 } // namespace ui 413 } // namespace ui
401 414
402 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ 415 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698