Chromium Code Reviews| 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/public/home_card.h" | 5 #include "athena/home/public/home_card.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "athena/common/container_priorities.h" | 10 #include "athena/common/container_priorities.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 } | 178 } |
| 179 break; | 179 break; |
| 180 } | 180 } |
| 181 default: | 181 default: |
| 182 // do nothing. | 182 // do nothing. |
| 183 break; | 183 break; |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 private: | 187 private: |
| 188 HomeCard::State GetClosestState() { | 188 HomeCard::State GetClosestState() { |
|
oshima
2014/08/24 02:22:45
can this be const?
and document this method.
Jun Mukai
2014/08/24 02:27:31
actually I have another CL https://codereview.chro
| |
| 189 // The top position of the bounds for one smaller state than the current | 189 // The top position of the bounds for one smaller state than the current |
| 190 // one. | 190 // one. |
| 191 int smaller_top = -1; | 191 int smaller_top = -1; |
| 192 for (int i = HomeCard::VISIBLE_MINIMIZED; | 192 for (int i = HomeCard::VISIBLE_MINIMIZED; |
| 193 i >= HomeCard::VISIBLE_CENTERED; --i) { | 193 i >= HomeCard::VISIBLE_CENTERED; --i) { |
| 194 HomeCard::State state = static_cast<HomeCard::State>(i); | 194 HomeCard::State state = static_cast<HomeCard::State>(i); |
| 195 int top = GetBoundsForState(screen_bounds_, state).y(); | 195 int top = GetBoundsForState(screen_bounds_, state).y(); |
| 196 if (last_estimated_top_ == top) { | 196 if (last_estimated_top_ == top) { |
| 197 return state; | 197 return state; |
| 198 } else if (last_estimated_top_ > top) { | 198 } else if (last_estimated_top_ > top) { |
| 199 if (smaller_top < 0) | 199 if (smaller_top < 0) |
| 200 return state; | 200 return state; |
| 201 | 201 |
| 202 if (smaller_top - last_estimated_top_ > (smaller_top - top) / 5) { | 202 if (smaller_top - last_estimated_top_ > (smaller_top - top) / 5) { |
| 203 return state; | 203 return state; |
| 204 } else { | 204 } else { |
| 205 return static_cast<HomeCard::State>(i + 1); | 205 return static_cast<HomeCard::State>(i + 1); |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 smaller_top = top; | 208 smaller_top = top; |
| 209 } | 209 } |
| 210 | 210 |
| 211 NOTREACHED(); | |
| 212 return last_state_; | 211 return last_state_; |
| 213 } | 212 } |
| 214 | 213 |
| 215 void UpdateScrollState(const ui::GestureEvent& event) { | 214 void UpdateScrollState(const ui::GestureEvent& event) { |
| 216 last_estimated_top_ = event.root_location().y() - y_offset_; | 215 last_estimated_top_ = event.root_location().y() - y_offset_; |
| 217 | 216 |
| 218 // The bounds which is at one smaller state than the current one. | 217 // The bounds which is at one smaller state than the current one. |
| 219 gfx::Rect smaller_bounds; | 218 gfx::Rect smaller_bounds; |
| 220 | 219 |
| 221 for (int i = HomeCard::VISIBLE_MINIMIZED; | 220 for (int i = HomeCard::VISIBLE_MINIMIZED; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 243 last_state_ = static_cast<HomeCard::State>(last_state_ + 1); | 242 last_state_ = static_cast<HomeCard::State>(last_state_ + 1); |
| 244 } | 243 } |
| 245 } | 244 } |
| 246 delegate_->OnGestureProgressed(last_state_, state, progress); | 245 delegate_->OnGestureProgressed(last_state_, state, progress); |
| 247 } | 246 } |
| 248 last_state_ = state; | 247 last_state_ = state; |
| 249 return; | 248 return; |
| 250 } | 249 } |
| 251 smaller_bounds = bounds; | 250 smaller_bounds = bounds; |
| 252 } | 251 } |
| 253 NOTREACHED(); | |
| 254 } | 252 } |
| 255 | 253 |
| 256 Delegate* delegate_; | 254 Delegate* delegate_; |
| 257 HomeCard::State last_state_; | 255 HomeCard::State last_state_; |
| 258 | 256 |
| 259 // The offset from the top edge of the home card and the initial position of | 257 // The offset from the top edge of the home card and the initial position of |
| 260 // gesture. | 258 // gesture. |
| 261 int y_offset_; | 259 int y_offset_; |
| 262 | 260 |
| 263 // The estimated top edge of the home card after the last touch event. | 261 // The estimated top edge of the home card after the last touch event. |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 659 instance = NULL; | 657 instance = NULL; |
| 660 } | 658 } |
| 661 | 659 |
| 662 // static | 660 // static |
| 663 HomeCard* HomeCard::Get() { | 661 HomeCard* HomeCard::Get() { |
| 664 DCHECK(instance); | 662 DCHECK(instance); |
| 665 return instance; | 663 return instance; |
| 666 } | 664 } |
| 667 | 665 |
| 668 } // namespace athena | 666 } // namespace athena |
| OLD | NEW |