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/tray/tray_utils.h" | 5 #include "ash/system/tray/tray_utils.h" |
6 | 6 |
7 #include "ash/system/tray/tray_constants.h" | 7 #include "ash/system/tray/tray_constants.h" |
8 #include "ash/system/tray/tray_item_view.h" | 8 #include "ash/system/tray/tray_item_view.h" |
9 #include "ui/accessibility/ax_view_state.h" | 9 #include "ui/accessibility/ax_view_state.h" |
10 #include "ui/gfx/font_list.h" | 10 #include "ui/gfx/font_list.h" |
11 #include "ui/gfx/geometry/vector2d.h" | 11 #include "ui/gfx/geometry/vector2d.h" |
12 #include "ui/views/border.h" | 12 #include "ui/views/border.h" |
13 #include "ui/views/controls/label.h" | 13 #include "ui/views/controls/label.h" |
14 | 14 |
15 namespace ash { | 15 namespace ash { |
16 | 16 |
17 void SetupLabelForTray(views::Label* label) { | 17 void SetupLabelForTray(views::Label* label) { |
18 label->SetFontList(gfx::FontList().Derive(1, gfx::Font::BOLD)); | 18 label->SetFontList(gfx::FontList().Derive(1, gfx::Font::BOLD)); |
19 label->SetAutoColorReadabilityEnabled(false); | 19 label->SetAutoColorReadabilityEnabled(false); |
20 label->SetEnabledColor(SK_ColorWHITE); | 20 label->SetEnabledColor(SK_ColorWHITE); |
21 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); | 21 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); |
22 label->SetShadows(gfx::ShadowValues( | 22 label->SetShadows(gfx::ShadowValues( |
23 1, | 23 1, |
24 gfx::ShadowValue(gfx::Vector2d(0, 1), 0, SkColorSetARGB(64, 0, 0, 0)))); | 24 gfx::ShadowValue(gfx::Vector2d(0, 1), 0, SkColorSetARGB(64, 0, 0, 0)))); |
25 } | 25 } |
26 | 26 |
27 void SetTrayImageItemBorder(views::View* tray_view, | 27 void SetTrayImageItemBorder(views::View* tray_view, |
28 ShelfAlignment alignment) { | 28 ShelfAlignment alignment) { |
29 if (alignment == SHELF_ALIGNMENT_BOTTOM || | 29 if (alignment == SHELF_ALIGNMENT_BOTTOM) { |
30 alignment == SHELF_ALIGNMENT_TOP) { | |
31 tray_view->SetBorder(views::Border::CreateEmptyBorder( | 30 tray_view->SetBorder(views::Border::CreateEmptyBorder( |
32 0, | 31 0, |
33 kTrayImageItemHorizontalPaddingBottomAlignment, | 32 kTrayImageItemHorizontalPaddingBottomAlignment, |
34 0, | 33 0, |
35 kTrayImageItemHorizontalPaddingBottomAlignment)); | 34 kTrayImageItemHorizontalPaddingBottomAlignment)); |
36 } else { | 35 } else { |
37 tray_view->SetBorder(views::Border::CreateEmptyBorder( | 36 tray_view->SetBorder(views::Border::CreateEmptyBorder( |
38 kTrayImageItemVerticalPaddingVerticalAlignment, | 37 kTrayImageItemVerticalPaddingVerticalAlignment, |
39 kTrayImageItemHorizontalPaddingVerticalAlignment, | 38 kTrayImageItemHorizontalPaddingVerticalAlignment, |
40 kTrayImageItemVerticalPaddingVerticalAlignment, | 39 kTrayImageItemVerticalPaddingVerticalAlignment, |
41 kTrayImageItemHorizontalPaddingVerticalAlignment)); | 40 kTrayImageItemHorizontalPaddingVerticalAlignment)); |
42 } | 41 } |
43 } | 42 } |
44 | 43 |
45 void SetTrayLabelItemBorder(TrayItemView* tray_view, | 44 void SetTrayLabelItemBorder(TrayItemView* tray_view, |
46 ShelfAlignment alignment) { | 45 ShelfAlignment alignment) { |
47 if (alignment == SHELF_ALIGNMENT_BOTTOM || | 46 if (alignment == SHELF_ALIGNMENT_BOTTOM) { |
48 alignment == SHELF_ALIGNMENT_TOP) { | |
49 tray_view->SetBorder(views::Border::CreateEmptyBorder( | 47 tray_view->SetBorder(views::Border::CreateEmptyBorder( |
50 0, | 48 0, |
51 kTrayLabelItemHorizontalPaddingBottomAlignment, | 49 kTrayLabelItemHorizontalPaddingBottomAlignment, |
52 0, | 50 0, |
53 kTrayLabelItemHorizontalPaddingBottomAlignment)); | 51 kTrayLabelItemHorizontalPaddingBottomAlignment)); |
54 } else { | 52 } else { |
55 // Center the label for vertical launcher alignment. | 53 // Center the label for vertical launcher alignment. |
56 int horizontal_padding = std::max(0, | 54 int horizontal_padding = std::max(0, |
57 (tray_view->GetPreferredSize().width() - | 55 (tray_view->GetPreferredSize().width() - |
58 tray_view->label()->GetPreferredSize().width()) / 2); | 56 tray_view->label()->GetPreferredSize().width()) / 2); |
(...skipping 16 matching lines...) Expand all Loading... |
75 // Do not descend into static text labels which may compute their own labels | 73 // Do not descend into static text labels which may compute their own labels |
76 // recursively. | 74 // recursively. |
77 if (temp_state.role == ui::AX_ROLE_STATIC_TEXT) | 75 if (temp_state.role == ui::AX_ROLE_STATIC_TEXT) |
78 return; | 76 return; |
79 | 77 |
80 for (int i = 0; i < view->child_count(); ++i) | 78 for (int i = 0; i < view->child_count(); ++i) |
81 GetAccessibleLabelFromDescendantViews(view->child_at(i), out_labels); | 79 GetAccessibleLabelFromDescendantViews(view->child_at(i), out_labels); |
82 } | 80 } |
83 | 81 |
84 } // namespace ash | 82 } // namespace ash |
OLD | NEW |