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 #include "athena/wm/bezel_controller.h" | 5 #include "athena/wm/bezel_controller.h" |
6 | 6 |
7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
8 #include "ui/events/event_handler.h" | 8 #include "ui/events/event_handler.h" |
9 #include "ui/gfx/display.h" | 9 #include "ui/gfx/display.h" |
10 #include "ui/gfx/geometry/point_conversions.h" | 10 #include "ui/gfx/geometry/point_conversions.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return BezelController::BEZEL_RIGHT; | 60 return BezelController::BEZEL_RIGHT; |
61 return BezelController::BEZEL_NONE; | 61 return BezelController::BEZEL_NONE; |
62 } | 62 } |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 BezelController::BezelController(aura::Window* container) | 66 BezelController::BezelController(aura::Window* container) |
67 : container_(container), | 67 : container_(container), |
68 state_(NONE), | 68 state_(NONE), |
69 scroll_bezel_(BEZEL_NONE), | 69 scroll_bezel_(BEZEL_NONE), |
70 scroll_target_(NULL), | 70 scroll_target_(nullptr), |
71 left_right_delegate_(NULL) { | 71 left_right_delegate_(nullptr) { |
72 } | 72 } |
73 | 73 |
74 void BezelController::SetState(BezelController::State state) { | 74 void BezelController::SetState(BezelController::State state) { |
75 // Use SetState(State, float) if |state| is one of the BEZEL_SCROLLING states. | 75 // Use SetState(State, float) if |state| is one of the BEZEL_SCROLLING states. |
76 DCHECK_NE(state, BEZEL_SCROLLING_TWO_FINGERS); | 76 DCHECK_NE(state, BEZEL_SCROLLING_TWO_FINGERS); |
77 DCHECK_NE(state, BEZEL_SCROLLING_ONE_FINGER); | 77 DCHECK_NE(state, BEZEL_SCROLLING_ONE_FINGER); |
78 SetState(state, kScrollDeltaNone); | 78 SetState(state, kScrollDeltaNone); |
79 } | 79 } |
80 | 80 |
81 void BezelController::SetState(BezelController::State state, | 81 void BezelController::SetState(BezelController::State state, |
82 float scroll_delta) { | 82 float scroll_delta) { |
83 if (!left_right_delegate_ || state == state_) | 83 if (!left_right_delegate_ || state == state_) |
84 return; | 84 return; |
85 | 85 |
86 State old_state = state_; | 86 State old_state = state_; |
87 state_ = state; | 87 state_ = state; |
88 | 88 |
89 if (state == NONE) { | 89 if (state == NONE) { |
90 scroll_bezel_ = BEZEL_NONE; | 90 scroll_bezel_ = BEZEL_NONE; |
91 scroll_target_ = NULL; | 91 scroll_target_ = nullptr; |
92 } | 92 } |
93 | 93 |
94 if (state == BEZEL_SCROLLING_TWO_FINGERS) { | 94 if (state == BEZEL_SCROLLING_TWO_FINGERS) { |
95 left_right_delegate_->BezelScrollBegin(scroll_bezel_, scroll_delta); | 95 left_right_delegate_->BezelScrollBegin(scroll_bezel_, scroll_delta); |
96 } else if (old_state == BEZEL_SCROLLING_TWO_FINGERS) { | 96 } else if (old_state == BEZEL_SCROLLING_TWO_FINGERS) { |
97 // If BezelScrollEnd() hides |scroll_target_|, ET_GESTURE_END is dispatched | 97 // If BezelScrollEnd() hides |scroll_target_|, ET_GESTURE_END is dispatched |
98 // and we get a reentrant call to SetState(). | 98 // and we get a reentrant call to SetState(). |
99 left_right_delegate_->BezelScrollEnd(0.0f); | 99 left_right_delegate_->BezelScrollEnd(0.0f); |
100 } | 100 } |
101 } | 101 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (state_ != BEZEL_SCROLLING_TWO_FINGERS) | 200 if (state_ != BEZEL_SCROLLING_TWO_FINGERS) |
201 return; | 201 return; |
202 | 202 |
203 left_right_delegate_->BezelScrollUpdate(scroll_delta); | 203 left_right_delegate_->BezelScrollUpdate(scroll_delta); |
204 if (left_right_delegate_->BezelCanScroll()) | 204 if (left_right_delegate_->BezelCanScroll()) |
205 event->SetHandled(); | 205 event->SetHandled(); |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 } // namespace athena | 209 } // namespace athena |
OLD | NEW |