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/common/wm/shelf/wm_shelf_util.h" | 7 #include "ash/common/shelf/wm_shelf_util.h" |
8 #include "ash/shelf/shelf_util.h" | 8 #include "ash/shelf/shelf_util.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" |
11 #include "ui/accessibility/ax_view_state.h" | 11 #include "ui/accessibility/ax_view_state.h" |
12 #include "ui/gfx/font_list.h" | 12 #include "ui/gfx/font_list.h" |
13 #include "ui/gfx/geometry/vector2d.h" | 13 #include "ui/gfx/geometry/vector2d.h" |
14 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
15 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
16 | 16 |
17 namespace ash { | 17 namespace ash { |
18 | 18 |
19 void SetupLabelForTray(views::Label* label) { | 19 void SetupLabelForTray(views::Label* label) { |
20 label->SetFontList( | 20 label->SetFontList( |
21 gfx::FontList().Derive(1, gfx::Font::NORMAL, gfx::Font::Weight::BOLD)); | 21 gfx::FontList().Derive(1, gfx::Font::NORMAL, gfx::Font::Weight::BOLD)); |
22 label->SetAutoColorReadabilityEnabled(false); | 22 label->SetAutoColorReadabilityEnabled(false); |
23 label->SetEnabledColor(SK_ColorWHITE); | 23 label->SetEnabledColor(SK_ColorWHITE); |
24 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); | 24 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); |
25 label->SetShadows(gfx::ShadowValues( | 25 label->SetShadows(gfx::ShadowValues( |
26 1, | 26 1, |
27 gfx::ShadowValue(gfx::Vector2d(0, 1), 0, SkColorSetARGB(64, 0, 0, 0)))); | 27 gfx::ShadowValue(gfx::Vector2d(0, 1), 0, SkColorSetARGB(64, 0, 0, 0)))); |
28 } | 28 } |
29 | 29 |
30 void SetTrayImageItemBorder(views::View* tray_view, | 30 void SetTrayImageItemBorder(views::View* tray_view, ShelfAlignment alignment) { |
31 wm::ShelfAlignment alignment) { | 31 if (IsHorizontalAlignment(alignment)) { |
32 if (wm::IsHorizontalAlignment(alignment)) { | |
33 tray_view->SetBorder(views::Border::CreateEmptyBorder( | 32 tray_view->SetBorder(views::Border::CreateEmptyBorder( |
34 0, kTrayImageItemHorizontalPaddingBottomAlignment, 0, | 33 0, kTrayImageItemHorizontalPaddingBottomAlignment, 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, ShelfAlignment alignment) { |
46 wm::ShelfAlignment alignment) { | 45 if (IsHorizontalAlignment(alignment)) { |
47 if (wm::IsHorizontalAlignment(alignment)) { | |
48 tray_view->SetBorder(views::Border::CreateEmptyBorder( | 46 tray_view->SetBorder(views::Border::CreateEmptyBorder( |
49 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, | 47 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, |
50 kTrayLabelItemHorizontalPaddingBottomAlignment)); | 48 kTrayLabelItemHorizontalPaddingBottomAlignment)); |
51 } else { | 49 } else { |
52 // Center the label for vertical launcher alignment. | 50 // Center the label for vertical launcher alignment. |
53 int horizontal_padding = std::max(0, | 51 int horizontal_padding = std::max(0, |
54 (tray_view->GetPreferredSize().width() - | 52 (tray_view->GetPreferredSize().width() - |
55 tray_view->label()->GetPreferredSize().width()) / 2); | 53 tray_view->label()->GetPreferredSize().width()) / 2); |
56 tray_view->SetBorder(views::Border::CreateEmptyBorder( | 54 tray_view->SetBorder(views::Border::CreateEmptyBorder( |
57 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding, | 55 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding, |
(...skipping 12 matching lines...) Expand all Loading... |
70 // Do not descend into static text labels which may compute their own labels | 68 // Do not descend into static text labels which may compute their own labels |
71 // recursively. | 69 // recursively. |
72 if (temp_state.role == ui::AX_ROLE_STATIC_TEXT) | 70 if (temp_state.role == ui::AX_ROLE_STATIC_TEXT) |
73 return; | 71 return; |
74 | 72 |
75 for (int i = 0; i < view->child_count(); ++i) | 73 for (int i = 0; i < view->child_count(); ++i) |
76 GetAccessibleLabelFromDescendantViews(view->child_at(i), out_labels); | 74 GetAccessibleLabelFromDescendantViews(view->child_at(i), out_labels); |
77 } | 75 } |
78 | 76 |
79 } // namespace ash | 77 } // namespace ash |
OLD | NEW |