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/tray/tray_utils.h" | 5 #include "ash/common/system/tray/tray_utils.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/shelf/wm_shelf_util.h" | 8 #include "ash/common/shelf/wm_shelf_util.h" |
9 #include "ash/common/system/tray/tray_constants.h" | 9 #include "ash/common/system/tray/tray_constants.h" |
10 #include "ash/common/system/tray/tray_item_view.h" | 10 #include "ash/common/system/tray/tray_item_view.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 label->SetAutoColorReadabilityEnabled(false); | 34 label->SetAutoColorReadabilityEnabled(false); |
35 label->SetEnabledColor(SK_ColorWHITE); | 35 label->SetEnabledColor(SK_ColorWHITE); |
36 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); | 36 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 void SetTrayImageItemBorder(views::View* tray_view, ShelfAlignment alignment) { | 40 void SetTrayImageItemBorder(views::View* tray_view, ShelfAlignment alignment) { |
41 if (MaterialDesignController::IsShelfMaterial()) | 41 if (MaterialDesignController::IsShelfMaterial()) |
42 return; | 42 return; |
43 | 43 |
44 const int tray_image_item_padding = GetTrayConstant(TRAY_IMAGE_ITEM_PADDING); | |
45 if (IsHorizontalAlignment(alignment)) { | 44 if (IsHorizontalAlignment(alignment)) { |
46 tray_view->SetBorder(views::CreateEmptyBorder(0, tray_image_item_padding, 0, | 45 tray_view->SetBorder( |
47 tray_image_item_padding)); | 46 views::CreateEmptyBorder(gfx::Insets(0, kTrayImageItemPadding))); |
48 } else { | 47 } else { |
49 tray_view->SetBorder(views::CreateEmptyBorder( | 48 tray_view->SetBorder(views::CreateEmptyBorder(gfx::Insets( |
50 tray_image_item_padding, | 49 kTrayImageItemPadding, |
51 kTrayImageItemHorizontalPaddingVerticalAlignment, | 50 kTrayImageItemHorizontalPaddingVerticalAlignment))); |
52 tray_image_item_padding, | |
53 kTrayImageItemHorizontalPaddingVerticalAlignment)); | |
54 } | 51 } |
55 } | 52 } |
56 | 53 |
57 void SetTrayLabelItemBorder(TrayItemView* tray_view, ShelfAlignment alignment) { | 54 void SetTrayLabelItemBorder(TrayItemView* tray_view, ShelfAlignment alignment) { |
58 if (MaterialDesignController::IsShelfMaterial()) | 55 if (MaterialDesignController::IsShelfMaterial()) |
59 return; | 56 return; |
60 | 57 |
61 if (IsHorizontalAlignment(alignment)) { | 58 if (IsHorizontalAlignment(alignment)) { |
62 tray_view->SetBorder(views::CreateEmptyBorder( | 59 tray_view->SetBorder(views::CreateEmptyBorder( |
63 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, | 60 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, |
64 kTrayLabelItemHorizontalPaddingBottomAlignment)); | 61 kTrayLabelItemHorizontalPaddingBottomAlignment)); |
65 } else { | 62 } else { |
66 // Center the label for vertical launcher alignment. | 63 // Center the label for vertical launcher alignment. |
67 int horizontal_padding = | 64 int horizontal_padding = |
68 std::max(0, (tray_view->GetPreferredSize().width() - | 65 std::max(0, (tray_view->GetPreferredSize().width() - |
69 tray_view->label()->GetPreferredSize().width()) / | 66 tray_view->label()->GetPreferredSize().width()) / |
70 2); | 67 2); |
71 tray_view->SetBorder(views::CreateEmptyBorder( | 68 tray_view->SetBorder(views::CreateEmptyBorder( |
72 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding, | 69 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding, |
73 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding)); | 70 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding)); |
74 } | 71 } |
75 } | 72 } |
76 | 73 |
77 } // namespace ash | 74 } // namespace ash |
OLD | NEW |