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/home/home_card_gesture_manager.h" | 5 #include "athena/home/home_card_gesture_manager.h" |
6 | 6 |
7 #include "athena/home/home_card_constants.h" | 7 #include "athena/home/home_card_constants.h" |
8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
9 | 9 |
10 namespace athena { | 10 namespace athena { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 float bigger_height = kHomeCardHeight; | 92 float bigger_height = kHomeCardHeight; |
93 if (last_estimated_height_ > kHomeCardHeight) { | 93 if (last_estimated_height_ > kHomeCardHeight) { |
94 state = HomeCard::VISIBLE_CENTERED; | 94 state = HomeCard::VISIBLE_CENTERED; |
95 smaller_height = kHomeCardHeight; | 95 smaller_height = kHomeCardHeight; |
96 bigger_height = screen_bounds_.height(); | 96 bigger_height = screen_bounds_.height(); |
97 } | 97 } |
98 | 98 |
99 // The finger is between two states. | 99 // The finger is between two states. |
100 float progress = (last_estimated_height_ - smaller_height) / | 100 float progress = (last_estimated_height_ - smaller_height) / |
101 (bigger_height - smaller_height); | 101 (bigger_height - smaller_height); |
| 102 progress = std::min(1.0f, std::max(0.0f, progress)); |
102 | 103 |
103 if (last_state_ == state) { | 104 if (last_state_ == state) { |
104 if (event.details().scroll_y() > 0) { | 105 if (event.details().scroll_y() > 0) { |
105 state = static_cast<HomeCard::State>(state + 1); | 106 state = static_cast<HomeCard::State>(state + 1); |
106 progress = 1.0f - progress; | 107 progress = 1.0f - progress; |
107 } else { | 108 } else { |
108 last_state_ = static_cast<HomeCard::State>(last_state_ + 1); | 109 last_state_ = static_cast<HomeCard::State>(last_state_ + 1); |
109 } | 110 } |
110 } | 111 } |
111 delegate_->OnGestureProgressed(last_state_, state, progress); | 112 delegate_->OnGestureProgressed(last_state_, state, progress); |
112 last_state_ = state; | 113 last_state_ = state; |
113 } | 114 } |
114 | 115 |
115 } // namespace athena | 116 } // namespace athena |
OLD | NEW |