Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: ui/app_list/pagination_model.cc

Issue 10961020: cros: Fix mouse over-scroll animation not happening. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix jumping around when mouse is hovering on an item Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/app_list/pagination_model.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 11
12 namespace app_list { 12 namespace app_list {
13 13
14 PaginationModel::PaginationModel() 14 PaginationModel::PaginationModel()
15 : total_pages_(-1), 15 : total_pages_(-1),
16 selected_page_(-1), 16 selected_page_(-1),
17 transition_(-1, 0), 17 transition_(-1, 0),
18 scrolling_(false),
19 pending_selected_page_(-1), 18 pending_selected_page_(-1),
20 transition_duration_ms_(0) { 19 transition_duration_ms_(0) {
21 } 20 }
22 21
23 PaginationModel::~PaginationModel() { 22 PaginationModel::~PaginationModel() {
24 } 23 }
25 24
26 void PaginationModel::SetTotalPages(int total_pages) { 25 void PaginationModel::SetTotalPages(int total_pages) {
27 if (total_pages == total_pages_) 26 if (total_pages == total_pages_)
28 return; 27 return;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 93
95 transition_ = transition; 94 transition_ = transition;
96 NotifyTransitionChanged(); 95 NotifyTransitionChanged();
97 } 96 }
98 97
99 void PaginationModel::SetTransitionDuration(int duration_ms) { 98 void PaginationModel::SetTransitionDuration(int duration_ms) {
100 transition_duration_ms_ = duration_ms; 99 transition_duration_ms_ = duration_ms;
101 } 100 }
102 101
103 void PaginationModel::StartScroll() { 102 void PaginationModel::StartScroll() {
104 scrolling_ = true;
105 // Cancels current transition animation (if any). 103 // Cancels current transition animation (if any).
106 transition_animation_.reset(); 104 transition_animation_.reset();
107 } 105 }
108 106
109 void PaginationModel::UpdateScroll(double delta) { 107 void PaginationModel::UpdateScroll(double delta) {
110 // Translates scroll delta to desired page change direction. 108 // Translates scroll delta to desired page change direction.
111 int page_change_dir = delta > 0 ? -1 : 1; 109 int page_change_dir = delta > 0 ? -1 : 1;
112 110
113 // Initializes a transition if there is none. 111 // Initializes a transition if there is none.
114 if (!has_transition()) 112 if (!has_transition())
(...skipping 11 matching lines...) Expand all
126 SelectPage(transition_.target_page, false); 124 SelectPage(transition_.target_page, false);
127 clear_transition(); 125 clear_transition();
128 } 126 }
129 } else { 127 } else {
130 transition_.progress = progress; 128 transition_.progress = progress;
131 NotifyTransitionChanged(); 129 NotifyTransitionChanged();
132 } 130 }
133 } 131 }
134 132
135 void PaginationModel::EndScroll(bool cancel) { 133 void PaginationModel::EndScroll(bool cancel) {
136 scrolling_ = false;
137
138 if (!has_transition()) 134 if (!has_transition())
139 return; 135 return;
140 136
141 CreateTransitionAnimation(); 137 CreateTransitionAnimation();
142 transition_animation_->Reset(transition_.progress); 138 transition_animation_->Reset(transition_.progress);
143 139
144 // Always call Show to ensure animation will run. 140 // Always call Show to ensure animation will run.
145 transition_animation_->Show(); 141 transition_animation_->Show();
146 if (cancel) 142 if (cancel)
147 transition_animation_->Hide(); 143 transition_animation_->Hide();
148 } 144 }
149 145
146 bool PaginationModel::IsRevertingCurrentTransition() const {
147 return transition_animation_.get() && transition_animation_->IsClosing();
148 }
149
150 void PaginationModel::AddObserver(PaginationModelObserver* observer) { 150 void PaginationModel::AddObserver(PaginationModelObserver* observer) {
151 observers_.AddObserver(observer); 151 observers_.AddObserver(observer);
152 } 152 }
153 153
154 void PaginationModel::RemoveObserver(PaginationModelObserver* observer) { 154 void PaginationModel::RemoveObserver(PaginationModelObserver* observer) {
155 observers_.RemoveObserver(observer); 155 observers_.RemoveObserver(observer);
156 } 156 }
157 157
158 void PaginationModel::NotifySelectedPageChanged(int old_selected, 158 void PaginationModel::NotifySelectedPageChanged(int old_selected,
159 int new_selected) { 159 int new_selected) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } else if (transition_animation_->GetCurrentValue() == 0) { 236 } else if (transition_animation_->GetCurrentValue() == 0) {
237 // Hiding animation ends. No page change should happen. 237 // Hiding animation ends. No page change should happen.
238 ResetTransitionAnimation(); 238 ResetTransitionAnimation();
239 } 239 }
240 240
241 if (next_target >= 0) 241 if (next_target >= 0)
242 SelectPage(next_target, true); 242 SelectPage(next_target, true);
243 } 243 }
244 244
245 } // namespace app_list 245 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/pagination_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698