Chromium Code Reviews| 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/frame/opaque_browser_frame_view_layout.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/containers/adapters.h" | 8 #include "base/containers/adapters.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/profiles/profiles_state.h" | 10 #include "chrome/browser/profiles/profiles_state.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 void OpaqueBrowserFrameViewLayout::SetButtonOrdering( | 100 void OpaqueBrowserFrameViewLayout::SetButtonOrdering( |
| 101 const std::vector<views::FrameButton>& leading_buttons, | 101 const std::vector<views::FrameButton>& leading_buttons, |
| 102 const std::vector<views::FrameButton>& trailing_buttons) { | 102 const std::vector<views::FrameButton>& trailing_buttons) { |
| 103 leading_buttons_ = leading_buttons; | 103 leading_buttons_ = leading_buttons; |
| 104 trailing_buttons_ = trailing_buttons; | 104 trailing_buttons_ = trailing_buttons; |
| 105 } | 105 } |
| 106 | 106 |
| 107 gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip( | 107 gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip( |
| 108 const gfx::Size& tabstrip_preferred_size, | 108 const gfx::Size& tabstrip_preferred_size, |
| 109 int available_width) const { | 109 int available_width) const { |
| 110 int x = leading_button_start_ + GetLayoutConstant(AVATAR_ICON_PADDING); | 110 int x = leading_button_start_ + OpaqueBrowserFrameView::kAvatarIconPadding; |
| 111 available_width -= x + NewTabCaptionSpacing() + trailing_button_start_; | 111 available_width -= x + NewTabCaptionSpacing() + trailing_button_start_; |
| 112 return gfx::Rect(x, GetTabStripInsetsTop(false), std::max(0, available_width), | 112 return gfx::Rect(x, GetTabStripInsetsTop(false), std::max(0, available_width), |
| 113 tabstrip_preferred_size.height()); | 113 tabstrip_preferred_size.height()); |
| 114 } | 114 } |
| 115 | 115 |
| 116 gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize( | 116 gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize( |
| 117 int available_width) const { | 117 int available_width) const { |
| 118 gfx::Size min_size = delegate_->GetBrowserViewMinimumSize(); | 118 gfx::Size min_size = delegate_->GetBrowserViewMinimumSize(); |
| 119 int border_thickness = NonClientBorderThickness(); | 119 int border_thickness = NonClientBorderThickness(); |
| 120 min_size.Enlarge(2 * border_thickness, | 120 min_size.Enlarge(2 * border_thickness, |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 | 362 |
| 363 // Any buttons/icon/title were laid out based on the frame border thickness, | 363 // Any buttons/icon/title were laid out based on the frame border thickness, |
| 364 // but the tabstrip bounds need to be based on the non-client border thickness | 364 // but the tabstrip bounds need to be based on the non-client border thickness |
| 365 // on any side where there aren't other buttons forcing a larger inset. | 365 // on any side where there aren't other buttons forcing a larger inset. |
| 366 int min_button_width = NonClientBorderThickness(); | 366 int min_button_width = NonClientBorderThickness(); |
| 367 leading_button_start_ = std::max(leading_button_start_, min_button_width); | 367 leading_button_start_ = std::max(leading_button_start_, min_button_width); |
| 368 // The trailing corner is a mirror of the leading one. | 368 // The trailing corner is a mirror of the leading one. |
| 369 trailing_button_start_ = std::max(trailing_button_start_, min_button_width); | 369 trailing_button_start_ = std::max(trailing_button_start_, min_button_width); |
| 370 | 370 |
| 371 if (incognito_icon_) { | 371 if (incognito_icon_) { |
| 372 const int pad = GetLayoutConstant(AVATAR_ICON_PADDING); | 372 const int pad = OpaqueBrowserFrameView::kAvatarIconPadding; |
|
Peter Kasting
2016/12/08 20:57:49
Nit: Make constexpr?
Evan Stade
2016/12/13 01:31:17
Done.
| |
| 373 const gfx::Size size(delegate_->GetIncognitoAvatarIcon().size()); | 373 const gfx::Size size(delegate_->GetIncognitoAvatarIcon().size()); |
| 374 const int incognito_width = pad + size.width(); | 374 const int incognito_width = pad + size.width(); |
| 375 int x; | 375 int x; |
| 376 if (ShouldIncognitoIconBeOnRight()) { | 376 if (ShouldIncognitoIconBeOnRight()) { |
| 377 trailing_button_start_ += incognito_width; | 377 trailing_button_start_ += incognito_width; |
| 378 x = host->width() - trailing_button_start_; | 378 x = host->width() - trailing_button_start_; |
| 379 } else { | 379 } else { |
| 380 x = leading_button_start_ + pad; | 380 x = leading_button_start_ + pad; |
| 381 leading_button_start_ += incognito_width; | 381 leading_button_start_ += incognito_width; |
| 382 } | 382 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 | 601 |
| 602 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, | 602 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, |
| 603 views::View* view) { | 603 views::View* view) { |
| 604 SetView(view->id(), view); | 604 SetView(view->id(), view); |
| 605 } | 605 } |
| 606 | 606 |
| 607 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, | 607 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, |
| 608 views::View* view) { | 608 views::View* view) { |
| 609 SetView(view->id(), nullptr); | 609 SetView(view->id(), nullptr); |
| 610 } | 610 } |
| OLD | NEW |