| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/app_list/pagination_model.h" | 5 #include "ui/app_list/pagination_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/app_list/pagination_model_observer.h" | 9 #include "ui/app_list/pagination_model_observer.h" |
| 10 #include "ui/base/animation/slide_animation.h" | 10 #include "ui/base/animation/slide_animation.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 void PaginationModel::SetTotalPages(int total_pages) { | 25 void PaginationModel::SetTotalPages(int total_pages) { |
| 26 if (total_pages == total_pages_) | 26 if (total_pages == total_pages_) |
| 27 return; | 27 return; |
| 28 | 28 |
| 29 total_pages_ = total_pages; | 29 total_pages_ = total_pages; |
| 30 if (selected_page_ < 0) | 30 if (selected_page_ < 0) |
| 31 SelectPage(0, false /* animate */); | 31 SelectPage(0, false /* animate */); |
| 32 if (selected_page_ >= total_pages_) | 32 if (selected_page_ >= total_pages_) |
| 33 SelectPage(total_pages_ - 1, false /* animate */); | 33 SelectPage(total_pages_ - 1, false /* animate */); |
| 34 FOR_EACH_OBSERVER(PaginationModelObserver, | 34 FOR_EACH_OBSERVER(PaginationModelObserver, observers_, TotalPagesChanged()); |
| 35 observers_, | |
| 36 TotalPagesChanged()); | |
| 37 } | 35 } |
| 38 | 36 |
| 39 void PaginationModel::SelectPage(int page, bool animate) { | 37 void PaginationModel::SelectPage(int page, bool animate) { |
| 40 if (animate) { | 38 if (animate) { |
| 41 // -1 and |total_pages_| are valid target page for animation. | 39 // -1 and |total_pages_| are valid target page for animation. |
| 42 DCHECK(page >= -1 && page <= total_pages_); | 40 DCHECK(page >= -1 && page <= total_pages_); |
| 43 | 41 |
| 44 if (!transition_animation_.get()) { | 42 if (!transition_animation_.get()) { |
| 45 if (page == selected_page_) | 43 if (page == selected_page_) |
| 46 return; | 44 return; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } else if (transition_animation_->GetCurrentValue() == 0) { | 217 } else if (transition_animation_->GetCurrentValue() == 0) { |
| 220 // Hiding animation ends. No page change should happen. | 218 // Hiding animation ends. No page change should happen. |
| 221 ResetTranstionAnimation(); | 219 ResetTranstionAnimation(); |
| 222 } | 220 } |
| 223 | 221 |
| 224 if (next_target >= 0) | 222 if (next_target >= 0) |
| 225 SelectPage(next_target, true); | 223 SelectPage(next_target, true); |
| 226 } | 224 } |
| 227 | 225 |
| 228 } // namespace app_list | 226 } // namespace app_list |
| OLD | NEW |