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

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

Issue 10809008: Make spacing between uber tray items consistent with UI spec. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
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 "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h"
8 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/system/tray/tray_constants.h" 10 #include "ash/system/tray/tray_constants.h"
10 #include "ash/system/tray/tray_item_view.h" 11 #include "ash/system/tray/tray_item_view.h"
11 #include "ash/system/tray/tray_views.h" 12 #include "ash/system/tray/tray_views.h"
12 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
13 #include "grit/ash_strings.h" 14 #include "grit/ash_strings.h"
14 #include "skia/ext/image_operations.h" 15 #include "skia/ext/image_operations.h"
15 #include "third_party/skia/include/core/SkCanvas.h" 16 #include "third_party/skia/include/core/SkCanvas.h"
16 #include "third_party/skia/include/core/SkPaint.h" 17 #include "third_party/skia/include/core/SkPaint.h"
17 #include "third_party/skia/include/core/SkPath.h" 18 #include "third_party/skia/include/core/SkPath.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
21 #include "ui/gfx/image/image_skia_operations.h" 22 #include "ui/gfx/image/image_skia_operations.h"
22 #include "ui/gfx/size.h" 23 #include "ui/gfx/size.h"
23 #include "ui/gfx/skia_util.h" 24 #include "ui/gfx/skia_util.h"
24 #include "ui/views/controls/button/button.h" 25 #include "ui/views/controls/button/button.h"
25 #include "ui/views/controls/button/text_button.h" 26 #include "ui/views/controls/button/text_button.h"
26 #include "ui/views/controls/image_view.h" 27 #include "ui/views/controls/image_view.h"
27 #include "ui/views/controls/label.h" 28 #include "ui/views/controls/label.h"
28 #include "ui/views/layout/box_layout.h" 29 #include "ui/views/layout/box_layout.h"
29 #include "ui/views/view.h" 30 #include "ui/views/view.h"
30 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
31 32
32 namespace { 33 namespace {
33 34
34 const int kUserInfoVerticalPadding = 10; 35 const int kUserInfoVerticalPadding = 10;
35 const int kUserInfoEmptyBorderLeftPadding = 6;
36 const int kUserInfoEmptyBorderRightPadding = 1;
37 const int kUserIconSize = 27; 36 const int kUserIconSize = 27;
38 37
39 } // namespace 38 } // namespace
40 39
41 namespace ash { 40 namespace ash {
42 namespace internal { 41 namespace internal {
43 42
44 namespace tray { 43 namespace tray {
45 44
46 // A custom image view with rounded edges. 45 // A custom image view with rounded edges.
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 : user_(NULL), 249 : user_(NULL),
251 avatar_(NULL) { 250 avatar_(NULL) {
252 } 251 }
253 252
254 TrayUser::~TrayUser() { 253 TrayUser::~TrayUser() {
255 } 254 }
256 255
257 views::View* TrayUser::CreateTrayView(user::LoginStatus status) { 256 views::View* TrayUser::CreateTrayView(user::LoginStatus status) {
258 CHECK(avatar_ == NULL); 257 CHECK(avatar_ == NULL);
259 avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius); 258 avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius);
260 avatar_->set_border(views::Border::CreateEmptyBorder( 259 UpdateAfterShelfAlignmentChange(
261 0, kUserInfoEmptyBorderLeftPadding, 0, kUserInfoEmptyBorderRightPadding)); 260 ash::Shell::GetInstance()->system_tray()->shelf_alignment());
262 UpdateAfterLoginStatusChange(status); 261 UpdateAfterLoginStatusChange(status);
263 return avatar_; 262 return avatar_;
264 } 263 }
265 264
266 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { 265 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) {
267 if (status == user::LOGGED_IN_NONE) 266 if (status == user::LOGGED_IN_NONE)
268 return NULL; 267 return NULL;
269 268
270 CHECK(user_ == NULL); 269 CHECK(user_ == NULL);
271 user_ = new tray::UserView(status); 270 user_ = new tray::UserView(status);
(...skipping 20 matching lines...) Expand all
292 status != user::LOGGED_IN_GUEST) { 291 status != user::LOGGED_IN_GUEST) {
293 avatar_->SetImage( 292 avatar_->SetImage(
294 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), 293 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
295 gfx::Size(kUserIconSize, kUserIconSize)); 294 gfx::Size(kUserIconSize, kUserIconSize));
296 avatar_->SetVisible(true); 295 avatar_->SetVisible(true);
297 } else { 296 } else {
298 avatar_->SetVisible(false); 297 avatar_->SetVisible(false);
299 } 298 }
300 } 299 }
301 300
301 void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
302 SetTrayImageItemBorder(avatar_, alignment);
303 }
304
302 void TrayUser::OnUserUpdate() { 305 void TrayUser::OnUserUpdate() {
303 avatar_->SetImage( 306 avatar_->SetImage(
304 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), 307 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
305 gfx::Size(kUserIconSize, kUserIconSize)); 308 gfx::Size(kUserIconSize, kUserIconSize));
306 } 309 }
307 310
308 } // namespace internal 311 } // namespace internal
309 } // namespace ash 312 } // namespace ash
OLDNEW
« ash/system/tray/tray_item_view.h ('K') | « ash/system/user/tray_user.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698