| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 // Overridden from views::View. | 70 // Overridden from views::View. |
| 71 virtual gfx::Size GetPreferredSize() OVERRIDE { | 71 virtual gfx::Size GetPreferredSize() OVERRIDE { |
| 72 return gfx::Size(image_size_.width() + GetInsets().width(), | 72 return gfx::Size(image_size_.width() + GetInsets().width(), |
| 73 image_size_.height() + GetInsets().height()); | 73 image_size_.height() + GetInsets().height()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 76 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
| 77 View::OnPaint(canvas); | 77 View::OnPaint(canvas); |
| 78 gfx::Rect image_bounds(GetPreferredSize()); | 78 gfx::Rect image_bounds(GetPreferredSize()); |
| 79 image_bounds = gfx::Rect(size()).Center(image_bounds.size()); | 79 image_bounds = gfx::Rect(size()); |
| 80 image_bounds.ClampToCenteredSize(image_bounds.size()); |
| 80 image_bounds.Inset(GetInsets()); | 81 image_bounds.Inset(GetInsets()); |
| 81 const SkScalar kRadius = SkIntToScalar(corner_radius_); | 82 const SkScalar kRadius = SkIntToScalar(corner_radius_); |
| 82 SkPath path; | 83 SkPath path; |
| 83 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius, kRadius); | 84 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius, kRadius); |
| 84 SkPaint paint; | 85 SkPaint paint; |
| 85 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 86 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 86 canvas->DrawImageInPath(resized_, image_bounds.x(), image_bounds.y(), | 87 canvas->DrawImageInPath(resized_, image_bounds.x(), image_bounds.y(), |
| 87 path, paint); | 88 path, paint); |
| 88 } | 89 } |
| 89 | 90 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 214 } |
| 214 | 215 |
| 215 virtual void Layout() OVERRIDE { | 216 virtual void Layout() OVERRIDE { |
| 216 views::View::Layout(); | 217 views::View::Layout(); |
| 217 if (bounds().IsEmpty()) | 218 if (bounds().IsEmpty()) |
| 218 return; | 219 return; |
| 219 | 220 |
| 220 container_->SetBoundsRect(gfx::Rect(size())); | 221 container_->SetBoundsRect(gfx::Rect(size())); |
| 221 if (signout_ && user_info_) { | 222 if (signout_ && user_info_) { |
| 222 gfx::Rect signout_bounds(signout_->GetPreferredSize()); | 223 gfx::Rect signout_bounds(signout_->GetPreferredSize()); |
| 223 signout_bounds = bounds().Center(signout_bounds.size()); | 224 signout_bounds = bounds(); |
| 225 signout_bounds.ClampToCenteredSize(signout_bounds.size()); |
| 224 signout_bounds.set_x(width() - signout_bounds.width() - | 226 signout_bounds.set_x(width() - signout_bounds.width() - |
| 225 kTrayPopupPaddingHorizontal); | 227 kTrayPopupPaddingHorizontal); |
| 226 signout_->SetBoundsRect(signout_bounds); | 228 signout_->SetBoundsRect(signout_bounds); |
| 227 | 229 |
| 228 gfx::Rect usercard_bounds(user_info_->GetPreferredSize()); | 230 gfx::Rect usercard_bounds(user_info_->GetPreferredSize()); |
| 229 usercard_bounds.set_width(signout_bounds.x()); | 231 usercard_bounds.set_width(signout_bounds.x()); |
| 230 user_info_->SetBoundsRect(usercard_bounds); | 232 user_info_->SetBoundsRect(usercard_bounds); |
| 231 } else if (signout_) { | 233 } else if (signout_) { |
| 232 signout_->SetBoundsRect(gfx::Rect(size())); | 234 signout_->SetBoundsRect(gfx::Rect(size())); |
| 233 } else if (user_info_) { | 235 } else if (user_info_) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // Check for null to avoid crbug.com/150944. | 345 // Check for null to avoid crbug.com/150944. |
| 344 if (avatar_) { | 346 if (avatar_) { |
| 345 avatar_->SetImage( | 347 avatar_->SetImage( |
| 346 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), | 348 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), |
| 347 gfx::Size(kUserIconSize, kUserIconSize)); | 349 gfx::Size(kUserIconSize, kUserIconSize)); |
| 348 } | 350 } |
| 349 } | 351 } |
| 350 | 352 |
| 351 } // namespace internal | 353 } // namespace internal |
| 352 } // namespace ash | 354 } // namespace ash |
| OLD | NEW |