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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // this is usually the previous or next page (or -1 when there is no | 42 // this is usually the previous or next page (or -1 when there is no |
43 // previous or next page). | 43 // previous or next page). |
44 int target_page; | 44 int target_page; |
45 | 45 |
46 // A [0, 1] progress indicates how much of the current page is being | 46 // A [0, 1] progress indicates how much of the current page is being |
47 // transitioned. | 47 // transitioned. |
48 double progress; | 48 double progress; |
49 }; | 49 }; |
50 | 50 |
51 PaginationModel(); | 51 PaginationModel(); |
52 virtual ~PaginationModel(); | 52 ~PaginationModel() override; |
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 | 62 // Immediately completes all queued animations, jumping directly to the final |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // If there is a transition, current page is the transition target page or the | 115 // If there is a transition, current page is the transition target page or the |
116 // pending transition target page. When current page + |delta| goes beyond | 116 // pending transition target page. When current page + |delta| goes beyond |
117 // valid range and |selected_page_| is at the range ends, invalid page number | 117 // valid range and |selected_page_| is at the range ends, invalid page number |
118 // -1 or |total_pages_| is returned to indicate the situation. | 118 // -1 or |total_pages_| is returned to indicate the situation. |
119 int CalculateTargetPage(int delta) const; | 119 int CalculateTargetPage(int delta) const; |
120 | 120 |
121 void StartTransitionAnimation(const Transition& transition); | 121 void StartTransitionAnimation(const Transition& transition); |
122 void ResetTransitionAnimation(); | 122 void ResetTransitionAnimation(); |
123 | 123 |
124 // gfx::AnimationDelegate overrides: | 124 // gfx::AnimationDelegate overrides: |
125 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 125 void AnimationProgressed(const gfx::Animation* animation) override; |
126 virtual void AnimationEnded(const gfx::Animation* animation) override; | 126 void AnimationEnded(const gfx::Animation* animation) override; |
127 | 127 |
128 int total_pages_; | 128 int total_pages_; |
129 int selected_page_; | 129 int selected_page_; |
130 | 130 |
131 Transition transition_; | 131 Transition transition_; |
132 | 132 |
133 // Pending selected page when SelectedPage is called during a transition. If | 133 // Pending selected page when SelectedPage is called during a transition. If |
134 // multiple SelectPage is called while a transition is in progress, only the | 134 // multiple SelectPage is called while a transition is in progress, only the |
135 // last target page is remembered here. | 135 // last target page is remembered here. |
136 int pending_selected_page_; | 136 int pending_selected_page_; |
137 | 137 |
138 scoped_ptr<gfx::SlideAnimation> transition_animation_; | 138 scoped_ptr<gfx::SlideAnimation> transition_animation_; |
139 int transition_duration_ms_; // Transition duration in millisecond. | 139 int transition_duration_ms_; // Transition duration in millisecond. |
140 int overscroll_transition_duration_ms_; | 140 int overscroll_transition_duration_ms_; |
141 | 141 |
142 int last_overscroll_target_page_; | 142 int last_overscroll_target_page_; |
143 base::TimeTicks last_overscroll_animation_start_time_; | 143 base::TimeTicks last_overscroll_animation_start_time_; |
144 | 144 |
145 ObserverList<PaginationModelObserver> observers_; | 145 ObserverList<PaginationModelObserver> observers_; |
146 | 146 |
147 DISALLOW_COPY_AND_ASSIGN(PaginationModel); | 147 DISALLOW_COPY_AND_ASSIGN(PaginationModel); |
148 }; | 148 }; |
149 | 149 |
150 } // namespace app_list | 150 } // namespace app_list |
151 | 151 |
152 #endif // UI_APP_LIST_PAGINATION_MODEL_H_ | 152 #endif // UI_APP_LIST_PAGINATION_MODEL_H_ |
OLD | NEW |