OLD | NEW |
1 // Copyright (c) 2010 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 "app/slide_animation.h" | |
12 #include "base/logging.h" | 11 #include "base/logging.h" |
13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/download/download_item.h" | 13 #include "chrome/browser/download/download_item.h" |
15 #include "chrome/browser/download/download_item_model.h" | 14 #include "chrome/browser/download/download_item_model.h" |
16 #include "chrome/browser/download/download_manager.h" | 15 #include "chrome/browser/download/download_manager.h" |
17 #include "chrome/browser/tab_contents/navigation_entry.h" | 16 #include "chrome/browser/tab_contents/navigation_entry.h" |
18 #include "chrome/browser/themes/browser_theme_provider.h" | 17 #include "chrome/browser/themes/browser_theme_provider.h" |
19 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/view_ids.h" | 19 #include "chrome/browser/ui/view_ids.h" |
21 #include "chrome/browser/ui/views/download_item_view.h" | 20 #include "chrome/browser/ui/views/download_item_view.h" |
22 #include "chrome/browser/ui/views/frame/browser_view.h" | 21 #include "chrome/browser/ui/views/frame/browser_view.h" |
23 #include "gfx/canvas.h" | 22 #include "gfx/canvas.h" |
24 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
25 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 25 #include "ui/base/animation/slide_animation.h" |
26 #include "views/background.h" | 26 #include "views/background.h" |
27 #include "views/controls/button/image_button.h" | 27 #include "views/controls/button/image_button.h" |
28 #include "views/controls/image_view.h" | 28 #include "views/controls/image_view.h" |
29 | 29 |
30 // Max number of download views we'll contain. Any time a view is added and | 30 // Max number of download views we'll contain. Any time a view is added and |
31 // we already have this many download views, one is removed. | 31 // we already have this many download views, one is removed. |
32 static const size_t kMaxDownloadViews = 15; | 32 static const size_t kMaxDownloadViews = 15; |
33 | 33 |
34 // Padding from left edge and first download view. | 34 // Padding from left edge and first download view. |
35 static const int kLeftPadding = 2; | 35 static const int kLeftPadding = 2; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 rb.GetBitmapNamed(IDR_CLOSE_BAR)); | 113 rb.GetBitmapNamed(IDR_CLOSE_BAR)); |
114 close_button_->SetImage(views::CustomButton::BS_HOT, | 114 close_button_->SetImage(views::CustomButton::BS_HOT, |
115 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); | 115 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); |
116 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 116 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
117 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); | 117 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); |
118 close_button_->SetAccessibleName( | 118 close_button_->SetAccessibleName( |
119 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE))); | 119 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE))); |
120 UpdateButtonColors(); | 120 UpdateButtonColors(); |
121 AddChildView(close_button_); | 121 AddChildView(close_button_); |
122 | 122 |
123 new_item_animation_.reset(new SlideAnimation(this)); | 123 new_item_animation_.reset(new ui::SlideAnimation(this)); |
124 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); | 124 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); |
125 | 125 |
126 shelf_animation_.reset(new SlideAnimation(this)); | 126 shelf_animation_.reset(new ui::SlideAnimation(this)); |
127 shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs); | 127 shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs); |
128 Show(); | 128 Show(); |
129 } | 129 } |
130 | 130 |
131 void DownloadShelfView::AddDownloadView(DownloadItemView* view) { | 131 void DownloadShelfView::AddDownloadView(DownloadItemView* view) { |
132 mouse_watcher_.Stop(); | 132 mouse_watcher_.Stop(); |
133 | 133 |
134 Show(); | 134 Show(); |
135 | 135 |
136 DCHECK(view); | 136 DCHECK(view); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 217 } |
218 prefsize.Enlarge(0, kTopBottomPadding + kTopBottomPadding); | 218 prefsize.Enlarge(0, kTopBottomPadding + kTopBottomPadding); |
219 if (shelf_animation_->is_animating()) { | 219 if (shelf_animation_->is_animating()) { |
220 prefsize.set_height(static_cast<int>( | 220 prefsize.set_height(static_cast<int>( |
221 static_cast<double>(prefsize.height()) * | 221 static_cast<double>(prefsize.height()) * |
222 shelf_animation_->GetCurrentValue())); | 222 shelf_animation_->GetCurrentValue())); |
223 } | 223 } |
224 return prefsize; | 224 return prefsize; |
225 } | 225 } |
226 | 226 |
227 void DownloadShelfView::AnimationProgressed(const Animation *animation) { | 227 void DownloadShelfView::AnimationProgressed(const ui::Animation *animation) { |
228 if (animation == new_item_animation_.get()) { | 228 if (animation == new_item_animation_.get()) { |
229 Layout(); | 229 Layout(); |
230 SchedulePaint(); | 230 SchedulePaint(); |
231 } else if (animation == shelf_animation_.get()) { | 231 } else if (animation == shelf_animation_.get()) { |
232 // Force a re-layout of the parent, which will call back into | 232 // Force a re-layout of the parent, which will call back into |
233 // GetPreferredSize, where we will do our animation. In the case where the | 233 // GetPreferredSize, where we will do our animation. In the case where the |
234 // animation is hiding, we do a full resize - the fast resizing would | 234 // animation is hiding, we do a full resize - the fast resizing would |
235 // otherwise leave blank white areas where the shelf was and where the | 235 // otherwise leave blank white areas where the shelf was and where the |
236 // user's eye is. Thankfully bottom-resizing is a lot faster than | 236 // user's eye is. Thankfully bottom-resizing is a lot faster than |
237 // top-resizing. | 237 // top-resizing. |
238 parent_->SelectedTabToolbarSizeChanged(shelf_animation_->IsShowing()); | 238 parent_->SelectedTabToolbarSizeChanged(shelf_animation_->IsShowing()); |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 void DownloadShelfView::AnimationEnded(const Animation *animation) { | 242 void DownloadShelfView::AnimationEnded(const ui::Animation *animation) { |
243 if (animation == shelf_animation_.get()) { | 243 if (animation == shelf_animation_.get()) { |
244 parent_->SetDownloadShelfVisible(shelf_animation_->IsShowing()); | 244 parent_->SetDownloadShelfVisible(shelf_animation_->IsShowing()); |
245 if (!shelf_animation_->IsShowing()) | 245 if (!shelf_animation_->IsShowing()) |
246 Closed(); | 246 Closed(); |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 void DownloadShelfView::Layout() { | 250 void DownloadShelfView::Layout() { |
251 // Now that we know we have a parent, we can safely set our theme colors. | 251 // Now that we know we have a parent, we can safely set our theme colors. |
252 show_all_view_->SetColor( | 252 show_all_view_->SetColor( |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 const DownloadItemView* download_item_view) { | 433 const DownloadItemView* download_item_view) { |
434 gfx::Rect bounds = download_item_view->bounds(); | 434 gfx::Rect bounds = download_item_view->bounds(); |
435 | 435 |
436 #if defined(TOOLKIT_VIEWS) | 436 #if defined(TOOLKIT_VIEWS) |
437 bounds.set_height(bounds.height() - 1); | 437 bounds.set_height(bounds.height() - 1); |
438 bounds.Offset(0, 3); | 438 bounds.Offset(0, 3); |
439 #endif | 439 #endif |
440 | 440 |
441 return bounds; | 441 return bounds; |
442 } | 442 } |
OLD | NEW |