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

Side by Side Diff: chrome/browser/views/download_shelf_view.cc

Issue 1961001: Refactors animation to allow for cleaner subclassing. I'm doing this (Closed)
Patch Set: Incorporated review feedback Created 10 years, 7 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/views/download_shelf_view.h" 5 #include "chrome/browser/views/download_shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 gfx::Size DownloadShelfView::GetPreferredSize() { 158 gfx::Size DownloadShelfView::GetPreferredSize() {
159 gfx::Size prefsize(kRightPadding + kLeftPadding + kCloseAndLinkPadding, 0); 159 gfx::Size prefsize(kRightPadding + kLeftPadding + kCloseAndLinkPadding, 0);
160 AdjustSize(close_button_, &prefsize); 160 AdjustSize(close_button_, &prefsize);
161 AdjustSize(show_all_view_, &prefsize); 161 AdjustSize(show_all_view_, &prefsize);
162 // Add one download view to the preferred size. 162 // Add one download view to the preferred size.
163 if (download_views_.size() > 0) { 163 if (download_views_.size() > 0) {
164 AdjustSize(*download_views_.begin(), &prefsize); 164 AdjustSize(*download_views_.begin(), &prefsize);
165 prefsize.Enlarge(kDownloadPadding, 0); 165 prefsize.Enlarge(kDownloadPadding, 0);
166 } 166 }
167 prefsize.Enlarge(0, kTopBottomPadding + kTopBottomPadding); 167 prefsize.Enlarge(0, kTopBottomPadding + kTopBottomPadding);
168 if (shelf_animation_->IsAnimating()) { 168 if (shelf_animation_->is_animating()) {
169 prefsize.set_height(static_cast<int>( 169 prefsize.set_height(static_cast<int>(
170 static_cast<double>(prefsize.height()) * 170 static_cast<double>(prefsize.height()) *
171 shelf_animation_->GetCurrentValue())); 171 shelf_animation_->GetCurrentValue()));
172 } 172 }
173 return prefsize; 173 return prefsize;
174 } 174 }
175 175
176 void DownloadShelfView::AnimationProgressed(const Animation *animation) { 176 void DownloadShelfView::AnimationProgressed(const Animation *animation) {
177 if (animation == new_item_animation_.get()) { 177 if (animation == new_item_animation_.get()) {
178 Layout(); 178 Layout();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 next_x = kLeftPadding; 246 next_x = kLeftPadding;
247 std::vector<DownloadItemView*>::reverse_iterator ri; 247 std::vector<DownloadItemView*>::reverse_iterator ri;
248 for (ri = download_views_.rbegin(); ri != download_views_.rend(); ++ri) { 248 for (ri = download_views_.rbegin(); ri != download_views_.rend(); ++ri) {
249 gfx::Size view_size = (*ri)->GetPreferredSize(); 249 gfx::Size view_size = (*ri)->GetPreferredSize();
250 250
251 int x = next_x; 251 int x = next_x;
252 252
253 // Figure out width of item. 253 // Figure out width of item.
254 int item_width = view_size.width(); 254 int item_width = view_size.width();
255 if (new_item_animation_->IsAnimating() && ri == download_views_.rbegin()) { 255 if (new_item_animation_->is_animating() && ri == download_views_.rbegin()) {
256 item_width = static_cast<int>(static_cast<double>(view_size.width()) * 256 item_width = static_cast<int>(static_cast<double>(view_size.width()) *
257 new_item_animation_->GetCurrentValue()); 257 new_item_animation_->GetCurrentValue());
258 } 258 }
259 259
260 next_x += item_width; 260 next_x += item_width;
261 261
262 // Make sure our item can be contained within the shelf. 262 // Make sure our item can be contained within the shelf.
263 if (next_x < max_download_x) { 263 if (next_x < max_download_x) {
264 (*ri)->SetVisible(true); 264 (*ri)->SetVisible(true);
265 (*ri)->SetBounds(x, CenterPosition(view_size.height(), height()), 265 (*ri)->SetBounds(x, CenterPosition(view_size.height(), height()),
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 bool is_transfer_done = download->state() == DownloadItem::COMPLETE || 339 bool is_transfer_done = download->state() == DownloadItem::COMPLETE ||
340 download->state() == DownloadItem::CANCELLED; 340 download->state() == DownloadItem::CANCELLED;
341 if (is_transfer_done && 341 if (is_transfer_done &&
342 download->safety_state() != DownloadItem::DANGEROUS) { 342 download->safety_state() != DownloadItem::DANGEROUS) {
343 RemoveDownloadView(download_views_[i]); 343 RemoveDownloadView(download_views_[i]);
344 } else { 344 } else {
345 ++i; 345 ++i;
346 } 346 }
347 } 347 }
348 } 348 }
OLDNEW
« no previous file with comments | « chrome/browser/views/download_item_view.cc ('k') | chrome/browser/views/download_started_animation_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698