| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef ATHENA_WM_BEZEL_CONTROLLER_H_ | |
| 6 #define ATHENA_WM_BEZEL_CONTROLLER_H_ | |
| 7 | |
| 8 #include "ui/events/event_handler.h" | |
| 9 | |
| 10 namespace aura { | |
| 11 class Window; | |
| 12 } | |
| 13 | |
| 14 namespace gfx { | |
| 15 class PointF; | |
| 16 } | |
| 17 | |
| 18 namespace ui { | |
| 19 class EventTarget; | |
| 20 } | |
| 21 | |
| 22 namespace athena { | |
| 23 | |
| 24 // Responsible for detecting bezel gestures and notifying the delegate(s) | |
| 25 // subscribed to them. | |
| 26 class BezelController : public ui::EventHandler { | |
| 27 public: | |
| 28 enum Bezel { BEZEL_NONE, BEZEL_LEFT, BEZEL_RIGHT, BEZEL_TOP, BEZEL_BOTTOM }; | |
| 29 | |
| 30 // Responsible for handling scroll gestures initiated from the bezel. | |
| 31 // Two touch points are need to perform the bezel scroll gesture from | |
| 32 // the left and right bezel. | |
| 33 class ScrollDelegate { | |
| 34 public: | |
| 35 ~ScrollDelegate() {} | |
| 36 | |
| 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. | |
| 40 virtual void BezelScrollBegin(Bezel bezel, float delta) = 0; | |
| 41 | |
| 42 // End of the current bezel scroll with velocity |velocity|. | |
| 43 virtual void BezelScrollEnd(float velocity) = 0; | |
| 44 | |
| 45 // Update of the scroll position for the currently active bezel scroll. | |
| 46 // |delta| has the same meaning as in ScrollBegin(). | |
| 47 virtual void BezelScrollUpdate(float delta) = 0; | |
| 48 | |
| 49 // Should return false if the delegate isn't going to react to the scroll | |
| 50 // events. | |
| 51 virtual bool BezelCanScroll() = 0; | |
| 52 }; | |
| 53 | |
| 54 explicit BezelController(aura::Window* container); | |
| 55 ~BezelController() override {} | |
| 56 | |
| 57 // Set the delegate to handle the gestures from left and right bezels. | |
| 58 // Two touch points are need to perform the bezel scroll gesture from | |
| 59 // the left and right bezel. | |
| 60 void set_left_right_delegate(ScrollDelegate* delegate) { | |
| 61 left_right_delegate_ = delegate; | |
| 62 } | |
| 63 | |
| 64 private: | |
| 65 enum State { | |
| 66 NONE, | |
| 67 IGNORE_CURRENT_SCROLL, | |
| 68 BEZEL_GESTURE_STARTED, | |
| 69 BEZEL_SCROLLING_ONE_FINGER, | |
| 70 BEZEL_SCROLLING_TWO_FINGERS, | |
| 71 }; | |
| 72 | |
| 73 void SetState(State state); | |
| 74 // |scroll_delta| only needs to be passed when |state| is one of the | |
| 75 // BEZEL_SROLLING states. | |
| 76 void SetState(State state, float scroll_delta); | |
| 77 | |
| 78 // ui::EventHandler overrides | |
| 79 void OnGestureEvent(ui::GestureEvent* event) override; | |
| 80 | |
| 81 aura::Window* container_; | |
| 82 | |
| 83 State state_; | |
| 84 | |
| 85 // The bezel where the currently active scroll was started. | |
| 86 Bezel scroll_bezel_; | |
| 87 | |
| 88 // The target of the bezel scroll gesture. Used to filter out other gestures | |
| 89 // when the bezel scroll is in progress. | |
| 90 ui::EventTarget* scroll_target_; | |
| 91 | |
| 92 // Responsible for handling gestures started from the left and right bezels. | |
| 93 // Not owned. | |
| 94 ScrollDelegate* left_right_delegate_; | |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(BezelController); | |
| 97 }; | |
| 98 | |
| 99 } // namespace athena | |
| 100 | |
| 101 #endif // ATHENA_WM_BEZEL_CONTROLLER_H_ | |
| OLD | NEW |