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

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
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_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')
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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 ui::Accelerator* accelerator) { 534 ui::Accelerator* accelerator) {
535 return GetWidget()->GetAccelerator(command_id, accelerator); 535 return GetWidget()->GetAccelerator(command_id, accelerator);
536 } 536 }
537 537
538 //////////////////////////////////////////////////////////////////////////////// 538 ////////////////////////////////////////////////////////////////////////////////
539 // ToolbarView, views::View overrides: 539 // ToolbarView, views::View overrides:
540 540
541 gfx::Size ToolbarView::GetPreferredSize() { 541 gfx::Size ToolbarView::GetPreferredSize() {
542 gfx::Size size(location_bar_->GetPreferredSize()); 542 gfx::Size size(location_bar_->GetPreferredSize());
543 if (is_display_mode_normal()) { 543 if (is_display_mode_normal()) {
544 size.Enlarge( 544 int content_width = kLeftEdgeSpacing + back_->GetPreferredSize().width() +
545 kLeftEdgeSpacing + back_->GetPreferredSize().width() + 545 forward_->GetPreferredSize().width() +
546 forward_->GetPreferredSize().width() + 546 reload_->GetPreferredSize().width() +
547 reload_->GetPreferredSize().width() + kStandardSpacing + 547 (show_home_button_.GetValue() ? home_->GetPreferredSize().width() : 0) +
548 (show_home_button_.GetValue() ? 548 kStandardSpacing + browser_actions_->GetPreferredSize().width() +
549 home_->GetPreferredSize().width() : 0) + 549 app_menu_->GetPreferredSize().width() + kRightEdgeSpacing;
550 (origin_chip_view_->visible() ? 550 content_width += origin_chip_view_->visible() ?
551 (origin_chip_view_->GetPreferredSize().width() + 551 (origin_chip_view_->GetPreferredSize().width() + kStandardSpacing) : 0;
552 2 * kStandardSpacing) : 552 size.Enlarge(content_width, 0);
553 0) +
554 browser_actions_->GetPreferredSize().width() +
555 app_menu_->GetPreferredSize().width() + kRightEdgeSpacing,
556 0);
557 gfx::ImageSkia* normal_background =
558 GetThemeProvider()->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER);
559 size.SetToMax(
560 gfx::Size(0, normal_background->height() - content_shadow_height()));
561 } else {
562 const int kPopupBottomSpacingGlass = 1;
563 const int kPopupBottomSpacingNonGlass = 2;
564 size.Enlarge(
565 0,
566 PopupTopSpacing() + (GetWidget()->ShouldWindowContentsBeTransparent() ?
567 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass));
568 } 553 }
569 return size; 554 return SizeForContentSize(size);
555 }
556
557 gfx::Size ToolbarView::GetMinimumSize() {
558 gfx::Size size(location_bar_->GetMinimumSize());
559 if (is_display_mode_normal()) {
560 int content_width = kLeftEdgeSpacing + back_->GetMinimumSize().width() +
561 forward_->GetMinimumSize().width() + reload_->GetMinimumSize().width() +
562 (show_home_button_.GetValue() ? home_->GetMinimumSize().width() : 0) +
563 kStandardSpacing + browser_actions_->GetMinimumSize().width() +
564 app_menu_->GetMinimumSize().width() + kRightEdgeSpacing;
565 content_width += origin_chip_view_->visible() ?
566 (origin_chip_view_->GetMinimumSize().width() + kStandardSpacing) : 0;
567 size.Enlarge(content_width, 0);
568 }
569 return SizeForContentSize(size);
570 } 570 }
571 571
572 void ToolbarView::Layout() { 572 void ToolbarView::Layout() {
573 // If we have not been initialized yet just do nothing. 573 // If we have not been initialized yet just do nothing.
574 if (back_ == NULL) 574 if (back_ == NULL)
575 return; 575 return;
576 576
577 if (!is_display_mode_normal()) { 577 if (!is_display_mode_normal()) {
578 location_bar_->SetBounds(0, PopupTopSpacing(), width(), 578 location_bar_->SetBounds(0, PopupTopSpacing(), width(),
579 location_bar_->GetPreferredSize().height()); 579 location_bar_->GetPreferredSize().height());
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance(); 773 EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance();
774 loaded_modules->MaybePostScanningTask(); 774 loaded_modules->MaybePostScanningTask();
775 return loaded_modules->ShouldShowConflictWarning(); 775 return loaded_modules->ShouldShowConflictWarning();
776 #else 776 #else
777 return false; 777 return false;
778 #endif 778 #endif
779 } 779 }
780 780
781 int ToolbarView::PopupTopSpacing() const { 781 int ToolbarView::PopupTopSpacing() const {
782 const int kPopupTopSpacingNonGlass = 3; 782 const int kPopupTopSpacingNonGlass = 3;
783 return GetWidget()->ShouldWindowContentsBeTransparent() 783 return GetWidget()->ShouldWindowContentsBeTransparent() ?
784 ? 0 784 0 : kPopupTopSpacingNonGlass;
785 : kPopupTopSpacingNonGlass; 785 }
786
787 gfx::Size ToolbarView::SizeForContentSize(gfx::Size size) const {
788 if (is_display_mode_normal()) {
789 gfx::ImageSkia* normal_background =
790 GetThemeProvider()->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER);
791 size.SetToMax(
792 gfx::Size(0, normal_background->height() - content_shadow_height()));
793 } else {
794 const int kPopupBottomSpacingGlass = 1;
795 const int kPopupBottomSpacingNonGlass = 2;
796 size.Enlarge(
797 0,
798 PopupTopSpacing() + (GetWidget()->ShouldWindowContentsBeTransparent() ?
799 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass));
800 }
801 return size;
786 } 802 }
787 803
788 void ToolbarView::LoadImages() { 804 void ToolbarView::LoadImages() {
789 ui::ThemeProvider* tp = GetThemeProvider(); 805 ui::ThemeProvider* tp = GetThemeProvider();
790 806
791 back_->SetImage(views::Button::STATE_NORMAL, 807 back_->SetImage(views::Button::STATE_NORMAL,
792 *(tp->GetImageSkiaNamed(IDR_BACK))); 808 *(tp->GetImageSkiaNamed(IDR_BACK)));
793 back_->SetImage(views::Button::STATE_DISABLED, 809 back_->SetImage(views::Button::STATE_DISABLED,
794 *(tp->GetImageSkiaNamed(IDR_BACK_D))); 810 *(tp->GetImageSkiaNamed(IDR_BACK_D)));
795 811
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 893
878 void ToolbarView::OnShowHomeButtonChanged() { 894 void ToolbarView::OnShowHomeButtonChanged() {
879 Layout(); 895 Layout();
880 SchedulePaint(); 896 SchedulePaint();
881 } 897 }
882 898
883 int ToolbarView::content_shadow_height() const { 899 int ToolbarView::content_shadow_height() const {
884 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? 900 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ?
885 kContentShadowHeightAsh : kContentShadowHeight; 901 kContentShadowHeightAsh : kContentShadowHeight;
886 } 902 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698