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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_view.cc

Issue 271013002: Compute minimum widths for the toolbar components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/toolbar/toolbar_view.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/i18n/number_formatting.h" 9 #include "base/i18n/number_formatting.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 ui::Accelerator* accelerator) { 530 ui::Accelerator* accelerator) {
531 return GetWidget()->GetAccelerator(command_id, accelerator); 531 return GetWidget()->GetAccelerator(command_id, accelerator);
532 } 532 }
533 533
534 //////////////////////////////////////////////////////////////////////////////// 534 ////////////////////////////////////////////////////////////////////////////////
535 // ToolbarView, views::View overrides: 535 // ToolbarView, views::View overrides:
536 536
537 gfx::Size ToolbarView::GetPreferredSize() { 537 gfx::Size ToolbarView::GetPreferredSize() {
538 gfx::Size size(location_bar_->GetPreferredSize()); 538 gfx::Size size(location_bar_->GetPreferredSize());
539 if (is_display_mode_normal()) { 539 if (is_display_mode_normal()) {
540 size.Enlarge( 540 int content_width = kLeftEdgeSpacing + back_->GetPreferredSize().width() +
541 kLeftEdgeSpacing + back_->GetPreferredSize().width() + 541 forward_->GetPreferredSize().width() +
542 forward_->GetPreferredSize().width() + 542 reload_->GetPreferredSize().width() +
543 reload_->GetPreferredSize().width() + kStandardSpacing + 543 (show_home_button_.GetValue() ? home_->GetPreferredSize().width() : 0) +
544 (show_home_button_.GetValue() ? 544 kStandardSpacing + browser_actions_->GetPreferredSize().width() +
545 home_->GetPreferredSize().width() : 0) + 545 app_menu_->GetPreferredSize().width() + kRightEdgeSpacing;
546 (origin_chip_view_->visible() ? 546 content_width += origin_chip_view_->visible() ?
547 (origin_chip_view_->GetPreferredSize().width() + 547 (origin_chip_view_->GetPreferredSize().width() + kStandardSpacing) : 0;
548 2 * kStandardSpacing) : 548 size.Enlarge(content_width, 0);
549 0) +
550 browser_actions_->GetPreferredSize().width() +
551 app_menu_->GetPreferredSize().width() + kRightEdgeSpacing,
552 0);
553 gfx::ImageSkia* normal_background =
554 GetThemeProvider()->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER);
555 size.SetToMax(
556 gfx::Size(0, normal_background->height() - content_shadow_height()));
557 } else {
558 const int kPopupBottomSpacingGlass = 1;
559 const int kPopupBottomSpacingNonGlass = 2;
560 size.Enlarge(
561 0,
562 PopupTopSpacing() + (GetWidget()->ShouldWindowContentsBeTransparent() ?
563 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass));
564 } 549 }
565 return size; 550 return SizeForContentSize(size);
551 }
552
553 gfx::Size ToolbarView::GetMinimumSize() {
554 gfx::Size size(location_bar_->GetMinimumSize());
555 if (is_display_mode_normal()) {
556 int content_width = kLeftEdgeSpacing + back_->GetMinimumSize().width() +
557 forward_->GetMinimumSize().width() + reload_->GetMinimumSize().width() +
558 (show_home_button_.GetValue() ? home_->GetMinimumSize().width() : 0) +
559 kStandardSpacing + browser_actions_->GetMinimumSize().width() +
560 app_menu_->GetMinimumSize().width() + kRightEdgeSpacing;
561 content_width += origin_chip_view_->visible() ?
562 (origin_chip_view_->GetMinimumSize().width() + kStandardSpacing) : 0;
563 size.Enlarge(content_width, 0);
564 }
565 return SizeForContentSize(size);
566 } 566 }
567 567
568 void ToolbarView::Layout() { 568 void ToolbarView::Layout() {
569 // If we have not been initialized yet just do nothing. 569 // If we have not been initialized yet just do nothing.
570 if (back_ == NULL) 570 if (back_ == NULL)
571 return; 571 return;
572 572
573 if (!is_display_mode_normal()) { 573 if (!is_display_mode_normal()) {
574 location_bar_->SetBounds(0, PopupTopSpacing(), width(), 574 location_bar_->SetBounds(0, PopupTopSpacing(), width(),
575 location_bar_->GetPreferredSize().height()); 575 location_bar_->GetPreferredSize().height());
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance(); 769 EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance();
770 loaded_modules->MaybePostScanningTask(); 770 loaded_modules->MaybePostScanningTask();
771 return loaded_modules->ShouldShowConflictWarning(); 771 return loaded_modules->ShouldShowConflictWarning();
772 #else 772 #else
773 return false; 773 return false;
774 #endif 774 #endif
775 } 775 }
776 776
777 int ToolbarView::PopupTopSpacing() const { 777 int ToolbarView::PopupTopSpacing() const {
778 const int kPopupTopSpacingNonGlass = 3; 778 const int kPopupTopSpacingNonGlass = 3;
779 return GetWidget()->ShouldWindowContentsBeTransparent() 779 return GetWidget()->ShouldWindowContentsBeTransparent() ?
780 ? 0 780 0 : kPopupTopSpacingNonGlass;
781 : kPopupTopSpacingNonGlass; 781 }
782
783 gfx::Size ToolbarView::SizeForContentSize(gfx::Size size) const {
784 if (is_display_mode_normal()) {
785 gfx::ImageSkia* normal_background =
786 GetThemeProvider()->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER);
787 size.SetToMax(
788 gfx::Size(0, normal_background->height() - content_shadow_height()));
789 } else {
790 const int kPopupBottomSpacingGlass = 1;
791 const int kPopupBottomSpacingNonGlass = 2;
792 size.Enlarge(
793 0,
794 PopupTopSpacing() + (GetWidget()->ShouldWindowContentsBeTransparent() ?
795 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass));
796 }
797 return size;
782 } 798 }
783 799
784 void ToolbarView::LoadImages() { 800 void ToolbarView::LoadImages() {
785 ui::ThemeProvider* tp = GetThemeProvider(); 801 ui::ThemeProvider* tp = GetThemeProvider();
786 802
787 back_->SetImage(views::Button::STATE_NORMAL, 803 back_->SetImage(views::Button::STATE_NORMAL,
788 *(tp->GetImageSkiaNamed(IDR_BACK))); 804 *(tp->GetImageSkiaNamed(IDR_BACK)));
789 back_->SetImage(views::Button::STATE_DISABLED, 805 back_->SetImage(views::Button::STATE_DISABLED,
790 *(tp->GetImageSkiaNamed(IDR_BACK_D))); 806 *(tp->GetImageSkiaNamed(IDR_BACK_D)));
791 807
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 889
874 void ToolbarView::OnShowHomeButtonChanged() { 890 void ToolbarView::OnShowHomeButtonChanged() {
875 Layout(); 891 Layout();
876 SchedulePaint(); 892 SchedulePaint();
877 } 893 }
878 894
879 int ToolbarView::content_shadow_height() const { 895 int ToolbarView::content_shadow_height() const {
880 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? 896 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ?
881 kContentShadowHeightAsh : kContentShadowHeight; 897 kContentShadowHeightAsh : kContentShadowHeight;
882 } 898 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698