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

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

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 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
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 "chrome/browser/ui/views/download/download_shelf_view.h" 5 #include "chrome/browser/ui/views/download/download_shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/download/download_item_model.h" 12 #include "chrome/browser/download/download_item_model.h"
13 #include "chrome/browser/download/download_stats.h" 13 #include "chrome/browser/download/download_stats.h"
14 #include "chrome/browser/themes/theme_properties.h" 14 #include "chrome/browser/themes/theme_properties.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/chrome_pages.h" 16 #include "chrome/browser/ui/chrome_pages.h"
17 #include "chrome/browser/ui/view_ids.h" 17 #include "chrome/browser/ui/view_ids.h"
18 #include "chrome/browser/ui/views/download/download_item_view.h" 18 #include "chrome/browser/ui/views/download/download_item_view.h"
19 #include "chrome/browser/ui/views/frame/browser_view.h" 19 #include "chrome/browser/ui/views/frame/browser_view.h"
20 #include "content/public/browser/download_item.h" 20 #include "content/public/browser/download_item.h"
21 #include "content/public/browser/download_manager.h" 21 #include "content/public/browser/download_manager.h"
22 #include "content/public/browser/page_navigator.h" 22 #include "content/public/browser/page_navigator.h"
23 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
24 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
25 #include "grit/ui_resources.h" 25 #include "grit/ui_resources.h"
26 #include "ui/base/animation/slide_animation.h"
27 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
29 #include "ui/base/theme_provider.h" 28 #include "ui/base/theme_provider.h"
29 #include "ui/gfx/animation/slide_animation.h"
30 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
31 #include "ui/views/background.h" 31 #include "ui/views/background.h"
32 #include "ui/views/controls/button/image_button.h" 32 #include "ui/views/controls/button/image_button.h"
33 #include "ui/views/controls/image_view.h" 33 #include "ui/views/controls/image_view.h"
34 #include "ui/views/controls/link.h" 34 #include "ui/views/controls/link.h"
35 #include "ui/views/mouse_watcher_view_host.h" 35 #include "ui/views/mouse_watcher_view_host.h"
36 36
37 // Max number of download views we'll contain. Any time a view is added and 37 // Max number of download views we'll contain. Any time a view is added and
38 // we already have this many download views, one is removed. 38 // we already have this many download views, one is removed.
39 static const size_t kMaxDownloadViews = 15; 39 static const size_t kMaxDownloadViews = 15;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 prefsize.Enlarge(0, kTopBottomPadding + kTopBottomPadding); 203 prefsize.Enlarge(0, kTopBottomPadding + kTopBottomPadding);
204 if (shelf_animation_->is_animating()) { 204 if (shelf_animation_->is_animating()) {
205 prefsize.set_height(static_cast<int>( 205 prefsize.set_height(static_cast<int>(
206 static_cast<double>(prefsize.height()) * 206 static_cast<double>(prefsize.height()) *
207 shelf_animation_->GetCurrentValue())); 207 shelf_animation_->GetCurrentValue()));
208 } 208 }
209 return prefsize; 209 return prefsize;
210 } 210 }
211 211
212 void DownloadShelfView::AnimationProgressed(const ui::Animation *animation) { 212 void DownloadShelfView::AnimationProgressed(const gfx::Animation *animation) {
213 if (animation == new_item_animation_.get()) { 213 if (animation == new_item_animation_.get()) {
214 Layout(); 214 Layout();
215 SchedulePaint(); 215 SchedulePaint();
216 } else if (animation == shelf_animation_.get()) { 216 } else if (animation == shelf_animation_.get()) {
217 // Force a re-layout of the parent, which will call back into 217 // Force a re-layout of the parent, which will call back into
218 // GetPreferredSize, where we will do our animation. In the case where the 218 // GetPreferredSize, where we will do our animation. In the case where the
219 // animation is hiding, we do a full resize - the fast resizing would 219 // animation is hiding, we do a full resize - the fast resizing would
220 // otherwise leave blank white areas where the shelf was and where the 220 // otherwise leave blank white areas where the shelf was and where the
221 // user's eye is. Thankfully bottom-resizing is a lot faster than 221 // user's eye is. Thankfully bottom-resizing is a lot faster than
222 // top-resizing. 222 // top-resizing.
223 parent_->ToolbarSizeChanged(shelf_animation_->IsShowing()); 223 parent_->ToolbarSizeChanged(shelf_animation_->IsShowing());
224 } 224 }
225 } 225 }
226 226
227 void DownloadShelfView::AnimationEnded(const ui::Animation *animation) { 227 void DownloadShelfView::AnimationEnded(const gfx::Animation *animation) {
228 if (animation == shelf_animation_.get()) { 228 if (animation == shelf_animation_.get()) {
229 parent_->SetDownloadShelfVisible(shelf_animation_->IsShowing()); 229 parent_->SetDownloadShelfVisible(shelf_animation_->IsShowing());
230 if (!shelf_animation_->IsShowing()) 230 if (!shelf_animation_->IsShowing())
231 Closed(); 231 Closed();
232 } 232 }
233 } 233 }
234 234
235 void DownloadShelfView::Layout() { 235 void DownloadShelfView::Layout() {
236 // Let our base class layout our child views 236 // Let our base class layout our child views
237 views::View::Layout(); 237 views::View::Layout();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 close_button_->SetImage(views::CustomButton::STATE_HOVERED, 324 close_button_->SetImage(views::CustomButton::STATE_HOVERED,
325 rb.GetImageSkiaNamed(IDR_CLOSE_1_H)); 325 rb.GetImageSkiaNamed(IDR_CLOSE_1_H));
326 close_button_->SetImage(views::CustomButton::STATE_PRESSED, 326 close_button_->SetImage(views::CustomButton::STATE_PRESSED,
327 rb.GetImageSkiaNamed(IDR_CLOSE_1_P)); 327 rb.GetImageSkiaNamed(IDR_CLOSE_1_P));
328 close_button_->SetAccessibleName( 328 close_button_->SetAccessibleName(
329 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); 329 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
330 AddChildView(close_button_); 330 AddChildView(close_button_);
331 331
332 UpdateColorsFromTheme(); 332 UpdateColorsFromTheme();
333 333
334 new_item_animation_.reset(new ui::SlideAnimation(this)); 334 new_item_animation_.reset(new gfx::SlideAnimation(this));
335 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); 335 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs);
336 336
337 shelf_animation_.reset(new ui::SlideAnimation(this)); 337 shelf_animation_.reset(new gfx::SlideAnimation(this));
338 shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs); 338 shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs);
339 } 339 }
340 } 340 }
341 341
342 bool DownloadShelfView::CanFitFirstDownloadItem() { 342 bool DownloadShelfView::CanFitFirstDownloadItem() {
343 if (download_views_.empty()) 343 if (download_views_.empty())
344 return true; 344 return true;
345 345
346 gfx::Size image_size = arrow_image_->GetPreferredSize(); 346 gfx::Size image_size = arrow_image_->GetPreferredSize();
347 gfx::Size close_button_size = close_button_->GetPreferredSize(); 347 gfx::Size close_button_size = close_button_->GetPreferredSize();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 const DownloadItemView* download_item_view) { 472 const DownloadItemView* download_item_view) {
473 gfx::Rect bounds = download_item_view->bounds(); 473 gfx::Rect bounds = download_item_view->bounds();
474 474
475 #if defined(TOOLKIT_VIEWS) 475 #if defined(TOOLKIT_VIEWS)
476 bounds.set_height(bounds.height() - 1); 476 bounds.set_height(bounds.height() - 1);
477 bounds.Offset(0, 3); 477 bounds.Offset(0, 3);
478 #endif 478 #endif
479 479
480 return bounds; 480 return bounds;
481 } 481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698