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