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

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

Issue 1685763004: Fix various issues with popup/app window layout/drawing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: Fix unittest Created 4 years, 10 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
« 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 <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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 gfx::Size ToolbarView::GetMinimumSize() const { 481 gfx::Size ToolbarView::GetMinimumSize() const {
482 return GetSizeInternal(&View::GetMinimumSize); 482 return GetSizeInternal(&View::GetMinimumSize);
483 } 483 }
484 484
485 void ToolbarView::Layout() { 485 void ToolbarView::Layout() {
486 // If we have not been initialized yet just do nothing. 486 // If we have not been initialized yet just do nothing.
487 if (!location_bar_) 487 if (!location_bar_)
488 return; 488 return;
489 489
490 if (!is_display_mode_normal()) { 490 if (!is_display_mode_normal()) {
491 location_bar_->SetBounds(0, PopupTopSpacing(), width(), 491 location_bar_->SetBounds(0, 0, width(),
492 location_bar_->GetPreferredSize().height()); 492 location_bar_->GetPreferredSize().height());
493 return; 493 return;
494 } 494 }
495 495
496 // We assume all child elements except the location bar are the same height. 496 // We assume all child elements except the location bar are the same height.
497 // Set child_y such that buttons appear vertically centered. 497 // Set child_y such that buttons appear vertically centered.
498 const int child_height = 498 const int child_height =
499 std::min(back_->GetPreferredSize().height(), height()); 499 std::min(back_->GetPreferredSize().height(), height());
500 const int child_y = CenteredChildY(height(), child_height); 500 const int child_y = CenteredChildY(height(), child_height);
501 501
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 content::RecordAction(UserMetricsAction("ConflictBadge")); 680 content::RecordAction(UserMetricsAction("ConflictBadge"));
681 #if defined(OS_WIN) 681 #if defined(OS_WIN)
682 ConflictingModuleView::MaybeShow(browser_, app_menu_button_); 682 ConflictingModuleView::MaybeShow(browser_, app_menu_button_);
683 #endif 683 #endif
684 } 684 }
685 incompatibility_badge_showing = true; 685 incompatibility_badge_showing = true;
686 return; 686 return;
687 } 687 }
688 } 688 }
689 689
690 int ToolbarView::PopupTopSpacing() const {
691 return (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) ?
692 0 : views::NonClientFrameView::kClientEdgeThickness;
693 }
694
695 gfx::Size ToolbarView::GetSizeInternal( 690 gfx::Size ToolbarView::GetSizeInternal(
696 gfx::Size (View::*get_size)() const) const { 691 gfx::Size (View::*get_size)() const) const {
697 gfx::Size size((location_bar_->*get_size)()); 692 gfx::Size size((location_bar_->*get_size)());
698 if (is_display_mode_normal()) { 693 if (is_display_mode_normal()) {
699 const int element_padding = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING); 694 const int element_padding = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING);
700 const int browser_actions_width = 695 const int browser_actions_width =
701 (browser_actions_->*get_size)().width(); 696 (browser_actions_->*get_size)().width();
702 const int right_padding = 697 const int right_padding =
703 GetLayoutConstant(TOOLBAR_LOCATION_BAR_RIGHT_PADDING); 698 GetLayoutConstant(TOOLBAR_LOCATION_BAR_RIGHT_PADDING);
704 const int content_width = 699 const int content_width =
(...skipping 21 matching lines...) Expand all
726 int content_height = std::max(back_->GetPreferredSize().height(), 721 int content_height = std::max(back_->GetPreferredSize().height(),
727 location_bar_->GetPreferredSize().height()); 722 location_bar_->GetPreferredSize().height());
728 int padding = GetLayoutInsets(TOOLBAR).height(); 723 int padding = GetLayoutInsets(TOOLBAR).height();
729 size.SetToMax(gfx::Size(0, content_height + padding)); 724 size.SetToMax(gfx::Size(0, content_height + padding));
730 } else { 725 } else {
731 gfx::ImageSkia* normal_background = 726 gfx::ImageSkia* normal_background =
732 GetThemeProvider()->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER); 727 GetThemeProvider()->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER);
733 size.SetToMax( 728 size.SetToMax(
734 gfx::Size(0, normal_background->height() - content_shadow_height())); 729 gfx::Size(0, normal_background->height() - content_shadow_height()));
735 } 730 }
736 } else if (size.height() > 0) {
737 size.Enlarge(
738 0, PopupTopSpacing() + views::NonClientFrameView::kClientEdgeThickness);
739 } 731 }
740 return size; 732 return size;
741 } 733 }
742 734
743 void ToolbarView::LoadImages() { 735 void ToolbarView::LoadImages() {
744 const ui::ThemeProvider* tp = GetThemeProvider(); 736 const ui::ThemeProvider* tp = GetThemeProvider();
745 737
746 if (ui::MaterialDesignController::IsModeMaterial()) { 738 if (ui::MaterialDesignController::IsModeMaterial()) {
747 const int kButtonSize = 16; 739 const int kButtonSize = 16;
748 const SkColor normal_color = 740 const SkColor normal_color =
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 void ToolbarView::OnShowHomeButtonChanged() { 794 void ToolbarView::OnShowHomeButtonChanged() {
803 Layout(); 795 Layout();
804 SchedulePaint(); 796 SchedulePaint();
805 } 797 }
806 798
807 int ToolbarView::content_shadow_height() const { 799 int ToolbarView::content_shadow_height() const {
808 return GetLayoutConstant( 800 return GetLayoutConstant(
809 (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) ? 801 (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) ?
810 TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH : TOOLBAR_CONTENT_SHADOW_HEIGHT); 802 TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH : TOOLBAR_CONTENT_SHADOW_HEIGHT);
811 } 803 }
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