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

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

Issue 165372: Merge 22980 - Mask the close button on the download shelf so that it's visibl... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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 | « chrome/browser/views/download_shelf_view.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')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/chrome/browser/views/download_shelf_view.cc:r22980
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 size->set_height(std::max(view_preferred.height(), size->height())); 65 size->set_height(std::max(view_preferred.height(), size->height()));
66 } 66 }
67 67
68 int CenterPosition(int size, int target_size) { 68 int CenterPosition(int size, int target_size) {
69 return std::max((target_size - size) / 2, kTopBottomPadding); 69 return std::max((target_size - size) / 2, kTopBottomPadding);
70 } 70 }
71 71
72 } // namespace 72 } // namespace
73 73
74 DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent) 74 DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent)
75 : browser_(browser), parent_(parent) { 75 : browser_(browser),
76 parent_(parent) {
76 parent->AddChildView(this); 77 parent->AddChildView(this);
77 Init(); 78 Init();
78 } 79 }
79 80
80 DownloadShelfView::~DownloadShelfView() { 81 DownloadShelfView::~DownloadShelfView() {
81 parent_->RemoveChildView(this); 82 parent_->RemoveChildView(this);
82 } 83 }
83 84
84 void DownloadShelfView::Init() { 85 void DownloadShelfView::Init() {
85 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); 86 ResourceBundle &rb = ResourceBundle::GetSharedInstance();
86 arrow_image_ = new views::ImageView(); 87 arrow_image_ = new views::ImageView();
87 arrow_image_->SetImage(rb.GetBitmapNamed(IDR_DOWNLOADS_FAVICON)); 88 arrow_image_->SetImage(rb.GetBitmapNamed(IDR_DOWNLOADS_FAVICON));
88 AddChildView(arrow_image_); 89 AddChildView(arrow_image_);
89 90
90 show_all_view_ = 91 show_all_view_ =
91 new views::Link(l10n_util::GetString(IDS_SHOW_ALL_DOWNLOADS)); 92 new views::Link(l10n_util::GetString(IDS_SHOW_ALL_DOWNLOADS));
92 show_all_view_->SetController(this); 93 show_all_view_->SetController(this);
93 AddChildView(show_all_view_); 94 AddChildView(show_all_view_);
94 95
95 close_button_ = new views::ImageButton(this); 96 close_button_ = new views::ImageButton(this);
96 close_button_->SetImage(views::CustomButton::BS_NORMAL, 97 close_button_->SetImage(views::CustomButton::BS_NORMAL,
97 rb.GetBitmapNamed(IDR_CLOSE_BAR)); 98 rb.GetBitmapNamed(IDR_CLOSE_BAR));
98 close_button_->SetImage(views::CustomButton::BS_HOT, 99 close_button_->SetImage(views::CustomButton::BS_HOT,
99 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); 100 rb.GetBitmapNamed(IDR_CLOSE_BAR_H));
100 close_button_->SetImage(views::CustomButton::BS_PUSHED, 101 close_button_->SetImage(views::CustomButton::BS_PUSHED,
101 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); 102 rb.GetBitmapNamed(IDR_CLOSE_BAR_P));
103 UpdateButtonColors();
102 AddChildView(close_button_); 104 AddChildView(close_button_);
103 105
104 new_item_animation_.reset(new SlideAnimation(this)); 106 new_item_animation_.reset(new SlideAnimation(this));
105 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); 107 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs);
106 108
107 shelf_animation_.reset(new SlideAnimation(this)); 109 shelf_animation_.reset(new SlideAnimation(this));
108 shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs); 110 shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs);
109 Show(); 111 Show();
110 } 112 }
111 113
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 int available_width = width() - kRightPadding - close_button_size.width() - 279 int available_width = width() - kRightPadding - close_button_size.width() -
278 kCloseAndLinkPadding - show_all_size.width() - kDownloadsTitlePadding - 280 kCloseAndLinkPadding - show_all_size.width() - kDownloadsTitlePadding -
279 image_size.width() - kDownloadPadding - kLeftPadding; 281 image_size.width() - kDownloadPadding - kLeftPadding;
280 if (available_width <= 0) 282 if (available_width <= 0)
281 return false; 283 return false;
282 284
283 gfx::Size item_size = (*download_views_.rbegin())->GetPreferredSize(); 285 gfx::Size item_size = (*download_views_.rbegin())->GetPreferredSize();
284 return item_size.width() < available_width; 286 return item_size.width() < available_width;
285 } 287 }
286 288
289 void DownloadShelfView::UpdateButtonColors() {
290 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
291 if (GetThemeProvider()) {
292 close_button_->SetBackground(
293 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT),
294 rb.GetBitmapNamed(IDR_CLOSE_BAR),
295 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK));
296 }
297 }
298
299 void DownloadShelfView::ThemeChanged() {
300 UpdateButtonColors();
301 }
302
287 void DownloadShelfView::LinkActivated(views::Link* source, int event_flags) { 303 void DownloadShelfView::LinkActivated(views::Link* source, int event_flags) {
288 browser_->ShowDownloadsTab(); 304 browser_->ShowDownloadsTab();
289 } 305 }
290 306
291 void DownloadShelfView::ButtonPressed(views::Button* button) { 307 void DownloadShelfView::ButtonPressed(views::Button* button) {
292 Close(); 308 Close();
293 } 309 }
294 310
295 bool DownloadShelfView::IsShowing() const { 311 bool DownloadShelfView::IsShowing() const {
296 return shelf_animation_->IsShowing(); 312 return shelf_animation_->IsShowing();
297 } 313 }
298 314
299 bool DownloadShelfView::IsClosing() const { 315 bool DownloadShelfView::IsClosing() const {
300 return shelf_animation_->IsClosing(); 316 return shelf_animation_->IsClosing();
301 } 317 }
302 318
303 void DownloadShelfView::Show() { 319 void DownloadShelfView::Show() {
304 shelf_animation_->Show(); 320 shelf_animation_->Show();
305 } 321 }
306 322
307 void DownloadShelfView::Close() { 323 void DownloadShelfView::Close() {
308 parent_->SetDownloadShelfVisible(false); 324 parent_->SetDownloadShelfVisible(false);
309 shelf_animation_->Hide(); 325 shelf_animation_->Hide();
310 } 326 }
OLDNEW
« no previous file with comments | « chrome/browser/views/download_shelf_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698