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

Side by Side Diff: ash/system/user/tray_user.cc

Issue 15738017: Vertically centering the user name for guest mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed merge problem Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/user/tray_user.h" 5 #include "ash/system/user/tray_user.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <climits> 8 #include <climits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 icon->set_border(views::Border::CreateEmptyBorder( 792 icon->set_border(views::Border::CreateEmptyBorder(
793 0, kTrayUserTileHoverBorderInset, 0, 0)); 793 0, kTrayUserTileHoverBorderInset, 0, 0));
794 set_border(views::Border::CreateEmptyBorder( 794 set_border(views::Border::CreateEmptyBorder(
795 kUserCardVerticalPadding, 795 kUserCardVerticalPadding,
796 kTrayPopupPaddingHorizontal - kTrayUserTileHoverBorderInset, 796 kTrayPopupPaddingHorizontal - kTrayUserTileHoverBorderInset,
797 kUserCardVerticalPadding, 797 kUserCardVerticalPadding,
798 kTrayPopupPaddingHorizontal)); 798 kTrayPopupPaddingHorizontal));
799 } 799 }
800 ash::SessionStateDelegate* delegate = 800 ash::SessionStateDelegate* delegate =
801 ash::Shell::GetInstance()->session_state_delegate(); 801 ash::Shell::GetInstance()->session_state_delegate();
802 views::View* details = new views::View;
803 details->SetLayoutManager(new views::BoxLayout(
804 views::BoxLayout::kVertical, 0, kUserDetailsVerticalPadding, 0));
805 views::Label* username = NULL; 802 views::Label* username = NULL;
806 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 803 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
807 if (!multiprofile_index_) { 804 if (!multiprofile_index_) {
808 views::Label* username = new views::Label( 805 username = new views::Label(
809 login == ash::user::LOGGED_IN_GUEST ? 806 login == ash::user::LOGGED_IN_GUEST ?
810 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_GUEST_LABEL) : 807 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_GUEST_LABEL) :
811 delegate->GetUserDisplayName(multiprofile_index_)); 808 delegate->GetUserDisplayName(multiprofile_index_));
812 username->SetHorizontalAlignment(gfx::ALIGN_LEFT); 809 username->SetHorizontalAlignment(gfx::ALIGN_LEFT);
813 details->AddChildView(username);
814 } 810 }
815 811
816 views::Label* additional = NULL; 812 views::Label* additional = NULL;
817 if (login != ash::user::LOGGED_IN_GUEST) { 813 if (login != ash::user::LOGGED_IN_GUEST) {
818 additional = new views::Label(); 814 additional = new views::Label();
819 additional->SetText(login == ash::user::LOGGED_IN_LOCALLY_MANAGED ? 815 additional->SetText(login == ash::user::LOGGED_IN_LOCALLY_MANAGED ?
820 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL) : 816 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL) :
821 UTF8ToUTF16(delegate->GetUserEmail(multiprofile_index_))); 817 UTF8ToUTF16(delegate->GetUserEmail(multiprofile_index_)));
822 818
823 additional->SetFont(bundle.GetFont(ui::ResourceBundle::SmallFont)); 819 additional->SetFont(bundle.GetFont(ui::ResourceBundle::SmallFont));
824 additional->SetHorizontalAlignment(gfx::ALIGN_LEFT); 820 additional->SetHorizontalAlignment(gfx::ALIGN_LEFT);
825 details->AddChildView(additional);
826 } 821 }
827 822
828 // Adjust text properties dependent on if it is an active or inactive user. 823 // Adjust text properties dependent on if it is an active or inactive user.
829 if (multiprofile_index_) { 824 if (multiprofile_index_) {
830 // Fade the text of non active users to 50%. 825 // Fade the text of non active users to 50%.
831 SkColor text_color = additional->enabled_color(); 826 SkColor text_color = additional->enabled_color();
832 text_color = SkColorSetA(text_color, SkColorGetA(text_color) / 2); 827 text_color = SkColorSetA(text_color, SkColorGetA(text_color) / 2);
833 if (additional) 828 if (additional)
834 additional->SetDisabledColor(text_color); 829 additional->SetDisabledColor(text_color);
835 if (username) 830 if (username)
836 username->SetDisabledColor(text_color); 831 username->SetDisabledColor(text_color);
837 } 832 }
838 833
839 // Use a small font for email address if username exists as well. 834 if (additional && username) {
840 if (username) 835 views::View* details = new views::View;
841 additional->SetFont(bundle.GetFont(ui::ResourceBundle::SmallFont)); 836 details->SetLayoutManager(new views::BoxLayout(
842 837 views::BoxLayout::kVertical, 0, kUserDetailsVerticalPadding, 0));
843 user_card_view_->AddChildView(details); 838 details->AddChildView(username);
839 details->AddChildView(additional);
840 user_card_view_->AddChildView(details);
841 } else {
842 if (username)
843 user_card_view_->AddChildView(username);
844 if (additional)
845 user_card_view_->AddChildView(additional);
846 }
844 } 847 }
845 848
846 views::View* UserView::CreateIconForUserCard(ash::user::LoginStatus login) { 849 views::View* UserView::CreateIconForUserCard(ash::user::LoginStatus login) {
847 RoundedImageView* icon = new RoundedImageView(kProfileRoundedCornerRadius, 850 RoundedImageView* icon = new RoundedImageView(kProfileRoundedCornerRadius,
848 multiprofile_index_ == 0); 851 multiprofile_index_ == 0);
849 icon->SetEnabled(false); 852 icon->SetEnabled(false);
850 if (login == ash::user::LOGGED_IN_GUEST) { 853 if (login == ash::user::LOGGED_IN_GUEST) {
851 icon->SetImage(*ui::ResourceBundle::GetSharedInstance(). 854 icon->SetImage(*ui::ResourceBundle::GetSharedInstance().
852 GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON).ToImageSkia(), 855 GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON).ToImageSkia(),
853 gfx::Size(kUserIconSize, kUserIconSize)); 856 gfx::Size(kUserIconSize, kUserIconSize));
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 if (avatar_) { 1213 if (avatar_) {
1211 avatar_->SetImage( 1214 avatar_->SetImage(
1212 ash::Shell::GetInstance()->session_state_delegate()->GetUserImage( 1215 ash::Shell::GetInstance()->session_state_delegate()->GetUserImage(
1213 multiprofile_index_), 1216 multiprofile_index_),
1214 gfx::Size(kUserIconSize, kUserIconSize)); 1217 gfx::Size(kUserIconSize, kUserIconSize));
1215 } 1218 }
1216 } 1219 }
1217 1220
1218 } // namespace internal 1221 } // namespace internal
1219 } // namespace ash 1222 } // namespace ash
OLDNEW
« 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