| 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 #ifndef UI_APP_LIST_PAGINATION_MODEL_H_ | 5 #ifndef UI_APP_LIST_PAGINATION_MODEL_H_ |
| 6 #define UI_APP_LIST_PAGINATION_MODEL_H_ | 6 #define UI_APP_LIST_PAGINATION_MODEL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 // Updates transition progress from |delta|. |delta| > 0 means transit to | 68 // Updates transition progress from |delta|. |delta| > 0 means transit to |
| 69 // previous page (moving pages to the right). |delta| < 0 means transit | 69 // previous page (moving pages to the right). |delta| < 0 means transit |
| 70 // to next page (moving pages to the left). | 70 // to next page (moving pages to the left). |
| 71 void UpdateScroll(double delta); | 71 void UpdateScroll(double delta); |
| 72 | 72 |
| 73 // Finishes the current scroll transition if |cancel| is false. Otherwise, | 73 // Finishes the current scroll transition if |cancel| is false. Otherwise, |
| 74 // reverses it. | 74 // reverses it. |
| 75 void EndScroll(bool cancel); | 75 void EndScroll(bool cancel); |
| 76 | 76 |
| 77 // Returns true if current transition is being reverted. |
| 78 bool IsRevertingCurrentTransition() const; |
| 79 |
| 77 void AddObserver(PaginationModelObserver* observer); | 80 void AddObserver(PaginationModelObserver* observer); |
| 78 void RemoveObserver(PaginationModelObserver* observer); | 81 void RemoveObserver(PaginationModelObserver* observer); |
| 79 | 82 |
| 80 int total_pages() const { return total_pages_; } | 83 int total_pages() const { return total_pages_; } |
| 81 int selected_page() const { return selected_page_; } | 84 int selected_page() const { return selected_page_; } |
| 82 const Transition& transition() const { return transition_; } | 85 const Transition& transition() const { return transition_; } |
| 83 bool scrolling() const { return scrolling_; } | |
| 84 | 86 |
| 85 bool is_valid_page(int page) const { | 87 bool is_valid_page(int page) const { |
| 86 return page >= 0 && page < total_pages_; | 88 return page >= 0 && page < total_pages_; |
| 87 } | 89 } |
| 88 | 90 |
| 89 bool has_transition() const { | 91 bool has_transition() const { |
| 90 return transition_.target_page != -1 || transition_.progress != 0; | 92 return transition_.target_page != -1 || transition_.progress != 0; |
| 91 } | 93 } |
| 92 | 94 |
| 93 private: | 95 private: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 112 | 114 |
| 113 // ui::AnimationDelegate overrides: | 115 // ui::AnimationDelegate overrides: |
| 114 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 116 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 115 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 117 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
| 116 | 118 |
| 117 int total_pages_; | 119 int total_pages_; |
| 118 int selected_page_; | 120 int selected_page_; |
| 119 | 121 |
| 120 Transition transition_; | 122 Transition transition_; |
| 121 | 123 |
| 122 bool scrolling_; // Whether a scroll is in progress. | |
| 123 | |
| 124 // Pending selected page when SelectedPage is called during a transition. If | 124 // Pending selected page when SelectedPage is called during a transition. If |
| 125 // multiple SelectPage is called while a transition is in progress, only the | 125 // multiple SelectPage is called while a transition is in progress, only the |
| 126 // last target page is remembered here. | 126 // last target page is remembered here. |
| 127 int pending_selected_page_; | 127 int pending_selected_page_; |
| 128 | 128 |
| 129 scoped_ptr<ui::SlideAnimation> transition_animation_; | 129 scoped_ptr<ui::SlideAnimation> transition_animation_; |
| 130 int transition_duration_ms_; // Transition duration in millisecond. | 130 int transition_duration_ms_; // Transition duration in millisecond. |
| 131 | 131 |
| 132 ObserverList<PaginationModelObserver> observers_; | 132 ObserverList<PaginationModelObserver> observers_; |
| 133 | 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(PaginationModel); | 134 DISALLOW_COPY_AND_ASSIGN(PaginationModel); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 } // namespace app_list | 137 } // namespace app_list |
| 138 | 138 |
| 139 #endif // UI_APP_LIST_PAGINATION_MODEL_H_ | 139 #endif // UI_APP_LIST_PAGINATION_MODEL_H_ |
| OLD | NEW |