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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 virtual ~PaginationModel(); | 52 virtual ~PaginationModel(); |
53 | 53 |
54 void SetTotalPages(int total_pages); | 54 void SetTotalPages(int total_pages); |
55 | 55 |
56 // Selects a page. |animate| is true if the transition should be animated. | 56 // Selects a page. |animate| is true if the transition should be animated. |
57 void SelectPage(int page, bool animate); | 57 void SelectPage(int page, bool animate); |
58 | 58 |
59 // Selects a page by relative |delta|. | 59 // Selects a page by relative |delta|. |
60 void SelectPageRelative(int delta, bool animate); | 60 void SelectPageRelative(int delta, bool animate); |
61 | 61 |
| 62 // Immediately completes all queued animations, jumping directly to the final |
| 63 // target page. |
| 64 void FinishAnimation(); |
| 65 |
62 void SetTransition(const Transition& transition); | 66 void SetTransition(const Transition& transition); |
63 void SetTransitionDurations(int duration_ms, int overscroll_duration_ms); | 67 void SetTransitionDurations(int duration_ms, int overscroll_duration_ms); |
64 | 68 |
65 // Starts a scroll transition. If there is a running transition animation, | 69 // Starts a scroll transition. If there is a running transition animation, |
66 // cancels it but keeps the transition info. | 70 // cancels it but keeps the transition info. |
67 void StartScroll(); | 71 void StartScroll(); |
68 | 72 |
69 // Updates transition progress from |delta|. |delta| > 0 means transit to | 73 // Updates transition progress from |delta|. |delta| > 0 means transit to |
70 // previous page (moving pages to the right). |delta| < 0 means transit | 74 // previous page (moving pages to the right). |delta| < 0 means transit |
71 // to next page (moving pages to the left). | 75 // to next page (moving pages to the left). |
(...skipping 14 matching lines...) Expand all Loading... |
86 const Transition& transition() const { return transition_; } | 90 const Transition& transition() const { return transition_; } |
87 | 91 |
88 bool is_valid_page(int page) const { | 92 bool is_valid_page(int page) const { |
89 return page >= 0 && page < total_pages_; | 93 return page >= 0 && page < total_pages_; |
90 } | 94 } |
91 | 95 |
92 bool has_transition() const { | 96 bool has_transition() const { |
93 return transition_.target_page != -1 || transition_.progress != 0; | 97 return transition_.target_page != -1 || transition_.progress != 0; |
94 } | 98 } |
95 | 99 |
| 100 // Gets the page that the animation will eventually land on. If there is no |
| 101 // active animation, just returns selected_page(). |
| 102 int SelectedTargetPage() const; |
| 103 |
96 private: | 104 private: |
97 void NotifySelectedPageChanged(int old_selected, int new_selected); | 105 void NotifySelectedPageChanged(int old_selected, int new_selected); |
98 void NotifyTransitionStarted(); | 106 void NotifyTransitionStarted(); |
99 void NotifyTransitionChanged(); | 107 void NotifyTransitionChanged(); |
100 | 108 |
101 void clear_transition() { | 109 void clear_transition() { |
102 SetTransition(Transition(-1, 0)); | 110 SetTransition(Transition(-1, 0)); |
103 } | 111 } |
104 | 112 |
105 // Calculates a target page number by combining current page and |delta|. | 113 // Calculates a target page number by combining current page and |delta|. |
(...skipping 29 matching lines...) Expand all Loading... |
135 base::TimeTicks last_overscroll_animation_start_time_; | 143 base::TimeTicks last_overscroll_animation_start_time_; |
136 | 144 |
137 ObserverList<PaginationModelObserver> observers_; | 145 ObserverList<PaginationModelObserver> observers_; |
138 | 146 |
139 DISALLOW_COPY_AND_ASSIGN(PaginationModel); | 147 DISALLOW_COPY_AND_ASSIGN(PaginationModel); |
140 }; | 148 }; |
141 | 149 |
142 } // namespace app_list | 150 } // namespace app_list |
143 | 151 |
144 #endif // UI_APP_LIST_PAGINATION_MODEL_H_ | 152 #endif // UI_APP_LIST_PAGINATION_MODEL_H_ |
OLD | NEW |