Chromium Code Reviews| Index: chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
| diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
| index 839b14c86d651c4f6d46bb5b5138266fd3cdb18c..0a396cfbb02a1728341065e752f1249f37191512 100644 |
| --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
| +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
| +#include "chrome/browser/profiles/profiles_state.h" |
| #include "ui/gfx/font.h" |
| #include "ui/views/controls/button/image_button.h" |
| #include "ui/views/controls/label.h" |
| @@ -49,6 +50,9 @@ const int kAvatarLeftSpacing = 2; |
| // Space between the right edge of the avatar and the tabstrip. |
| const int kAvatarRightSpacing = -4; |
| +// How far the new avatar button is from the left of the minimize button. |
| +const int kNewAvatarButtonOffset = 5; |
| + |
| // In restored mode, the New Tab button isn't at the same height as the caption |
| // buttons, but the space will look cluttered if it actually slides under them, |
| // so we stop it when the gap between the two is down to 5 px. |
| @@ -101,7 +105,8 @@ OpaqueBrowserFrameViewLayout::OpaqueBrowserFrameViewLayout( |
| window_icon_(NULL), |
| window_title_(NULL), |
| avatar_label_(NULL), |
| - avatar_button_(NULL) { |
| + avatar_button_(NULL), |
| + new_avatar_button_(NULL) { |
| trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE); |
| trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE); |
| trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE); |
| @@ -130,6 +135,10 @@ gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip( |
| available_width -= trailing_button_start_; |
| available_width -= leading_button_start_; |
| + // The new avatar button is displayed to the left of the caption area buttons. |
| + if (delegate_->ShouldShowAvatar() && new_avatar_button_) |
| + available_width -= new_avatar_button_->width(); |
|
Elliot Glaysher
2013/09/26 21:05:44
This shouldn't be calculated here; rather, it shou
noms (inactive)
2013/10/01 17:42:21
Done.
|
| + |
| if (delegate_->GetAdditionalReservedSpaceInTabStrip()) |
| available_width -= delegate_->GetAdditionalReservedSpaceInTabStrip(); |
| @@ -355,7 +364,17 @@ void OpaqueBrowserFrameViewLayout::LayoutTitleBar(views::View* host) { |
| } |
| } |
| -void OpaqueBrowserFrameViewLayout::LayoutAvatar() { |
| +void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar() { |
|
Elliot Glaysher
2013/09/26 21:05:44
Since the new avatar menu looks like a caption but
noms (inactive)
2013/10/01 17:42:21
I've used the has_trailing_buttons_ boolean that g
Elliot Glaysher
2013/10/01 18:12:56
Yeap! "close:minimize" is the default button layou
noms (inactive)
2013/10/03 19:30:14
After offline conversation, I've made it so that t
|
| + gfx::Size label_size = new_avatar_button_->GetPreferredSize(); |
| + int caption_y = CaptionButtonY(false); |
| + new_avatar_button_->SetBounds( |
| + minimize_button_->x() - label_size.width() - kNewAvatarButtonOffset, |
| + caption_y, |
| + label_size.width(), |
| + caption_y + kCaptionButtonHeightWithPadding); |
|
Elliot Glaysher
2013/09/26 21:05:44
This position calculation is wrong. You can't posi
noms (inactive)
2013/10/01 17:42:21
Done.
|
| +} |
| + |
| +void OpaqueBrowserFrameViewLayout::LayoutIncognitoAvatar() { |
| // Even though the avatar is used for both incognito and profiles we always |
| // use the incognito icon to layout the avatar button. The profile icon |
| // can be customized so we can't depend on its size to perform layout. |
| @@ -372,30 +391,38 @@ void OpaqueBrowserFrameViewLayout::LayoutAvatar() { |
| delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); |
| if (avatar_button_) { |
| avatar_button_->SetBoundsRect(avatar_bounds_); |
|
Elliot Glaysher
2013/09/26 21:05:44
If you're pulling out the code block after this (n
noms (inactive)
2013/10/01 17:42:21
I don't actually know what I was thinking when I s
|
| + } |
| +} |
| - if (avatar_label_) { |
| - // Space between the bottom of the avatar and the bottom of the avatar |
| - // label. |
| - const int kAvatarLabelBottomSpacing = 3; |
| - gfx::Size label_size = avatar_label_->GetPreferredSize(); |
| - // The x-position of the avatar label should be slightly to the left of |
| - // the avatar menu button. Therefore we use the |leading_button_start_| |
| - // value directly. |
| - gfx::Rect label_bounds( |
| - leading_button_start_, |
| - avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), |
| - label_size.width(), |
| - delegate_->ShouldShowAvatar() ? label_size.height() : 0); |
| - avatar_label_->SetBoundsRect(label_bounds); |
| - leading_button_start_ += label_size.width(); |
| - } else { |
| - leading_button_start_ += kAvatarLeftSpacing + incognito_icon.width(); |
| - } |
| +void OpaqueBrowserFrameViewLayout::LayoutAvatar() { |
| + LayoutIncognitoAvatar(); |
| + gfx::ImageSkia incognito_icon = delegate_->GetOTRAvatarIcon(); |
| - // We just add the avatar button size to the minimum size because clicking |
| - // the avatar label does the same thing as clicking the avatar button. |
| - minimum_size_for_buttons_ += kAvatarLeftSpacing + incognito_icon.width(); |
| + int avatar_bottom = GetTabStripInsetsTop(false) + |
| + delegate_->GetTabStripHeight() - kAvatarBottomSpacing; |
| + |
| + if (avatar_label_) { |
| + // Space between the bottom of the avatar and the bottom of the avatar |
| + // label. |
| + const int kAvatarLabelBottomSpacing = 3; |
| + gfx::Size label_size = avatar_label_->GetPreferredSize(); |
| + // The x-position of the avatar label should be slightly to the left of |
| + // the avatar menu button. Therefore we use the |leading_button_start_| |
| + // value directly. |
| + gfx::Rect label_bounds( |
| + leading_button_start_, |
| + avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), |
| + label_size.width(), |
| + delegate_->ShouldShowAvatar() ? label_size.height() : 0); |
| + avatar_label_->SetBoundsRect(label_bounds); |
| + leading_button_start_ += label_size.width(); |
| + } else { |
| + leading_button_start_ += kAvatarLeftSpacing + incognito_icon.width(); |
| } |
| + |
| + // We just add the avatar button size to the minimum size because clicking |
| + // the avatar label does the same thing as clicking the avatar button. |
| + minimum_size_for_buttons_ += kAvatarLeftSpacing + incognito_icon.width(); |
| } |
| void OpaqueBrowserFrameViewLayout::ConfigureButton( |
| @@ -560,6 +587,9 @@ void OpaqueBrowserFrameViewLayout::SetView(int id, views::View* view) { |
| case VIEW_ID_AVATAR_BUTTON: |
| avatar_button_ = view; |
| break; |
| + case VIEW_ID_NEW_AVATAR_BUTTON: |
| + new_avatar_button_ = view; |
| + break; |
| default: |
| NOTIMPLEMENTED() << "Unknown view id " << id; |
| break; |
| @@ -586,7 +616,14 @@ void OpaqueBrowserFrameViewLayout::Layout(views::View* host) { |
| // on the trailing side. |
| leading_button_start_++; |
| - LayoutAvatar(); |
| + if (profiles::IsNewProfileManagementEnabled()) { |
| + if (delegate_->IsOffTheRecord() && !delegate_->IsGuestSession()) |
| + LayoutIncognitoAvatar(); |
| + else |
| + LayoutNewStyleAvatar(); |
| + } else { |
| + LayoutAvatar(); |
| + } |
| client_view_bounds_ = CalculateClientAreaBounds( |
| host->width(), host->height()); |