Commit 2029f370 authored by estade's avatar estade Committed by Commit bot

CrOS MD Menu - Some more user row tweaks.

As per Sebastien,
- more padding for "No more users" case.
- update text styles for both "Add user" and "No more users".

Also,
- fix active user name font weight (Medium->Normal)
- don't make the "no more users" label a button (it already didn't do
  anything when you clicked it, but there's no sense in making it a
  button).

BUG=667942

Review-Url: https://codereview.chromium.org/2535003002
Cr-Commit-Position: refs/heads/master@{#434874}
parent bf36294b
......@@ -113,9 +113,9 @@ class BorderlessLabelButton : public views::LabelButton {
set_has_ink_drop_action_on_click(true);
set_ink_drop_base_color(kTrayPopupInkDropBaseColor);
set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity);
const int kHorizontalPadding = 8;
const int kHorizontalPadding = 20;
SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding)));
TrayPopupItemStyle style(nullptr, TrayPopupItemStyle::FontStyle::BUTTON);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::BUTTON);
style.SetupLabel(label());
// TODO(tdanderson): Update focus rect for material design. See
// crbug.com/615892
......@@ -139,7 +139,7 @@ class BorderlessLabelButton : public views::LabelButton {
// views::LabelButton:
int GetHeightForWidth(int width) const override {
if (MaterialDesignController::IsSystemTrayMenuMaterial())
return kMenuButtonSize - 2 * kTrayPopupInkDropInset;
return kMenuButtonSize;
return LabelButton::GetHeightForWidth(width);
}
......
......@@ -503,8 +503,8 @@ void UserCardView::AddUserContentMd(LoginStatus login_status) {
if (!user_name_string.empty()) {
user_name = new views::Label(user_name_string);
user_name->SetHorizontalAlignment(gfx::ALIGN_LEFT);
TrayPopupItemStyle user_name_style(nullptr,
TrayPopupItemStyle::FontStyle::TITLE);
TrayPopupItemStyle user_name_style(
TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
user_name_style.SetupLabel(user_name);
}
}
......@@ -519,9 +519,6 @@ void UserCardView::AddUserContentMd(LoginStatus login_status) {
delegate->GetUserInfo(user_index_)->GetDisplayEmail());
if (!user_email_string.empty()) {
user_email = new views::Label(user_email_string);
user_email->SetFontList(
ui::ResourceBundle::GetSharedInstance().GetFontList(
ui::ResourceBundle::SmallFont));
user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT);
TrayPopupItemStyle user_email_style(
nullptr, TrayPopupItemStyle::FontStyle::CAPTION);
......
......@@ -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 =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment