Commit ced81f04 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Hide tooltip in user chooser view.

This CL hides tooltip in user chooser view when there is enough space to
show both the name and the email.

TEST=manual
BUG=889415

Change-Id: I0c02e4bb78c0dfbd81700afe24b8cc9ebe423ea2
Reviewed-on: https://chromium-review.googlesource.com/c/1304179Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603723}
parent ed289cec
......@@ -174,7 +174,9 @@ UserItemButton::UserItemButton(int user_index,
: Button(this),
user_index_(user_index),
controller_(controller),
capture_icon_(new views::ImageView) {
capture_icon_(new views::ImageView),
name_(new views::Label),
email_(new views::Label) {
auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::kHorizontal, gfx::Insets(0, kUnifiedTopShortcutSpacing),
kUnifiedTopShortcutSpacing));
......@@ -193,19 +195,17 @@ UserItemButton::UserItemButton(int user_index,
const mojom::UserSession* const user_session =
Shell::Get()->session_controller()->GetUserSession(user_index);
auto* name = new views::Label(
base::UTF8ToUTF16(user_session->user_info->display_name));
name->SetEnabledColor(kUnifiedMenuTextColor);
name->SetAutoColorReadabilityEnabled(false);
name->SetSubpixelRenderingEnabled(false);
vertical_labels->AddChildView(name);
name_->SetText(base::UTF8ToUTF16(user_session->user_info->display_name));
name_->SetEnabledColor(kUnifiedMenuTextColor);
name_->SetAutoColorReadabilityEnabled(false);
name_->SetSubpixelRenderingEnabled(false);
vertical_labels->AddChildView(name_);
auto* email = new views::Label(
base::UTF8ToUTF16(user_session->user_info->display_email));
email->SetEnabledColor(kUnifiedMenuSecondaryTextColor);
email->SetAutoColorReadabilityEnabled(false);
email->SetSubpixelRenderingEnabled(false);
vertical_labels->AddChildView(email);
email_->SetText(base::UTF8ToUTF16(user_session->user_info->display_email));
email_->SetEnabledColor(kUnifiedMenuSecondaryTextColor);
email_->SetAutoColorReadabilityEnabled(false);
email_->SetSubpixelRenderingEnabled(false);
vertical_labels->AddChildView(email_);
AddChildView(vertical_labels);
layout->SetFlexForView(vertical_labels, 1);
......@@ -251,6 +251,16 @@ void UserItemButton::SetCaptureState(mojom::MediaCaptureState capture_state) {
capture_icon_->set_tooltip_text(l10n_util::GetStringUTF16(res_id));
}
bool UserItemButton::GetTooltipText(const gfx::Point& p,
base::string16* tooltip) const {
// If both of them are full shown, hide the tooltip.
if (name_->GetPreferredSize().width() <= name_->width() &&
email_->GetPreferredSize().width() <= email_->width()) {
return false;
}
return views::Button::GetTooltipText(p, tooltip);
}
void UserItemButton::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (user_index_ > 0)
......
......@@ -11,6 +11,7 @@
namespace views {
class ImageView;
class Label;
} // namespace views
namespace ash {
......@@ -33,6 +34,10 @@ class UserItemButton : public views::Button, public views::ButtonListener {
void SetCaptureState(mojom::MediaCaptureState capture_states);
// views::Button:
bool GetTooltipText(const gfx::Point& p,
base::string16* tooltip) const override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
......@@ -40,6 +45,8 @@ class UserItemButton : public views::Button, public views::ButtonListener {
const int user_index_;
UnifiedSystemTrayController* const controller_;
views::ImageView* const capture_icon_;
views::Label* const name_;
views::Label* const email_;
DISALLOW_COPY_AND_ASSIGN(UserItemButton);
};
......
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