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

Unified Diff: ash/common/system/user/user_view.cc

Issue 2535003002: CrOS MD Menu - Some more user row tweaks. (Closed)
Patch Set: sign out button improvements Created 4 years, 1 month 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 | « ash/common/system/user/user_card_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/user/user_view.cc
diff --git a/ash/common/system/user/user_view.cc b/ash/common/system/user/user_view.cc
index b2f17ddd5299e839c1d577643fdcfcfbd56b67c0..ef5159cf910c6aeaab2c1d6d888a8ea8c47194de 100644
--- a/ash/common/system/user/user_view.cc
+++ b/ash/common/system/user/user_view.cc
@@ -16,6 +16,7 @@
#include "ash/common/system/tray/system_tray_controller.h"
#include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/system/tray/tray_constants.h"
+#include "ash/common/system/tray/tray_popup_item_style.h"
#include "ash/common/system/tray/tray_popup_label_button.h"
#include "ash/common/system/tray/tray_popup_label_button_border.h"
#include "ash/common/system/tray/tray_popup_utils.h"
@@ -104,16 +105,16 @@ bool IsMultiProfileSupportedAndUserActive() {
}
// Creates the view shown in the user switcher popup ("AddUserMenuOption").
-views::View* CreateAddUserView(AddUserSessionPolicy policy) {
+views::View* CreateAddUserView(AddUserSessionPolicy policy,
+ views::ButtonListener* listener) {
DCHECK(UseMd());
auto view = new views::View;
- auto layout = new views::BoxLayout(
- views::BoxLayout::kHorizontal, (kMenuButtonSize - kMenuIconSize) / 2,
- kMenuSeparatorVerticalPadding, kTrayPopupPaddingBetweenItems);
+ const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2;
+ auto layout =
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
+ kTrayPopupLabelHorizontalPadding + icon_padding);
layout->set_minimum_cross_axis_size(
- policy == AddUserSessionPolicy::ALLOWED
- ? GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)
- : 56);
+ GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT));
view->SetLayoutManager(layout);
view->set_background(
views::Background::CreateSolidBackground(kBackgroundColor));
@@ -143,7 +144,29 @@ views::View* CreateAddUserView(AddUserSessionPolicy policy) {
auto command_label = new views::Label(l10n_util::GetStringUTF16(message_id));
command_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
command_label->SetMultiLine(true);
+
+ TrayPopupItemStyle label_style(
+ TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
+ int vertical_padding = kMenuSeparatorVerticalPadding;
+ if (policy != AddUserSessionPolicy::ALLOWED) {
+ label_style.set_font_style(TrayPopupItemStyle::FontStyle::CAPTION);
+ label_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE);
+ vertical_padding += kMenuSeparatorVerticalPadding;
+ }
+ label_style.SetupLabel(command_label);
view->AddChildView(command_label);
+ view->SetBorder(views::CreateEmptyBorder(vertical_padding, icon_padding,
+ vertical_padding,
+ kTrayPopupLabelHorizontalPadding));
+ if (policy == AddUserSessionPolicy::ALLOWED) {
+ auto button =
+ new ButtonFromView(view, listener, TrayPopupInkDropStyle::INSET_BOUNDS,
+ false, gfx::Insets());
+ button->SetAccessibleName(
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
+ return button;
+ }
+
return view;
}
@@ -473,10 +496,7 @@ void UserView::AddLogoutButton(LoginStatus login) {
logout_button->SetAccessibleName(title);
logout_button_ = logout_button;
if (UseMd()) {
- views::View* separator = TrayPopupUtils::CreateVerticalSeparator();
- separator->SetBorder(views::CreateEmptyBorder(
- gfx::Insets(0, 0, 0, kTrayPopupLabelHorizontalPadding)));
- AddChildView(separator);
+ AddChildView(TrayPopupUtils::CreateVerticalSeparator());
} else if (login == LoginStatus::PUBLIC) {
// In public account mode, the logout button border has a custom color.
std::unique_ptr<TrayPopupLabelButtonBorder> border(
@@ -609,15 +629,6 @@ void UserView::ToggleAddUserMenuOption() {
add_user_enabled_ = add_user_policy == AddUserSessionPolicy::ALLOWED;
if (UseMd()) {
- ButtonFromView* button = new ButtonFromView(
- CreateAddUserView(add_user_policy), add_user_enabled_ ? this : nullptr,
- IsActiveUser() ? TrayPopupInkDropStyle::INSET_BOUNDS
- : TrayPopupInkDropStyle::FILL_BOUNDS,
- false, gfx::Insets());
- button->SetAccessibleName(
- l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
- button->ForceBorderVisible(true);
-
// Position the widget on top of the user card view (which is still in the
// system menu). The top half of the widget will be transparent to allow
// the active user to show through.
@@ -631,8 +642,14 @@ void UserView::ToggleAddUserMenuOption() {
views::CreateSolidSidedBorder(0, 0, 0, kSeparatorWidth,
kBackgroundColor),
gfx::Insets(row_height, 0, 0, 0)));
+ views::View* add_user_padding = new views::View();
+ add_user_padding->SetBorder(views::CreateSolidSidedBorder(
+ kMenuSeparatorVerticalPadding, 0, 0, 0, kBackgroundColor));
+ views::View* add_user_view = CreateAddUserView(add_user_policy, this);
+ add_user_padding->AddChildView(add_user_view);
+ add_user_padding->SetLayoutManager(new views::FillLayout());
+ container->AddChildView(add_user_padding);
container->SetLayoutManager(new views::FillLayout());
- container->AddChildView(button);
add_menu_option_->SetContentsView(container);
bounds.set_height(container->GetPreferredSize().height());
@@ -644,8 +661,8 @@ void UserView::ToggleAddUserMenuOption() {
// We activate the entry automatically if invoked with focus.
if (add_user_enabled_ && user_card_view_->HasFocus()) {
- button->GetFocusManager()->SetFocusedView(button);
- user_card_view_->GetFocusManager()->SetFocusedView(button);
+ add_user_view->GetFocusManager()->SetFocusedView(add_user_view);
+ user_card_view_->GetFocusManager()->SetFocusedView(add_user_view);
}
} else {
AddUserView* add_user_view =
« no previous file with comments | « ash/common/system/user/user_card_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698