| OLD | NEW |
| 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_delegate.h" | 8 #include "ash/system/tray/system_tray_delegate.h" |
| 9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
| 10 #include "ash/system/tray/tray_item_view.h" | 10 #include "ash/system/tray/tray_item_view.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "ui/views/controls/button/text_button.h" | 25 #include "ui/views/controls/button/text_button.h" |
| 26 #include "ui/views/controls/image_view.h" | 26 #include "ui/views/controls/image_view.h" |
| 27 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
| 28 #include "ui/views/layout/box_layout.h" | 28 #include "ui/views/layout/box_layout.h" |
| 29 #include "ui/views/view.h" | 29 #include "ui/views/view.h" |
| 30 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 const int kUserInfoVerticalPadding = 10; | 34 const int kUserInfoVerticalPadding = 10; |
| 35 const int kUserInfoEmptyBorderLeftPadding = 6; | |
| 36 const int kUserInfoEmptyBorderRightPadding = 1; | |
| 37 const int kUserIconSize = 27; | 35 const int kUserIconSize = 27; |
| 38 | 36 |
| 39 } // namespace | 37 } // namespace |
| 40 | 38 |
| 41 namespace ash { | 39 namespace ash { |
| 42 namespace internal { | 40 namespace internal { |
| 43 | 41 |
| 44 namespace tray { | 42 namespace tray { |
| 45 | 43 |
| 46 // A custom image view with rounded edges. | 44 // A custom image view with rounded edges. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 : user_(NULL), | 248 : user_(NULL), |
| 251 avatar_(NULL) { | 249 avatar_(NULL) { |
| 252 } | 250 } |
| 253 | 251 |
| 254 TrayUser::~TrayUser() { | 252 TrayUser::~TrayUser() { |
| 255 } | 253 } |
| 256 | 254 |
| 257 views::View* TrayUser::CreateTrayView(user::LoginStatus status) { | 255 views::View* TrayUser::CreateTrayView(user::LoginStatus status) { |
| 258 CHECK(avatar_ == NULL); | 256 CHECK(avatar_ == NULL); |
| 259 avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius); | 257 avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius); |
| 260 avatar_->set_border(views::Border::CreateEmptyBorder( | |
| 261 0, kUserInfoEmptyBorderLeftPadding, 0, kUserInfoEmptyBorderRightPadding)); | |
| 262 UpdateAfterLoginStatusChange(status); | 258 UpdateAfterLoginStatusChange(status); |
| 263 return avatar_; | 259 return avatar_; |
| 264 } | 260 } |
| 265 | 261 |
| 266 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { | 262 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { |
| 267 if (status == user::LOGGED_IN_NONE) | 263 if (status == user::LOGGED_IN_NONE) |
| 268 return NULL; | 264 return NULL; |
| 269 | 265 |
| 270 CHECK(user_ == NULL); | 266 CHECK(user_ == NULL); |
| 271 user_ = new tray::UserView(status); | 267 user_ = new tray::UserView(status); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 292 status != user::LOGGED_IN_GUEST) { | 288 status != user::LOGGED_IN_GUEST) { |
| 293 avatar_->SetImage( | 289 avatar_->SetImage( |
| 294 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), | 290 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), |
| 295 gfx::Size(kUserIconSize, kUserIconSize)); | 291 gfx::Size(kUserIconSize, kUserIconSize)); |
| 296 avatar_->SetVisible(true); | 292 avatar_->SetVisible(true); |
| 297 } else { | 293 } else { |
| 298 avatar_->SetVisible(false); | 294 avatar_->SetVisible(false); |
| 299 } | 295 } |
| 300 } | 296 } |
| 301 | 297 |
| 298 void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 299 SetTrayImageItemBorder(avatar_, alignment); |
| 300 } |
| 301 |
| 302 void TrayUser::OnUserUpdate() { | 302 void TrayUser::OnUserUpdate() { |
| 303 avatar_->SetImage( | 303 avatar_->SetImage( |
| 304 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), | 304 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), |
| 305 gfx::Size(kUserIconSize, kUserIconSize)); | 305 gfx::Size(kUserIconSize, kUserIconSize)); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace internal | 308 } // namespace internal |
| 309 } // namespace ash | 309 } // namespace ash |
| OLD | NEW |