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

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

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 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 | 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_item_view.h" 5 #include "chrome/browser/ui/views/download/download_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 y = (height() - button_size.height()) / 2; 354 y = (height() - button_size.height()) / 2;
355 if (save_button_) { 355 if (save_button_) {
356 save_button_->SetBounds(x, y, button_size.width(), button_size.height()); 356 save_button_->SetBounds(x, y, button_size.width(), button_size.height());
357 x += button_size.width() + kButtonPadding; 357 x += button_size.width() + kButtonPadding;
358 } 358 }
359 discard_button_->SetBounds(x, y, button_size.width(), button_size.height()); 359 discard_button_->SetBounds(x, y, button_size.width(), button_size.height());
360 UpdateColorsFromTheme(); 360 UpdateColorsFromTheme();
361 } 361 }
362 } 362 }
363 363
364 gfx::Size DownloadItemView::GetPreferredSize() { 364 gfx::Size DownloadItemView::GetPreferredSize() const {
365 int width, height; 365 int width, height;
366 366
367 // First, we set the height to the height of two rows or text plus margins. 367 // First, we set the height to the height of two rows or text plus margins.
368 height = 2 * kVerticalPadding + 2 * font_list_.GetHeight() + 368 height = 2 * kVerticalPadding + 2 * font_list_.GetHeight() +
369 kVerticalTextPadding; 369 kVerticalTextPadding;
370 // Then we increase the size if the progress icon doesn't fit. 370 // Then we increase the size if the progress icon doesn't fit.
371 height = std::max<int>(height, DownloadShelf::kSmallProgressIconSize); 371 height = std::max<int>(height, DownloadShelf::kSmallProgressIconSize);
372 372
373 if (IsShowingWarningDialog()) { 373 if (IsShowingWarningDialog()) {
374 BodyImageSet* body_image_set = 374 const BodyImageSet* body_image_set =
375 (mode_ == DANGEROUS_MODE) ? &dangerous_mode_body_image_set_ : 375 (mode_ == DANGEROUS_MODE) ? &dangerous_mode_body_image_set_ :
376 &malicious_mode_body_image_set_; 376 &malicious_mode_body_image_set_;
377 width = kLeftPadding + body_image_set->top_left->width(); 377 width = kLeftPadding + body_image_set->top_left->width();
378 width += warning_icon_->width() + kLabelPadding; 378 width += warning_icon_->width() + kLabelPadding;
379 width += dangerous_download_label_->width() + kLabelPadding; 379 width += dangerous_download_label_->width() + kLabelPadding;
380 gfx::Size button_size = GetButtonSize(); 380 gfx::Size button_size = GetButtonSize();
381 // Make sure the button fits. 381 // Make sure the button fits.
382 height = std::max<int>(height, 2 * kVerticalPadding + button_size.height()); 382 height = std::max<int>(height, 2 * kVerticalPadding + button_size.height());
383 // Then we make sure the warning icon fits. 383 // Then we make sure the warning icon fits.
384 height = std::max<int>(height, 2 * kVerticalPadding + 384 height = std::max<int>(height, 2 * kVerticalPadding +
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 dangerous_download_label_ = new views::Label(dangerous_label); 1197 dangerous_download_label_ = new views::Label(dangerous_label);
1198 dangerous_download_label_->SetMultiLine(true); 1198 dangerous_download_label_->SetMultiLine(true);
1199 dangerous_download_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1199 dangerous_download_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1200 dangerous_download_label_->SetAutoColorReadabilityEnabled(false); 1200 dangerous_download_label_->SetAutoColorReadabilityEnabled(false);
1201 AddChildView(dangerous_download_label_); 1201 AddChildView(dangerous_download_label_);
1202 SizeLabelToMinWidth(); 1202 SizeLabelToMinWidth();
1203 UpdateDropDownButtonPosition(); 1203 UpdateDropDownButtonPosition();
1204 TooltipTextChanged(); 1204 TooltipTextChanged();
1205 } 1205 }
1206 1206
1207 gfx::Size DownloadItemView::GetButtonSize() { 1207 gfx::Size DownloadItemView::GetButtonSize() const {
1208 DCHECK(discard_button_ && (mode_ == MALICIOUS_MODE || save_button_)); 1208 DCHECK(discard_button_ && (mode_ == MALICIOUS_MODE || save_button_));
1209 gfx::Size size; 1209 gfx::Size size;
1210 1210
1211 // We cache the size when successfully retrieved, not for performance reasons 1211 // We cache the size when successfully retrieved, not for performance reasons
1212 // but because if this DownloadItemView is being animated while the tab is 1212 // but because if this DownloadItemView is being animated while the tab is
1213 // not showing, the native buttons are not parented and their preferred size 1213 // not showing, the native buttons are not parented and their preferred size
1214 // is 0, messing-up the layout. 1214 // is 0, messing-up the layout.
1215 if (cached_button_size_.width() != 0) 1215 if (cached_button_size_.width() != 0)
1216 return cached_button_size_; 1216 return cached_button_size_;
1217 1217
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 void DownloadItemView::AnimateStateTransition(State from, State to, 1343 void DownloadItemView::AnimateStateTransition(State from, State to,
1344 gfx::SlideAnimation* animation) { 1344 gfx::SlideAnimation* animation) {
1345 if (from == NORMAL && to == HOT) { 1345 if (from == NORMAL && to == HOT) {
1346 animation->Show(); 1346 animation->Show();
1347 } else if (from == HOT && to == NORMAL) { 1347 } else if (from == HOT && to == NORMAL) {
1348 animation->Hide(); 1348 animation->Hide();
1349 } else if (from != to) { 1349 } else if (from != to) {
1350 animation->Reset((to == HOT) ? 1.0 : 0.0); 1350 animation->Reset((to == HOT) ? 1.0 : 0.0);
1351 } 1351 }
1352 } 1352 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.h ('k') | chrome/browser/ui/views/download/download_shelf_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698