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

Unified Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 2710543002: Linux/Windows: Adding tooltip in profile switcher menu. (Closed)
Patch Set: Update Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0981f6da1d7692a68dcff7c75e1cc01a0401138c 100644
--- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
@@ -313,20 +313,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 +1732,23 @@ 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);
+ int row_height = EditableProfilePhoto::icon_image_side() +
msarda 2017/02/21 08:51:48 I think this is actually the height of the entire
jlebel 2017/02/21 09:06:18 Done.
+ 2 * (EditableProfilePhoto::badge_spacing() +
+ views::kRelatedControlSmallVerticalSpacing);
+ grid_layout->StartRow(0, 0,
+ avatar_item.signed_in ? (row_height / 2) : row_height);
current_profile_card_ = current_profile_card;
// Profile picture, left-aligned.
@@ -1760,23 +1763,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));
@@ -1792,6 +1786,9 @@ views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView(
// The available links depend on the type of profile that is active.
if (avatar_item.signed_in) {
+ grid_layout->StartRow(1, 0);
+ // Skip first column for the profile icon.
+ grid_layout->SkipColumns(1);
if (switches::IsEnableAccountConsistency()) {
base::string16 button_text = l10n_util::GetStringUTF16(
IsProfileChooser(view_mode_)
@@ -1802,20 +1799,17 @@ views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView(
manage_accounts_button_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
manage_accounts_button_->SetMinSize(
gfx::Size(GetFixedMenuWidth(), kButtonHeight));
- view->AddChildView(manage_accounts_button_);
+ grid_layout->AddView(manage_accounts_button_, 1, 1,
+ views::GridLayout::CENTER,
+ views::GridLayout::CENTER);
} else {
views::Label* email_label = new views::Label(avatar_item.username);
current_profile_card->set_subtitle(email_label);
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->AddView(email_label, 1, 1, views::GridLayout::LEADING,
+ views::GridLayout::LEADING);
}
current_profile_card_->SetAccessibleName(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698