| 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/common/system/user/tray_user.h" | 5 #include "ash/common/system/user/tray_user.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shelf/wm_shelf_util.h" | 9 #include "ash/common/shelf/wm_shelf_util.h" |
| 10 #include "ash/common/system/tray/system_tray.h" | 10 #include "ash/common/system/tray/system_tray.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 avatar_->SetCornerRadii(0, kTrayRoundedBorderRadius, | 185 avatar_->SetCornerRadii(0, kTrayRoundedBorderRadius, |
| 186 kTrayRoundedBorderRadius, 0); | 186 kTrayRoundedBorderRadius, 0); |
| 187 } | 187 } |
| 188 if (label_) { | 188 if (label_) { |
| 189 // If label_ hasn't figured out its size yet, do that first. | 189 // If label_ hasn't figured out its size yet, do that first. |
| 190 if (label_->GetContentsBounds().height() == 0) | 190 if (label_->GetContentsBounds().height() == 0) |
| 191 label_->SizeToPreferredSize(); | 191 label_->SizeToPreferredSize(); |
| 192 int height = label_->GetContentsBounds().height(); | 192 int height = label_->GetContentsBounds().height(); |
| 193 int vertical_pad = (kTrayItemSize - height) / 2; | 193 int vertical_pad = (kTrayItemSize - height) / 2; |
| 194 int remainder = height % 2; | 194 int remainder = height % 2; |
| 195 label_->SetBorder(views::Border::CreateEmptyBorder( | 195 label_->SetBorder(views::CreateEmptyBorder( |
| 196 vertical_pad + remainder, | 196 vertical_pad + remainder, |
| 197 kTrayLabelItemHorizontalPaddingBottomAlignment, vertical_pad, | 197 kTrayLabelItemHorizontalPaddingBottomAlignment, vertical_pad, |
| 198 kTrayLabelItemHorizontalPaddingBottomAlignment)); | 198 kTrayLabelItemHorizontalPaddingBottomAlignment)); |
| 199 } | 199 } |
| 200 layout_view_->SetLayoutManager(new views::BoxLayout( | 200 layout_view_->SetLayoutManager(new views::BoxLayout( |
| 201 views::BoxLayout::kHorizontal, 0, 0, kUserLabelToIconPadding)); | 201 views::BoxLayout::kHorizontal, 0, 0, kUserLabelToIconPadding)); |
| 202 } else { | 202 } else { |
| 203 if (avatar_) { | 203 if (avatar_) { |
| 204 avatar_->SetCornerRadii(0, 0, kTrayRoundedBorderRadius, | 204 avatar_->SetCornerRadii(0, 0, kTrayRoundedBorderRadius, |
| 205 kTrayRoundedBorderRadius); | 205 kTrayRoundedBorderRadius); |
| 206 } | 206 } |
| 207 if (label_) { | 207 if (label_) { |
| 208 label_->SetBorder(views::Border::CreateEmptyBorder( | 208 label_->SetBorder(views::CreateEmptyBorder( |
| 209 kTrayLabelItemVerticalPaddingVerticalAlignment, | 209 kTrayLabelItemVerticalPaddingVerticalAlignment, |
| 210 kTrayLabelItemHorizontalPaddingBottomAlignment, | 210 kTrayLabelItemHorizontalPaddingBottomAlignment, |
| 211 kTrayLabelItemVerticalPaddingVerticalAlignment, | 211 kTrayLabelItemVerticalPaddingVerticalAlignment, |
| 212 kTrayLabelItemHorizontalPaddingBottomAlignment)); | 212 kTrayLabelItemHorizontalPaddingBottomAlignment)); |
| 213 } | 213 } |
| 214 layout_view_->SetLayoutManager(new views::BoxLayout( | 214 layout_view_->SetLayoutManager(new views::BoxLayout( |
| 215 views::BoxLayout::kVertical, 0, 0, kUserLabelToIconPadding)); | 215 views::BoxLayout::kVertical, 0, 0, kUserLabelToIconPadding)); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // Unit tests might come here with no images for some users. | 252 // Unit tests might come here with no images for some users. |
| 253 if (avatar_->size().IsEmpty()) | 253 if (avatar_->size().IsEmpty()) |
| 254 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize)); | 254 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize)); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void TrayUser::UpdateLayoutOfItem() { | 257 void TrayUser::UpdateLayoutOfItem() { |
| 258 UpdateAfterShelfAlignmentChange(system_tray()->shelf_alignment()); | 258 UpdateAfterShelfAlignmentChange(system_tray()->shelf_alignment()); |
| 259 } | 259 } |
| 260 | 260 |
| 261 } // namespace ash | 261 } // namespace ash |
| OLD | NEW |