Chromium Code Reviews| Index: chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.cc b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| index e1f40f7308f8a8759e1d5126300b3196ad59b951..ccf9c9b3865cd9eaca78ac8f75e18b304b0691e8 100644 |
| --- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| +++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| @@ -93,6 +93,7 @@ namespace { |
| // Helpers -------------------------------------------------------------------- |
| const int kButtonHeight = 32; |
| +const int kCurrentProfileMenuItemHeight = 56; |
| const int kPasswordCombinedFixedGaiaViewWidth = 360; |
| const int kFixedGaiaViewWidth = 448; |
| const int kFixedAccountRemovalViewWidth = 280; |
| @@ -313,20 +314,6 @@ class SizedContainer : public views::View { |
| gfx::Size preferred_size_; |
| }; |
| -// NonInteractiveContainer ------------------------------------------------- |
| - |
| -// A simple container view that does not process events within subtree. |
| -class NonInteractiveContainer : public views::View { |
| - public: |
| - NonInteractiveContainer() {} |
| - |
| - // views::CanProcessEventsWithinSubtree: |
| - bool CanProcessEventsWithinSubtree() const override { return false; } |
| - |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(NonInteractiveContainer); |
| -}; |
| - |
| // A view to host the GAIA webview overlapped with a back button. This class |
| // is needed to reparent the back button inside a native view so that on |
| // windows, user input can be be properly routed to the button. |
| @@ -1746,6 +1733,21 @@ views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( |
| // Container for the profile photo and avatar/user name. |
| BackgroundColorHoverButton* current_profile_card = |
| new BackgroundColorHoverButton(this, base::string16()); |
| + views::GridLayout* grid_layout = new views::GridLayout(current_profile_card); |
| + current_profile_card->SetLayoutManager(grid_layout); |
| + views::ColumnSet* columns = grid_layout->AddColumnSet(0); |
| + columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin); |
| + columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| + views::GridLayout::USE_PREF, 0, 0); |
| + columns->AddPaddingColumn( |
| + 0, kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing()); |
| + columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| + views::GridLayout::USE_PREF, 0, 0); |
| + columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin); |
| + grid_layout->AddPaddingRow(0, 0); |
| + grid_layout->StartRow(0, 0, avatar_item.signed_in |
| + ? (kCurrentProfileMenuItemHeight / 2) |
|
msarda
2017/02/20 17:01:46
Do you need this new "magic" constant kCurrentProf
msarda
2017/02/20 17:01:46
Should you divide by 2 if there is a single line?
jlebel
2017/02/21 08:28:16
If I don't set the height as half of the total hei
jlebel
2017/02/21 08:28:16
Done.
|
| + : kCurrentProfileMenuItemHeight); |
| current_profile_card_ = current_profile_card; |
| // Profile picture, left-aligned. |
| @@ -1760,23 +1762,14 @@ views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( |
| ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( |
| 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM)); |
| current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| - NonInteractiveContainer* profile_name_container = |
| - new NonInteractiveContainer(); |
| - int name_container_v_spacing = |
| - (current_profile_photo->GetPreferredSize().height() - |
| - current_profile_name->GetPreferredSize().height()) / 2; |
| - views::BoxLayout* profile_name_layout = new views::BoxLayout( |
| - views::BoxLayout::kVertical, 0, name_container_v_spacing, 0); |
| - profile_name_container->SetLayoutManager(profile_name_layout); |
| - profile_name_container->AddChildView(current_profile_name); |
| - |
| - const int between_child_spacing = |
| - kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing(); |
| - current_profile_card_->SetLayoutManager(new views::BoxLayout( |
| - views::BoxLayout::kHorizontal, 0, |
| - views::kRelatedControlSmallVerticalSpacing, between_child_spacing)); |
| - current_profile_card_->AddChildView(current_profile_photo); |
| - current_profile_card_->AddChildView(profile_name_container); |
| + |
| + // The grid layout contains one row if not signed in, and 2 if signed in (the |
| + // second row is for the email created later). Therefore, the profile photo is |
| + // over 2 rows if signed in. |
| + grid_layout->AddView(current_profile_photo, 1, avatar_item.signed_in ? 2 : 1); |
| + grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING, |
| + avatar_item.signed_in ? views::GridLayout::TRAILING |
| + : views::GridLayout::CENTER); |
| current_profile_card_->SetMinSize(gfx::Size( |
| GetFixedMenuWidth(), current_profile_photo->GetPreferredSize().height() + |
| 2 * views::kRelatedControlSmallVerticalSpacing)); |
| @@ -1809,13 +1802,11 @@ views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( |
| email_label->SetElideBehavior(gfx::ELIDE_EMAIL); |
| email_label->SetEnabled(false); |
| email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| - name_container_v_spacing = |
| - (current_profile_photo->GetPreferredSize().height() - |
| - current_profile_name->GetPreferredSize().height() - |
| - email_label->GetPreferredSize().height()) / 2; |
| - profile_name_layout->set_inside_border_insets( |
| - gfx::Insets(name_container_v_spacing, 0)); |
| - profile_name_container->AddChildView(email_label); |
| + grid_layout->StartRow(1, 0); |
| + // Skip first column for the profile icon. |
| + grid_layout->SkipColumns(1); |
| + grid_layout->AddView(email_label, 1, 1, views::GridLayout::LEADING, |
| + views::GridLayout::LEADING); |
| } |
| current_profile_card_->SetAccessibleName( |