Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "ui/chromeos/ui_chromeos_export.h" | 10 #include "ui/chromeos/ui_chromeos_export.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 public: | 32 public: |
| 33 virtual ~TouchExplorationControllerDelegate() {} | 33 virtual ~TouchExplorationControllerDelegate() {} |
| 34 | 34 |
| 35 // This function should be called whenever the delegate wants to play a sound | 35 // This function should be called whenever the delegate wants to play a sound |
| 36 // when the volume adjusts. | 36 // when the volume adjusts. |
| 37 virtual void PlayVolumeAdjustSound() = 0; | 37 virtual void PlayVolumeAdjustSound() = 0; |
| 38 | 38 |
| 39 // Takes an int from 0.0 to 100.0 that indicates the percent the volume | 39 // Takes an int from 0.0 to 100.0 that indicates the percent the volume |
| 40 // should be set to. | 40 // should be set to. |
| 41 virtual void SetOutputLevel(int volume) = 0; | 41 virtual void SetOutputLevel(int volume) = 0; |
| 42 | |
| 43 // This function should be called whenever the delegate should play an earcon. | |
| 44 // In the future a parameter can be passed to indicate what sound should be | |
| 45 // played. | |
| 46 virtual void PlayEarCon() = 0; | |
| 42 }; | 47 }; |
| 43 | 48 |
| 44 // TouchExplorationController is used in tandem with "Spoken Feedback" to | 49 // TouchExplorationController is used in tandem with "Spoken Feedback" to |
| 45 // make the touch UI accessible. Gestures performed in the middle of the screen | 50 // make the touch UI accessible. Gestures performed in the middle of the screen |
| 46 // are mapped to accessiblity key shortcuts while gestures performed on the edge | 51 // are mapped to accessiblity key shortcuts while gestures performed on the edge |
| 47 // of the screen can change settings. | 52 // of the screen can change settings. |
| 48 // | 53 // |
| 49 // ** Short version ** | 54 // ** Short version ** |
| 50 // | 55 // |
| 51 // At a high-level, single-finger events are used for accessibility - | 56 // At a high-level, single-finger events are used for accessibility - |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 ui::EventRewriteStatus InSingleTapPressed( | 163 ui::EventRewriteStatus InSingleTapPressed( |
| 159 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 164 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 160 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased( | 165 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased( |
| 161 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 166 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 162 ui::EventRewriteStatus InDoubleTapPressed( | 167 ui::EventRewriteStatus InDoubleTapPressed( |
| 163 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 168 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 164 ui::EventRewriteStatus InTouchExploration( | 169 ui::EventRewriteStatus InTouchExploration( |
| 165 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 170 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 166 ui::EventRewriteStatus InTwoToOneFinger( | 171 ui::EventRewriteStatus InTwoToOneFinger( |
| 167 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 172 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 173 ui::EventRewriteStatus InCornerPassthrough( | |
| 174 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | |
| 168 ui::EventRewriteStatus InPassthrough( | 175 ui::EventRewriteStatus InPassthrough( |
| 169 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 176 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 170 ui::EventRewriteStatus InGestureInProgress( | 177 ui::EventRewriteStatus InGestureInProgress( |
| 171 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 178 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 172 ui::EventRewriteStatus InTouchExploreSecondPress( | 179 ui::EventRewriteStatus InTouchExploreSecondPress( |
| 173 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 180 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 174 ui::EventRewriteStatus InWaitForRelease( | 181 ui::EventRewriteStatus InWaitForRelease( |
| 175 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 182 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 176 ui::EventRewriteStatus InSlideGesture( | 183 ui::EventRewriteStatus InSlideGesture( |
| 177 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 184 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 // touch explore. Any fingers pressed past the first two are ignored. | 285 // touch explore. Any fingers pressed past the first two are ignored. |
| 279 TOUCH_EXPLORE_SECOND_PRESS, | 286 TOUCH_EXPLORE_SECOND_PRESS, |
| 280 | 287 |
| 281 // The user placed two fingers down within the grace period. | 288 // The user placed two fingers down within the grace period. |
| 282 // We're now in two to one finger mode until one of the fingers is | 289 // We're now in two to one finger mode until one of the fingers is |
| 283 // lifted. The first finger is ignored and the events for the second | 290 // lifted. The first finger is ignored and the events for the second |
| 284 // finger are passed throuugh. If either finger is released, nothing | 291 // finger are passed throuugh. If either finger is released, nothing |
| 285 // happens until all fingers are up. | 292 // happens until all fingers are up. |
| 286 TWO_TO_ONE_FINGER, | 293 TWO_TO_ONE_FINGER, |
| 287 | 294 |
| 295 // If the user has pressed and held down the left corner past long press, | |
| 296 // then as long as they are holding the corner, all subsequent fingers | |
| 297 // registered will be in passthrough. | |
| 298 CORNER_PASSTHROUGH, | |
| 299 | |
| 288 // If the user is in TWO_TO_ONE_FINGER with two fingers down and presses | 300 // If the user is in TWO_TO_ONE_FINGER with two fingers down and presses |
| 289 // a third finger, every finger and touch event is passed through until | 301 // a third finger, every finger and touch event is passed through until |
| 290 // all fingers are released. | 302 // all fingers are released. |
| 291 PASSTHROUGH, | 303 PASSTHROUGH, |
| 292 | 304 |
| 293 // If the user lifted a finger in TWO_TO_ONE_FINGER, they must release | 305 // If the user lifted a finger in TWO_TO_ONE_FINGER, they must release |
| 294 // all fingers before completing any more actions. This state is | 306 // all fingers before completing any more actions. This state is |
| 295 // generally useful for developing new features, because it creates a | 307 // generally useful for developing new features, because it creates a |
| 296 // simple way to handle a dead end in user flow. | 308 // simple way to handle a dead end in user flow. |
| 297 WAIT_FOR_RELEASE, | 309 WAIT_FOR_RELEASE, |
| 298 | 310 |
| 299 // If the user is within the given bounds from an edge of the screen, not | 311 // If the user is within the given bounds from an edge of the screen, not |
| 300 // including corners, then the resulting movements will be interpreted as | 312 // including corners, then the resulting movements will be interpreted as |
| 301 // slide gestures. | 313 // slide gestures. |
| 302 SLIDE_GESTURE, | 314 SLIDE_GESTURE, |
| 303 }; | 315 }; |
| 304 | 316 |
| 305 enum ScreenLocation { | 317 enum ScreenLocation { |
| 306 // Hot "edges" of the screen are each represented by a respective bit. | 318 // Hot "edges" of the screen are each represented by a respective bit. |
| 307 NO_EDGE = 0, | 319 NO_EDGE = 0, |
| 308 RIGHT_EDGE = 1 << 0, | 320 RIGHT_EDGE = 1 << 0, |
| 309 TOP_EDGE = 1 << 1, | 321 TOP_EDGE = 1 << 1, |
| 310 LEFT_EDGE = 1 << 2, | 322 LEFT_EDGE = 1 << 2, |
| 311 BOTTOM_EDGE = 1 << 3, | 323 BOTTOM_EDGE = 1 << 3, |
| 324 BOTTOM_LEFT_CORNER = LEFT_EDGE | BOTTOM_EDGE, | |
|
aboxhall
2014/07/24 18:26:34
Very nice!
| |
| 325 BOTTOM_RIGHT_CORNER = RIGHT_EDGE | BOTTOM_EDGE, | |
| 312 }; | 326 }; |
| 313 | 327 |
| 328 | |
|
aboxhall
2014/07/24 18:26:34
nit: rogue newline
lisayin
2014/07/25 20:11:57
Done.
| |
| 314 // Given a point, if it is within the given bounds of an edge, returns the | 329 // Given a point, if it is within the given bounds of an edge, returns the |
| 315 // edge. If it is within the given bounds of two edges, returns an int with | 330 // edge. If it is within the given bounds of two edges, returns an int with |
| 316 // both bits that represent the respective edges turned on. Otherwise returns | 331 // both bits that represent the respective edges turned on. Otherwise returns |
| 317 // SCREEN_CENTER. | 332 // SCREEN_CENTER. |
| 318 int FindEdgesWithinBounds(gfx::Point point, float bounds); | 333 int FindEdgesWithinBounds(gfx::Point point, float bounds); |
| 319 | 334 |
| 320 void VlogState(const char* function_name); | 335 void VlogState(const char* function_name); |
| 321 | 336 |
| 322 void VlogEvent(const ui::TouchEvent& event, const char* function_name); | 337 void VlogEvent(const ui::TouchEvent& event, const char* function_name); |
| 323 | 338 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 348 | 363 |
| 349 // The last synthesized mouse move event. When the user double-taps, | 364 // The last synthesized mouse move event. When the user double-taps, |
| 350 // we send the passed-through tap to the location of this event. | 365 // we send the passed-through tap to the location of this event. |
| 351 scoped_ptr<ui::TouchEvent> last_touch_exploration_; | 366 scoped_ptr<ui::TouchEvent> last_touch_exploration_; |
| 352 | 367 |
| 353 // The last event from the finger that is being passed through in | 368 // The last event from the finger that is being passed through in |
| 354 // TWO_TO_ONE_FINGER. When the user lifts a finger during two to one, | 369 // TWO_TO_ONE_FINGER. When the user lifts a finger during two to one, |
| 355 // the location and id of the touch release is from here. | 370 // the location and id of the touch release is from here. |
| 356 scoped_ptr<ui::TouchEvent> last_two_to_one_; | 371 scoped_ptr<ui::TouchEvent> last_two_to_one_; |
| 357 | 372 |
| 358 // A timer to fire the mouse move event after the double-tap delay. | 373 // A timer to fire to change states if a pre-set action is not completed in |
| 374 // the allocaated time. | |
|
aboxhall
2014/07/24 18:26:34
nit: allocaated (Dutch?)
lisayin
2014/07/25 20:11:57
Done.
| |
| 359 base::OneShotTimer<TouchExplorationController> tap_timer_; | 375 base::OneShotTimer<TouchExplorationController> tap_timer_; |
|
aboxhall
2014/07/24 18:26:34
This may need to be renamed, based on the comment
| |
| 360 | 376 |
| 361 // A timer to fire an indicating sound when sliding to change volume. | 377 // A timer to fire an indicating sound when sliding to change volume. |
| 362 base::RepeatingTimer<TouchExplorationController> sound_timer_; | 378 base::RepeatingTimer<TouchExplorationController> sound_timer_; |
| 363 | 379 |
| 364 // For testing only, an event handler to use for generated events | 380 // For testing only, an event handler to use for generated events |
| 365 // outside of the normal event rewriting flow. | 381 // outside of the normal event rewriting flow. |
| 366 ui::EventHandler* event_handler_for_testing_; | 382 ui::EventHandler* event_handler_for_testing_; |
| 367 | 383 |
| 368 // A default gesture detector config, so we can share the same | 384 // A default gesture detector config, so we can share the same |
| 369 // timeout and pixel slop constants. | 385 // timeout and pixel slop constants. |
| 370 ui::GestureDetector::Config gesture_detector_config_; | 386 ui::GestureDetector::Config gesture_detector_config_; |
| 371 | 387 |
| 372 // Gesture Handler to interpret the touch events. | 388 // Gesture Handler to interpret the touch events. |
| 373 ui::GestureProviderAura gesture_provider_; | 389 ui::GestureProviderAura gesture_provider_; |
| 374 | 390 |
| 375 // The previous state entered. | 391 // The previous state entered. |
| 376 State prev_state_; | 392 State prev_state_; |
| 377 | 393 |
| 378 // A copy of the previous event passed. | 394 // A copy of the previous event passed. |
| 379 scoped_ptr<ui::TouchEvent> prev_event_; | 395 scoped_ptr<ui::TouchEvent> prev_event_; |
| 380 | 396 |
| 381 // This toggles whether VLOGS are turned on or not. | 397 // This toggles whether VLOGS are turned on or not. |
| 382 bool VLOG_on_; | 398 bool VLOG_on_; |
| 383 | 399 |
| 400 // Indicates if a finger is in the lower left corner waiting for the timer to | |
| 401 // run out. | |
| 402 bool waiting_for_corner_passthrough_; | |
| 403 | |
| 384 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); | 404 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); |
| 385 }; | 405 }; |
| 386 | 406 |
| 387 } // namespace ui | 407 } // namespace ui |
| 388 | 408 |
| 389 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 409 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
| OLD | NEW |