diff options
author | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 06:34:24 +0000 |
---|---|---|
committer | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 06:34:24 +0000 |
commit | b236c1c7bf750fecb04f4439e310f353dd713304 (patch) | |
tree | 35004ecc4b7bc0f6acf70020cb8176de5958100a /ash/system | |
parent | 78ec6e9159fd18c5c3cc9759c18588101729a8aa (diff) | |
download | chromium_src-b236c1c7bf750fecb04f4439e310f353dd713304.zip chromium_src-b236c1c7bf750fecb04f4439e310f353dd713304.tar.gz chromium_src-b236c1c7bf750fecb04f4439e310f353dd713304.tar.bz2 |
Status tray user icon updated for the alternate shelf layout, new icon is larger (32px instead of 27 and completely occludes the status area background behind it), has rounded corners only on the trailing edge (eg: top/bottom right when tray is horizontal, bottom left & right when vertical).
BUG=245012
TBR=oshima@chromium.org
Review URL: https://chromiumcodereview.appspot.com/19267013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211979 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system')
-rw-r--r-- | ash/system/tray/system_tray.cc | 5 | ||||
-rw-r--r-- | ash/system/tray/tray_background_view.cc | 16 | ||||
-rw-r--r-- | ash/system/user/tray_user.cc | 92 |
3 files changed, 89 insertions, 24 deletions
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index e3fcf78..11a8322 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -285,6 +285,11 @@ void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) { (*it)->UpdateAfterLoginStatusChange(login_status); } + // Items default to SHELF_ALIGNMENT_BOTTOM. Update them if the initial + // position of the shelf differs. + if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM) + UpdateAfterShelfAlignmentChange(shelf_alignment()); + SetVisible(true); PreferredSizeChanged(); } diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc index 944e8bb..61095d7 100644 --- a/ash/system/tray/tray_background_view.cc +++ b/ash/system/tray/tray_background_view.cc @@ -279,14 +279,14 @@ void TrayBackgroundView::TrayContainer::UpdateLayout() { int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment; int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment; if (ash::switches::UseAlternateShelfLayout()) { - vertical_padding += kPaddingFromEdgeOfShelf; - horizontal_padding += kPaddingFromEdgeOfShelf; + vertical_padding = kPaddingFromEdgeOfShelf; + horizontal_padding = kPaddingFromEdgeOfShelf; } set_border(views::Border::CreateEmptyBorder( - vertical_padding, - horizontal_padding, - horizontal_padding, - vertical_padding)); + vertical_padding, + horizontal_padding, + horizontal_padding, + vertical_padding)); views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); @@ -296,8 +296,8 @@ void TrayBackgroundView::TrayContainer::UpdateLayout() { int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment; int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment; if (ash::switches::UseAlternateShelfLayout()) { - vertical_padding += kPaddingFromEdgeOfShelf; - horizontal_padding += kPaddingFromEdgeOfShelf; + vertical_padding = kPaddingFromEdgeOfShelf; + horizontal_padding = kPaddingFromEdgeOfShelf; } set_border(views::Border::CreateEmptyBorder( vertical_padding, diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc index 10c07bd..e50aece 100644 --- a/ash/system/user/tray_user.cc +++ b/ash/system/user/tray_user.cc @@ -8,6 +8,7 @@ #include <climits> #include <vector> +#include "ash/ash_switches.h" #include "ash/popup_message.h" #include "ash/session_state_delegate.h" #include "ash/shell.h" @@ -69,6 +70,8 @@ const int kUserCardVerticalPadding = 10; const int kInactiveUserCardVerticalPadding = 4; const int kProfileRoundedCornerRadius = 2; const int kUserIconSize = 27; +const int kUserIconLargeSize = 32; +const int kUserIconLargeCornerRadius = 2; const int kUserLabelToIconPadding = 5; // When a hover border is used, it is starting this many pixels before the icon @@ -129,6 +132,12 @@ class RoundedImageView : public views::View { // receiver's image. void SetImage(const gfx::ImageSkia& img, const gfx::Size& size); + // Set the radii of the corners independantly. + void SetCornerRadii(int top_left, + int top_right, + int bottom_right, + int bottom_left); + private: // Overridden from views::View. virtual gfx::Size GetPreferredSize() OVERRIDE; @@ -137,7 +146,7 @@ class RoundedImageView : public views::View { gfx::ImageSkia image_; gfx::ImageSkia resized_; gfx::Size image_size_; - int corner_radius_; + int corner_radius_[4]; // True if the given user is the active user and the icon should get // painted as active. @@ -334,8 +343,10 @@ class AddUserView : public views::CustomButton, }; RoundedImageView::RoundedImageView(int corner_radius, bool active_user) - : corner_radius_(corner_radius), - active_user_(active_user) {} + : active_user_(active_user) { + for (int i = 0; i < 4; ++i) + corner_radius_[i] = corner_radius; +} RoundedImageView::~RoundedImageView() {} @@ -353,6 +364,16 @@ void RoundedImageView::SetImage(const gfx::ImageSkia& img, } } +void RoundedImageView::SetCornerRadii(int top_left, + int top_right, + int bottom_right, + int bottom_left) { + corner_radius_[0] = top_left; + corner_radius_[1] = top_right; + corner_radius_[2] = bottom_right; + corner_radius_[3] = bottom_left; +} + gfx::Size RoundedImageView::GetPreferredSize() { return gfx::Size(image_size_.width() + GetInsets().width(), image_size_.height() + GetInsets().height()); @@ -363,9 +384,18 @@ void RoundedImageView::OnPaint(gfx::Canvas* canvas) { gfx::Rect image_bounds(size()); image_bounds.ClampToCenteredSize(GetPreferredSize()); image_bounds.Inset(GetInsets()); - const SkScalar kRadius = SkIntToScalar(corner_radius_); + const SkScalar kRadius[8] = { + SkIntToScalar(corner_radius_[0]), + SkIntToScalar(corner_radius_[0]), + SkIntToScalar(corner_radius_[1]), + SkIntToScalar(corner_radius_[1]), + SkIntToScalar(corner_radius_[2]), + SkIntToScalar(corner_radius_[2]), + SkIntToScalar(corner_radius_[3]), + SkIntToScalar(corner_radius_[3]) + }; SkPath path; - path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius, kRadius); + path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius); SkPaint paint; paint.setAntiAlias(true); paint.setXfermodeMode(active_user_ ? SkXfermode::kSrcOver_Mode : @@ -1172,16 +1202,28 @@ void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) { bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL)); } + int icon_size = kUserIconSize; + if (avatar_ && ash::switches::UseAlternateShelfLayout()) { + icon_size = kUserIconLargeSize; + avatar_->SetCornerRadii(0, + kUserIconLargeCornerRadius, + kUserIconLargeCornerRadius, + 0); + avatar_->set_border(NULL); + } if (avatar_) { if (status == user::LOGGED_IN_GUEST) { - avatar_->SetImage(*ui::ResourceBundle::GetSharedInstance(). - GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON).ToImageSkia(), - gfx::Size(kUserIconSize, kUserIconSize)); + int image_name = ash::switches::UseAlternateShelfLayout() ? + IDR_AURA_UBER_TRAY_GUEST_ICON_LARGE : + IDR_AURA_UBER_TRAY_GUEST_ICON; + avatar_->SetImage(*ui::ResourceBundle::GetSharedInstance(). + GetImageNamed(image_name).ToImageSkia(), + gfx::Size(icon_size, icon_size)); } else { avatar_->SetImage( ash::Shell::GetInstance()->session_state_delegate()->GetUserImage( multiprofile_index_), - gfx::Size(kUserIconSize, kUserIconSize)); + gfx::Size(icon_size, icon_size)); } } } @@ -1193,10 +1235,17 @@ void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { if (alignment == SHELF_ALIGNMENT_BOTTOM || alignment == SHELF_ALIGNMENT_TOP) { if (avatar_) { - avatar_->set_border(views::Border::CreateEmptyBorder( - 0, kTrayImageItemHorizontalPaddingBottomAlignment + 2, - 0, kTrayImageItemHorizontalPaddingBottomAlignment)); - + if (ash::switches::UseAlternateShelfLayout()) { + avatar_->set_border(NULL); + avatar_->SetCornerRadii(0, + kUserIconLargeCornerRadius, + kUserIconLargeCornerRadius, + 0); + } else { + avatar_->set_border(views::Border::CreateEmptyBorder( + 0, kTrayImageItemHorizontalPaddingBottomAlignment + 2, + 0, kTrayImageItemHorizontalPaddingBottomAlignment)); + } } if (label_) { label_->set_border(views::Border::CreateEmptyBorder( @@ -1207,8 +1256,17 @@ void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, kUserLabelToIconPadding)); } else { - if (avatar_) - SetTrayImageItemBorder(avatar_, alignment); + if (avatar_) { + if (ash::switches::UseAlternateShelfLayout()) { + avatar_->set_border(NULL); + avatar_->SetCornerRadii(0, + 0, + kUserIconLargeCornerRadius, + kUserIconLargeCornerRadius); + } else { + SetTrayImageItemBorder(avatar_, alignment); + } + } if (label_) { label_->set_border(views::Border::CreateEmptyBorder( kTrayLabelItemVerticalPaddingVeriticalAlignment, @@ -1225,10 +1283,12 @@ void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { void TrayUser::OnUserUpdate() { // Check for null to avoid crbug.com/150944. if (avatar_) { + int icon_size = ash::switches::UseAlternateShelfLayout() ? + kUserIconLargeSize : kUserIconSize; avatar_->SetImage( ash::Shell::GetInstance()->session_state_delegate()->GetUserImage( multiprofile_index_), - gfx::Size(kUserIconSize, kUserIconSize)); + gfx::Size(icon_size, icon_size)); } } |