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

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

Issue 198063003: Revert of Shelf Cleanup (- binary files) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « ash/system/tray/tray_constants.cc ('k') | ash/system/web_notification/web_notification_tray.cc » ('j') | 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "ui/views/layout/fill_layout.h" 65 #include "ui/views/layout/fill_layout.h"
66 #include "ui/views/mouse_watcher.h" 66 #include "ui/views/mouse_watcher.h"
67 #include "ui/views/painter.h" 67 #include "ui/views/painter.h"
68 #include "ui/views/view.h" 68 #include "ui/views/view.h"
69 #include "ui/views/widget/widget.h" 69 #include "ui/views/widget/widget.h"
70 70
71 namespace { 71 namespace {
72 72
73 const int kUserDetailsVerticalPadding = 5; 73 const int kUserDetailsVerticalPadding = 5;
74 const int kUserCardVerticalPadding = 10; 74 const int kUserCardVerticalPadding = 10;
75 const int kUserIconSize = 32; 75 const int kProfileRoundedCornerRadius = 2;
76 const int kUserIconCornerRadius = 2; 76 const int kUserIconSize = 27;
77 const int kUserIconLargeSize = 32;
78 const int kUserIconLargeCornerRadius = 2;
77 const int kUserLabelToIconPadding = 5; 79 const int kUserLabelToIconPadding = 5;
78 80
79 // When a hover border is used, it is starting this many pixels before the icon 81 // When a hover border is used, it is starting this many pixels before the icon
80 // position. 82 // position.
81 const int kTrayUserTileHoverBorderInset = 10; 83 const int kTrayUserTileHoverBorderInset = 10;
82 84
83 // The border color of the user button. 85 // The border color of the user button.
84 const SkColor kBorderColor = 0xffdcdcdc; 86 const SkColor kBorderColor = 0xffdcdcdc;
85 87
86 // The invisible word joiner character, used as a marker to indicate the start 88 // The invisible word joiner character, used as a marker to indicate the start
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 user_card_view_->AddChildView(details); 906 user_card_view_->AddChildView(details);
905 } else { 907 } else {
906 if (username) 908 if (username)
907 user_card_view_->AddChildView(username); 909 user_card_view_->AddChildView(username);
908 if (additional) 910 if (additional)
909 user_card_view_->AddChildView(additional); 911 user_card_view_->AddChildView(additional);
910 } 912 }
911 } 913 }
912 914
913 views::View* UserView::CreateIconForUserCard(user::LoginStatus login) { 915 views::View* UserView::CreateIconForUserCard(user::LoginStatus login) {
914 RoundedImageView* icon = new RoundedImageView(kUserIconCornerRadius, 916 RoundedImageView* icon = new RoundedImageView(kProfileRoundedCornerRadius,
915 multiprofile_index_ == 0); 917 multiprofile_index_ == 0);
916 icon->SetEnabled(false); 918 icon->SetEnabled(false);
917 if (login == user::LOGGED_IN_GUEST) { 919 if (login == user::LOGGED_IN_GUEST) {
918 icon->SetImage(*ui::ResourceBundle::GetSharedInstance(). 920 icon->SetImage(*ui::ResourceBundle::GetSharedInstance().
919 GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON).ToImageSkia(), 921 GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON).ToImageSkia(),
920 gfx::Size(kUserIconSize, kUserIconSize)); 922 gfx::Size(kUserIconSize, kUserIconSize));
921 } else { 923 } else {
922 icon->SetImage( 924 icon->SetImage(
923 Shell::GetInstance()->session_state_delegate()-> 925 Shell::GetInstance()->session_state_delegate()->
924 GetUserImage(multiprofile_index_), 926 GetUserImage(multiprofile_index_),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 kTrayPopupPaddingHorizontal - kTrayUserTileHoverBorderInset, 1068 kTrayPopupPaddingHorizontal - kTrayUserTileHoverBorderInset,
1067 kUserCardVerticalPadding, 1069 kUserCardVerticalPadding,
1068 kTrayPopupPaddingHorizontal - kTrayUserTileHoverBorderInset)); 1070 kTrayPopupPaddingHorizontal - kTrayUserTileHoverBorderInset));
1069 1071
1070 add_user_->SetLayoutManager(new views::BoxLayout( 1072 add_user_->SetLayoutManager(new views::BoxLayout(
1071 views::BoxLayout::kHorizontal, 0, 0 , kTrayPopupPaddingBetweenItems)); 1073 views::BoxLayout::kHorizontal, 0, 0 , kTrayPopupPaddingBetweenItems));
1072 AddChildViewAt(add_user_, 0); 1074 AddChildViewAt(add_user_, 0);
1073 1075
1074 // Add the [+] icon which is also the anchor for messages. 1076 // Add the [+] icon which is also the anchor for messages.
1075 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 1077 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
1076 RoundedImageView* icon = new RoundedImageView(kUserIconCornerRadius, 1078 RoundedImageView* icon = new RoundedImageView(kProfileRoundedCornerRadius,
1077 true); 1079 true);
1078 anchor_ = icon; 1080 anchor_ = icon;
1079 icon->SetImage(*ui::ResourceBundle::GetSharedInstance(). 1081 icon->SetImage(*ui::ResourceBundle::GetSharedInstance().
1080 GetImageNamed(IDR_AURA_UBER_TRAY_ADD_MULTIPROFILE_USER).ToImageSkia(), 1082 GetImageNamed(IDR_AURA_UBER_TRAY_ADD_MULTIPROFILE_USER).ToImageSkia(),
1081 gfx::Size(kUserIconSize, kUserIconSize)); 1083 gfx::Size(kUserIconSize, kUserIconSize));
1082 add_user_->AddChildView(icon); 1084 add_user_->AddChildView(icon);
1083 1085
1084 // Add the command text. 1086 // Add the command text.
1085 views::Label* command_label = new views::Label( 1087 views::Label* command_label = new views::Label(
1086 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT)); 1088 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 (need_label != (label_ != NULL))) { 1199 (need_label != (label_ != NULL))) {
1198 layout_view_->RemoveAllChildViews(true); 1200 layout_view_->RemoveAllChildViews(true);
1199 if (need_label) { 1201 if (need_label) {
1200 label_ = new views::Label; 1202 label_ = new views::Label;
1201 SetupLabelForTray(label_); 1203 SetupLabelForTray(label_);
1202 layout_view_->AddChildView(label_); 1204 layout_view_->AddChildView(label_);
1203 } else { 1205 } else {
1204 label_ = NULL; 1206 label_ = NULL;
1205 } 1207 }
1206 if (need_avatar) { 1208 if (need_avatar) {
1207 avatar_ = new tray::RoundedImageView(kUserIconCornerRadius, true); 1209 avatar_ = new tray::RoundedImageView(kProfileRoundedCornerRadius, true);
1208 layout_view_->AddChildView(avatar_); 1210 layout_view_->AddChildView(avatar_);
1209 } else { 1211 } else {
1210 avatar_ = NULL; 1212 avatar_ = NULL;
1211 } 1213 }
1212 } 1214 }
1213 1215
1214 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 1216 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
1215 if (status == user::LOGGED_IN_LOCALLY_MANAGED) { 1217 if (status == user::LOGGED_IN_LOCALLY_MANAGED) {
1216 label_->SetText( 1218 label_->SetText(
1217 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL)); 1219 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL));
1218 } else if (status == user::LOGGED_IN_GUEST) { 1220 } else if (status == user::LOGGED_IN_GUEST) {
1219 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_GUEST_LABEL)); 1221 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_GUEST_LABEL));
1220 } 1222 }
1221 1223
1222 if (avatar_) { 1224 if (avatar_ && switches::UseAlternateShelfLayout()) {
1223 avatar_->SetCornerRadii( 1225 avatar_->SetCornerRadii(
1224 0, kUserIconCornerRadius, kUserIconCornerRadius, 0); 1226 0, kUserIconLargeCornerRadius, kUserIconLargeCornerRadius, 0);
1225 avatar_->SetBorder(views::Border::NullBorder()); 1227 avatar_->SetBorder(views::Border::NullBorder());
1226 } 1228 }
1227 UpdateAvatarImage(status); 1229 UpdateAvatarImage(status);
1228 1230
1229 // Update layout after setting label_ and avatar_ with new login status. 1231 // Update layout after setting label_ and avatar_ with new login status.
1230 UpdateLayoutOfItem(); 1232 UpdateLayoutOfItem();
1231 } 1233 }
1232 1234
1233 void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 1235 void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
1234 // Inactive users won't have a layout. 1236 // Inactive users won't have a layout.
1235 if (!layout_view_) 1237 if (!layout_view_)
1236 return; 1238 return;
1237 if (alignment == SHELF_ALIGNMENT_BOTTOM || 1239 if (alignment == SHELF_ALIGNMENT_BOTTOM ||
1238 alignment == SHELF_ALIGNMENT_TOP) { 1240 alignment == SHELF_ALIGNMENT_TOP) {
1239 if (avatar_) { 1241 if (avatar_) {
1240 avatar_->SetBorder(views::Border::NullBorder()); 1242 if (switches::UseAlternateShelfLayout()) {
1241 avatar_->SetCornerRadii( 1243 avatar_->SetBorder(views::Border::NullBorder());
1242 0, kUserIconCornerRadius, kUserIconCornerRadius, 0); 1244 avatar_->SetCornerRadii(
1245 0, kUserIconLargeCornerRadius, kUserIconLargeCornerRadius, 0);
1246 } else {
1247 avatar_->SetBorder(views::Border::CreateEmptyBorder(
1248 0,
1249 kTrayImageItemHorizontalPaddingBottomAlignment + 2,
1250 0,
1251 kTrayImageItemHorizontalPaddingBottomAlignment));
1252 }
1243 } 1253 }
1244 if (label_) { 1254 if (label_) {
1245 label_->SetBorder(views::Border::CreateEmptyBorder( 1255 label_->SetBorder(views::Border::CreateEmptyBorder(
1246 0, 1256 0,
1247 kTrayLabelItemHorizontalPaddingBottomAlignment, 1257 kTrayLabelItemHorizontalPaddingBottomAlignment,
1248 0, 1258 0,
1249 kTrayLabelItemHorizontalPaddingBottomAlignment)); 1259 kTrayLabelItemHorizontalPaddingBottomAlignment));
1250 } 1260 }
1251 layout_view_->SetLayoutManager( 1261 layout_view_->SetLayoutManager(
1252 new views::BoxLayout(views::BoxLayout::kHorizontal, 1262 new views::BoxLayout(views::BoxLayout::kHorizontal,
1253 0, 0, kUserLabelToIconPadding)); 1263 0, 0, kUserLabelToIconPadding));
1254 } else { 1264 } else {
1255 if (avatar_) { 1265 if (avatar_) {
1256 avatar_->SetBorder(views::Border::NullBorder()); 1266 if (switches::UseAlternateShelfLayout()) {
1257 avatar_->SetCornerRadii( 1267 avatar_->SetBorder(views::Border::NullBorder());
1258 0, 0, kUserIconCornerRadius, kUserIconCornerRadius); 1268 avatar_->SetCornerRadii(
1269 0, 0, kUserIconLargeCornerRadius, kUserIconLargeCornerRadius);
1270 } else {
1271 SetTrayImageItemBorder(avatar_, alignment);
1272 }
1259 } 1273 }
1260 if (label_) { 1274 if (label_) {
1261 label_->SetBorder(views::Border::CreateEmptyBorder( 1275 label_->SetBorder(views::Border::CreateEmptyBorder(
1262 kTrayLabelItemVerticalPaddingVerticalAlignment, 1276 kTrayLabelItemVerticalPaddingVerticalAlignment,
1263 kTrayLabelItemHorizontalPaddingBottomAlignment, 1277 kTrayLabelItemHorizontalPaddingBottomAlignment,
1264 kTrayLabelItemVerticalPaddingVerticalAlignment, 1278 kTrayLabelItemVerticalPaddingVerticalAlignment,
1265 kTrayLabelItemHorizontalPaddingBottomAlignment)); 1279 kTrayLabelItemHorizontalPaddingBottomAlignment));
1266 } 1280 }
1267 layout_view_->SetLayoutManager( 1281 layout_view_->SetLayoutManager(
1268 new views::BoxLayout(views::BoxLayout::kVertical, 1282 new views::BoxLayout(views::BoxLayout::kVertical,
(...skipping 21 matching lines...) Expand all
1290 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()); 1304 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus());
1291 } 1305 }
1292 1306
1293 void TrayUser::UpdateAvatarImage(user::LoginStatus status) { 1307 void TrayUser::UpdateAvatarImage(user::LoginStatus status) {
1294 SessionStateDelegate* session_state_delegate = 1308 SessionStateDelegate* session_state_delegate =
1295 Shell::GetInstance()->session_state_delegate(); 1309 Shell::GetInstance()->session_state_delegate();
1296 if (!avatar_ || 1310 if (!avatar_ ||
1297 GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) 1311 GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers())
1298 return; 1312 return;
1299 1313
1314 int icon_size = switches::UseAlternateShelfLayout() ?
1315 kUserIconLargeSize : kUserIconSize;
1316
1300 avatar_->SetImage( 1317 avatar_->SetImage(
1301 Shell::GetInstance()->session_state_delegate()->GetUserImage( 1318 Shell::GetInstance()->session_state_delegate()->GetUserImage(
1302 GetTrayIndex()), 1319 GetTrayIndex()),
1303 gfx::Size(kUserIconSize, kUserIconSize)); 1320 gfx::Size(icon_size, icon_size));
1304 1321
1305 // Unit tests might come here with no images for some users. 1322 // Unit tests might come here with no images for some users.
1306 if (avatar_->size().IsEmpty()) 1323 if (avatar_->size().IsEmpty())
1307 avatar_->SetSize(gfx::Size(kUserIconSize, kUserIconSize)); 1324 avatar_->SetSize(gfx::Size(icon_size, icon_size));
1308 } 1325 }
1309 1326
1310 MultiProfileIndex TrayUser::GetTrayIndex() { 1327 MultiProfileIndex TrayUser::GetTrayIndex() {
1311 Shell* shell = Shell::GetInstance(); 1328 Shell* shell = Shell::GetInstance();
1312 // If multi profile is not enabled we can use the normal index. 1329 // If multi profile is not enabled we can use the normal index.
1313 if (!shell->delegate()->IsMultiProfilesEnabled()) 1330 if (!shell->delegate()->IsMultiProfilesEnabled())
1314 return multiprofile_index_; 1331 return multiprofile_index_;
1315 // In case of multi profile we need to mirror the indices since the system 1332 // In case of multi profile we need to mirror the indices since the system
1316 // tray items are in the reverse order then the menu items. 1333 // tray items are in the reverse order then the menu items.
1317 return shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers() - 1334 return shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers() -
1318 1 - multiprofile_index_; 1335 1 - multiprofile_index_;
1319 } 1336 }
1320 1337
1321 void TrayUser::UpdateLayoutOfItem() { 1338 void TrayUser::UpdateLayoutOfItem() {
1322 internal::RootWindowController* controller = 1339 internal::RootWindowController* controller =
1323 internal::GetRootWindowController( 1340 internal::GetRootWindowController(
1324 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow()); 1341 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow());
1325 if (controller && controller->shelf()) { 1342 if (controller && controller->shelf()) {
1326 UpdateAfterShelfAlignmentChange( 1343 UpdateAfterShelfAlignmentChange(
1327 controller->GetShelfLayoutManager()->GetAlignment()); 1344 controller->GetShelfLayoutManager()->GetAlignment());
1328 } 1345 }
1329 } 1346 }
1330 1347
1331 } // namespace internal 1348 } // namespace internal
1332 } // namespace ash 1349 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_constants.cc ('k') | ash/system/web_notification/web_notification_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698