Chromium Code Reviews| Index: ui/chromeos/touch_exploration_controller.h |
| diff --git a/ui/chromeos/touch_exploration_controller.h b/ui/chromeos/touch_exploration_controller.h |
| index e809bcd7b9378f0232a2137e4bd0f29e4f605f5a..83587307f3ed61fab600758293bd18b191eb0813 100644 |
| --- a/ui/chromeos/touch_exploration_controller.h |
| +++ b/ui/chromeos/touch_exploration_controller.h |
| @@ -26,9 +26,24 @@ class GestureEvent; |
| class GestureProviderAura; |
| class TouchEvent; |
| +// A delegate to handle commands in response to detected accessibility gesture |
| +// events. |
| +class TouchExplorationControllerDelegate { |
| + public: |
| + virtual ~TouchExplorationControllerDelegate() {} |
| + |
| + // This function should be called whenever the delegate wants to play a sound |
| + // when the volume adjusts. |
| + virtual void PlayVolumeAdjustSound() = 0; |
| + // Takes a float from 1 to 100 that indicates the percent the volume should be |
|
James Cook
2014/07/15 22:40:37
nit: blank line above
And nice comment, it explai
lisayin
2014/07/15 23:54:46
Done.
|
| + // set to. |
| + virtual void SetOutputLevel(float volume) = 0; |
| +}; |
| + |
| // TouchExplorationController is used in tandem with "Spoken Feedback" to |
| -// make the touch UI accessible. Gestures are mapped to accessiblity key |
| -// shortcuts. |
| +// make the touch UI accessible. Gestures performed in the middle of the screen |
| +// are mapped to accessiblity key shortcuts while gestures performed on the edge |
| +// of the screen can change settings. |
| // |
| // ** Short version ** |
| // |
| @@ -40,7 +55,10 @@ class TouchEvent; |
| // right would correspond to the keyboard short cut shift+search+right. |
| // When two or more fingers are pressed initially, from then on the events |
| // are passed through, but with the initial finger removed - so if you swipe |
| -// down with two fingers, the running app will see a one-finger swipe. |
| +// down with two fingers, the running app will see a one-finger swipe. Slide |
| +// gestures performed on the edge of the screen can change settings |
| +// continuously. For example, sliding a finger along the right side of the |
| +// screen will change the volume. |
| // |
| // ** Long version ** |
| // |
| @@ -91,6 +109,24 @@ class TouchEvent; |
| // adds a third finger while in two to one finger mode, all fingers and touch |
| // events are passed through from then on. |
| // |
| +// If the user places a finger on the edge of the screen and moves their finger |
| +// past slop, a slide gesture is performed. The user can then slide one finger |
| +// along an edge of the screen and continuously control a setting. Once the user |
| +// enters this state, the boundaries that define an edge expand so that the user |
| +// can now adjust the setting within a slightly bigger width along the screen. |
| +// If the user exits this area without lifting their finger, they will not be |
| +// able to perform any actions, however if they keep their finger down and |
| +// return to the "hot edge," then they can still adjust the setting. In order to |
| +// perform other touch accessibility movements, the user must lift their finger. |
| +// If additional fingers are added while in this state, the user will transition |
| +// to passthrough. |
| +// |
| +// Currently, only the right edge is mapped to control the volume. Volume |
| +// control along the edge of the screen is directly proportional to where the |
| +// user's finger is located on the screen. The top right corner of the screen |
| +// automatically sets the volume to 100% and the bottome right corner of the |
| +// screen automatically sets the volume to 0% once the user has moved past slop. |
| +// |
| // Once touch exploration mode has been activated, |
| // it remains in that mode until all fingers have been released. |
| // |
| @@ -100,7 +136,9 @@ class UI_CHROMEOS_EXPORT TouchExplorationController |
| : public ui::EventRewriter, |
| public ui::GestureProviderAuraClient { |
| public: |
| - explicit TouchExplorationController(aura::Window* root_window); |
| + explicit TouchExplorationController( |
| + aura::Window* root_window, |
| + ui::TouchExplorationControllerDelegate* delegate); |
| virtual ~TouchExplorationController(); |
| void CallTapTimerNowForTesting(); |
| @@ -108,9 +146,11 @@ class UI_CHROMEOS_EXPORT TouchExplorationController |
| void SetEventHandlerForTesting(ui::EventHandler* event_handler_for_testing); |
| bool IsInNoFingersDownStateForTesting() const; |
| bool IsInGestureInProgressStateForTesting() const; |
| + bool IsInSlideGestureStateForTesting() const; |
| // VLOGs should be suppressed in tests that generate a lot of logs, |
| // for example permutations of nine touch events. |
| void SuppressVLOGsForTesting(bool suppress); |
| + gfx::Rect BoundsOfRootWindowInDIPForTesting(); |
| private: |
| // Overridden from ui::EventRewriter |
| @@ -141,6 +181,8 @@ class UI_CHROMEOS_EXPORT TouchExplorationController |
| const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| ui::EventRewriteStatus InWaitForRelease( |
| const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| + ui::EventRewriteStatus InSlideGesture( |
| + const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| // This timer is started every time we get the first press event, and |
| // it fires after the double-click timeout elapses (300 ms by default). |
| @@ -164,6 +206,8 @@ class UI_CHROMEOS_EXPORT TouchExplorationController |
| void OnSwipeEvent(ui::GestureEvent* swipe_gesture); |
| + void SideSlideControl(ui::GestureEvent* gesture); |
| + |
| // Dispatches the keyboard short cut Shift+Search+<arrow key> |
| // outside the event rewritting flow. |
| void DispatchShiftSearchKeyEvent(const ui::KeyboardCode direction); |
| @@ -177,6 +221,8 @@ class UI_CHROMEOS_EXPORT TouchExplorationController |
| // default value. |
| void ResetToNoFingersDown(); |
| + void PlaySoundForTimer(); |
| + |
| enum State { |
| // No fingers are down and no events are pending. |
| NO_FINGERS_DOWN, |
| @@ -243,8 +289,28 @@ class UI_CHROMEOS_EXPORT TouchExplorationController |
| // generally useful for developing new features, because it creates a |
| // simple way to handle a dead end in user flow. |
| WAIT_FOR_RELEASE, |
| + |
| + // If the user is within the given bounds from an edge of the screen, not |
| + // including corners, then the resulting movements will be interpreted as |
| + // slide gestures. |
| + SLIDE_GESTURE, |
| + }; |
| + |
| + enum ScreenLocation { |
| + // Hot "edges" of the screen are each represented by a respective bit. |
| + RIGHT_EDGE = 0x1, |
| + TOP_EDGE = 0x2, |
| + LEFT_EDGE = 0x4, |
| + BOTTOM_EDGE = 0x8, |
| + SCREEN_CENTER = 0x0, |
| }; |
| + // Given a point, if it is within the given bounds of an edge, returns the |
| + // edge. If it is within the given bounds of two edges, returns an int with |
| + // both bits that represent the respective edges turned on. Otherwise returns |
| + // SCREEN_CENTER. |
| + int WithinBoundsOfEdge(gfx::Point point, float bounds); |
| + |
| void VlogState(const char* function_name); |
| void VlogEvent(const ui::TouchEvent& event, const char* function_name); |
| @@ -254,6 +320,9 @@ class UI_CHROMEOS_EXPORT TouchExplorationController |
| aura::Window* root_window_; |
| + // Volume control. |
| + scoped_ptr<ui::TouchExplorationControllerDelegate> delegate_; |
| + |
| // A set of touch ids for fingers currently touching the screen. |
| std::vector<int> current_touch_ids_; |
| @@ -283,6 +352,9 @@ class UI_CHROMEOS_EXPORT TouchExplorationController |
| // A timer to fire the mouse move event after the double-tap delay. |
| base::OneShotTimer<TouchExplorationController> tap_timer_; |
| + // A timer to fire a indicating sound when sliding to change volume. |
| + base::RepeatingTimer<TouchExplorationController> sound_timer_; |
| + |
| // For testing only, an event handler to use for generated events |
| // outside of the normal event rewriting flow. |
| ui::EventHandler* event_handler_for_testing_; |