| 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 ATHENA_WM_BEZEL_CONTROLLER_H_ | 5 #ifndef ATHENA_WM_BEZEL_CONTROLLER_H_ |
| 6 #define ATHENA_WM_BEZEL_CONTROLLER_H_ | 6 #define ATHENA_WM_BEZEL_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ui/events/event_handler.h" | 8 #include "ui/events/event_handler.h" |
| 9 | 9 |
| 10 namespace aura { | 10 namespace aura { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 enum Bezel { BEZEL_NONE, BEZEL_LEFT, BEZEL_RIGHT, BEZEL_TOP, BEZEL_BOTTOM }; | 28 enum Bezel { BEZEL_NONE, BEZEL_LEFT, BEZEL_RIGHT, BEZEL_TOP, BEZEL_BOTTOM }; |
| 29 | 29 |
| 30 // Responsible for handling scroll gestures initiated from the bezel. | 30 // Responsible for handling scroll gestures initiated from the bezel. |
| 31 // Two touch points are need to perform the bezel scroll gesture from | 31 // Two touch points are need to perform the bezel scroll gesture from |
| 32 // the left and right bezel. | 32 // the left and right bezel. |
| 33 class ScrollDelegate { | 33 class ScrollDelegate { |
| 34 public: | 34 public: |
| 35 virtual ~ScrollDelegate() {} | 35 virtual ~ScrollDelegate() {} |
| 36 | 36 |
| 37 // Beginning of a bezel scroll gesture started from the |bezel|. | 37 // Beginning of a bezel scroll gesture started from the |bezel|. |
| 38 // |delta| is the difference between the x-coordinate of the current scroll |
| 39 // position and the bezel. It will be zero or negative for the right bezel. |
| 38 virtual void ScrollBegin(Bezel bezel, float delta) = 0; | 40 virtual void ScrollBegin(Bezel bezel, float delta) = 0; |
| 39 | 41 |
| 40 // End of the current bezel scroll | 42 // End of the current bezel scroll |
| 41 virtual void ScrollEnd() = 0; | 43 virtual void ScrollEnd() = 0; |
| 42 | 44 |
| 43 // Update of the scroll position for the currently active bezel scroll. | 45 // Update of the scroll position for the currently active bezel scroll. |
| 46 // |delta| has the same meaning as in ScrollBegin(). |
| 44 virtual void ScrollUpdate(float delta) = 0; | 47 virtual void ScrollUpdate(float delta) = 0; |
| 45 | 48 |
| 46 // Should return false if the delegate isn't going to react to the scroll | 49 // Should return false if the delegate isn't going to react to the scroll |
| 47 // events. | 50 // events. |
| 48 virtual bool CanScroll() = 0; | 51 virtual bool CanScroll() = 0; |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 explicit BezelController(aura::Window* container); | 54 explicit BezelController(aura::Window* container); |
| 52 virtual ~BezelController() {} | 55 virtual ~BezelController() {} |
| 53 | 56 |
| 54 // Set the delegate to handle the gestures from left and right bezels. | 57 // Set the delegate to handle the gestures from left and right bezels. |
| 55 // Two touch points are need to perform the bezel scroll gesture from | 58 // Two touch points are need to perform the bezel scroll gesture from |
| 56 // the left and right bezel. | 59 // the left and right bezel. |
| 57 void set_left_right_delegate(ScrollDelegate* delegate) { | 60 void set_left_right_delegate(ScrollDelegate* delegate) { |
| 58 left_right_delegate_ = delegate; | 61 left_right_delegate_ = delegate; |
| 59 } | 62 } |
| 60 | 63 |
| 61 private: | 64 private: |
| 62 enum State { | 65 enum State { |
| 63 NONE, | 66 NONE, |
| 64 IGNORE_CURRENT_SCROLL, | 67 IGNORE_CURRENT_SCROLL, |
| 65 BEZEL_GESTURE_STARTED, | 68 BEZEL_GESTURE_STARTED, |
| 66 BEZEL_SCROLLING_ONE_FINGER, | 69 BEZEL_SCROLLING_ONE_FINGER, |
| 67 BEZEL_SCROLLING_TWO_FINGERS, | 70 BEZEL_SCROLLING_TWO_FINGERS, |
| 68 }; | 71 }; |
| 69 | 72 |
| 70 // Calculates the distance from |position| to the |bezel|. | 73 void SetState(State state); |
| 71 float GetDistance(const gfx::PointF& position, Bezel bezel); | 74 // |scroll_delta| only needs to be passed when |state| is one of the |
| 72 | 75 // BEZEL_SROLLING states. |
| 73 // |scroll_position| only needs to be passed in the scrolling state | 76 void SetState(State state, float scroll_delta); |
| 74 void SetState(State state, const gfx::PointF& scroll_position); | |
| 75 | 77 |
| 76 // Returns the bezel corresponding to the |location| or BEZEL_NONE if the | 78 // Returns the bezel corresponding to the |location| or BEZEL_NONE if the |
| 77 // location is outside of the bezel area. | 79 // location is outside of the bezel area. |
| 78 Bezel GetBezel(const gfx::PointF& location); | 80 Bezel GetBezel(const gfx::PointF& location); |
| 79 | 81 |
| 80 // ui::EventHandler overrides | 82 // ui::EventHandler overrides |
| 81 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 83 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 82 | 84 |
| 83 aura::Window* container_; | 85 aura::Window* container_; |
| 84 | 86 |
| 85 State state_; | 87 State state_; |
| 86 | 88 |
| 87 // The bezel where the currently active scroll was started. | 89 // The bezel where the currently active scroll was started. |
| 88 Bezel scroll_bezel_; | 90 Bezel scroll_bezel_; |
| 89 | 91 |
| 90 // The target of the bezel scroll gesture. Used to filter out other gestures | 92 // The target of the bezel scroll gesture. Used to filter out other gestures |
| 91 // when the bezel scroll is in progress. | 93 // when the bezel scroll is in progress. |
| 92 ui::EventTarget* scroll_target_; | 94 ui::EventTarget* scroll_target_; |
| 93 | 95 |
| 94 // Responsible for handling gestures started from the left and right bezels. | 96 // Responsible for handling gestures started from the left and right bezels. |
| 95 // Not owned. | 97 // Not owned. |
| 96 ScrollDelegate* left_right_delegate_; | 98 ScrollDelegate* left_right_delegate_; |
| 97 | 99 |
| 98 DISALLOW_COPY_AND_ASSIGN(BezelController); | 100 DISALLOW_COPY_AND_ASSIGN(BezelController); |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 } // namespace athena | 103 } // namespace athena |
| 102 | 104 |
| 103 #endif // ATHENA_WM_BEZEL_CONTROLLER_H_ | 105 #endif // ATHENA_WM_BEZEL_CONTROLLER_H_ |
| OLD | NEW |