| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 home_->SetBounds(next_element_x, child_y, | 563 home_->SetBounds(next_element_x, child_y, |
| 564 home_->GetPreferredSize().width(), child_height); | 564 home_->GetPreferredSize().width(), child_height); |
| 565 } else { | 565 } else { |
| 566 home_->SetVisible(false); | 566 home_->SetVisible(false); |
| 567 home_->SetBounds(next_element_x, child_y, 0, child_height); | 567 home_->SetBounds(next_element_x, child_y, 0, child_height); |
| 568 } | 568 } |
| 569 next_element_x = | 569 next_element_x = |
| 570 home_->bounds().right() + GetLayoutConstant(TOOLBAR_STANDARD_SPACING); | 570 home_->bounds().right() + GetLayoutConstant(TOOLBAR_STANDARD_SPACING); |
| 571 | 571 |
| 572 int app_menu_width = app_menu_button_->GetPreferredSize().width(); | 572 int app_menu_width = app_menu_button_->GetPreferredSize().width(); |
| 573 const int right_padding = | 573 const int right_padding = GetLayoutConstant(TOOLBAR_STANDARD_SPACING); |
| 574 GetLayoutConstant(TOOLBAR_LOCATION_BAR_RIGHT_PADDING); | |
| 575 | 574 |
| 576 // Note that the browser actions container has its own internal left and right | 575 // Note that the browser actions container has its own internal left and right |
| 577 // padding to visually separate it from the location bar and app menu button. | 576 // padding to visually separate it from the location bar and app menu button. |
| 578 // However if the container is empty we must account for the |right_padding| | 577 // However if the container is empty we must account for the |right_padding| |
| 579 // value used to visually separate the location bar and app menu button. | 578 // value used to visually separate the location bar and app menu button. |
| 580 int available_width = std::max( | 579 int available_width = std::max( |
| 581 0, | 580 0, |
| 582 width() - end_padding - app_menu_width - | 581 width() - end_padding - app_menu_width - |
| 583 (browser_actions_->GetPreferredSize().IsEmpty() ? right_padding : 0) - | 582 (browser_actions_->GetPreferredSize().IsEmpty() ? right_padding : 0) - |
| 584 next_element_x); | 583 next_element_x); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 } | 702 } |
| 704 } | 703 } |
| 705 | 704 |
| 706 gfx::Size ToolbarView::GetSizeInternal( | 705 gfx::Size ToolbarView::GetSizeInternal( |
| 707 gfx::Size (View::*get_size)() const) const { | 706 gfx::Size (View::*get_size)() const) const { |
| 708 gfx::Size size((location_bar_->*get_size)()); | 707 gfx::Size size((location_bar_->*get_size)()); |
| 709 if (is_display_mode_normal()) { | 708 if (is_display_mode_normal()) { |
| 710 const int element_padding = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING); | 709 const int element_padding = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING); |
| 711 const int browser_actions_width = | 710 const int browser_actions_width = |
| 712 (browser_actions_->*get_size)().width(); | 711 (browser_actions_->*get_size)().width(); |
| 713 const int right_padding = | |
| 714 GetLayoutConstant(TOOLBAR_LOCATION_BAR_RIGHT_PADDING); | |
| 715 const int content_width = | 712 const int content_width = |
| 716 2 * GetToolbarHorizontalPadding() + (back_->*get_size)().width() + | 713 2 * GetToolbarHorizontalPadding() + (back_->*get_size)().width() + |
| 717 element_padding + (forward_->*get_size)().width() + element_padding + | 714 element_padding + (forward_->*get_size)().width() + element_padding + |
| 718 (reload_->*get_size)().width() + | 715 (reload_->*get_size)().width() + |
| 719 (show_home_button_.GetValue() | 716 (show_home_button_.GetValue() |
| 720 ? element_padding + (home_->*get_size)().width() | 717 ? element_padding + (home_->*get_size)().width() |
| 721 : 0) + | 718 : 0) + |
| 722 GetLayoutConstant(TOOLBAR_STANDARD_SPACING) + | 719 GetLayoutConstant(TOOLBAR_STANDARD_SPACING) + |
| 723 (browser_actions_width > 0 ? browser_actions_width : right_padding) + | 720 (browser_actions_width > 0 |
| 721 ? browser_actions_width |
| 722 : GetLayoutConstant(TOOLBAR_STANDARD_SPACING)) + |
| 724 (app_menu_button_->*get_size)().width(); | 723 (app_menu_button_->*get_size)().width(); |
| 725 size.Enlarge(content_width, 0); | 724 size.Enlarge(content_width, 0); |
| 726 } | 725 } |
| 727 return SizeForContentSize(size); | 726 return SizeForContentSize(size); |
| 728 } | 727 } |
| 729 | 728 |
| 730 gfx::Size ToolbarView::SizeForContentSize(gfx::Size size) const { | 729 gfx::Size ToolbarView::SizeForContentSize(gfx::Size size) const { |
| 731 if (is_display_mode_normal()) { | 730 if (is_display_mode_normal()) { |
| 732 // The size of the toolbar is computed using the size of the location bar | 731 // The size of the toolbar is computed using the size of the location bar |
| 733 // and constant padding values. | 732 // and constant padding values. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 if (OutdatedUpgradeBubbleView::IsAvailable()) { | 782 if (OutdatedUpgradeBubbleView::IsAvailable()) { |
| 784 OutdatedUpgradeBubbleView::ShowBubble(app_menu_button_, browser_, | 783 OutdatedUpgradeBubbleView::ShowBubble(app_menu_button_, browser_, |
| 785 auto_update_enabled); | 784 auto_update_enabled); |
| 786 } | 785 } |
| 787 } | 786 } |
| 788 | 787 |
| 789 void ToolbarView::OnShowHomeButtonChanged() { | 788 void ToolbarView::OnShowHomeButtonChanged() { |
| 790 Layout(); | 789 Layout(); |
| 791 SchedulePaint(); | 790 SchedulePaint(); |
| 792 } | 791 } |
| OLD | NEW |