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