cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ash / system / tray / tray_utils.cc
blob893697c1a489748fc9d030ce2bef8cd449a4e782
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.
5 #include "ash/system/tray/tray_utils.h"
7 #include "ash/system/tray/tray_constants.h"
8 #include "ash/system/tray/tray_item_view.h"
9 #include "ui/accessibility/ax_view_state.h"
10 #include "ui/gfx/font_list.h"
11 #include "ui/gfx/geometry/vector2d.h"
12 #include "ui/views/border.h"
13 #include "ui/views/controls/label.h"
15 namespace ash {
17 void SetupLabelForTray(views::Label* label) {
18 label->SetFontList(gfx::FontList().Derive(1, gfx::Font::BOLD));
19 label->SetAutoColorReadabilityEnabled(false);
20 label->SetEnabledColor(SK_ColorWHITE);
21 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255));
22 label->SetShadows(gfx::ShadowValues(
24 gfx::ShadowValue(gfx::Vector2d(0, 1), 0, SkColorSetARGB(64, 0, 0, 0))));
27 void SetTrayImageItemBorder(views::View* tray_view,
28 ShelfAlignment alignment) {
29 if (alignment == SHELF_ALIGNMENT_BOTTOM ||
30 alignment == SHELF_ALIGNMENT_TOP) {
31 tray_view->SetBorder(views::Border::CreateEmptyBorder(
33 kTrayImageItemHorizontalPaddingBottomAlignment,
35 kTrayImageItemHorizontalPaddingBottomAlignment));
36 } else {
37 tray_view->SetBorder(views::Border::CreateEmptyBorder(
38 kTrayImageItemVerticalPaddingVerticalAlignment,
39 kTrayImageItemHorizontalPaddingVerticalAlignment,
40 kTrayImageItemVerticalPaddingVerticalAlignment,
41 kTrayImageItemHorizontalPaddingVerticalAlignment));
45 void SetTrayLabelItemBorder(TrayItemView* tray_view,
46 ShelfAlignment alignment) {
47 if (alignment == SHELF_ALIGNMENT_BOTTOM ||
48 alignment == SHELF_ALIGNMENT_TOP) {
49 tray_view->SetBorder(views::Border::CreateEmptyBorder(
51 kTrayLabelItemHorizontalPaddingBottomAlignment,
53 kTrayLabelItemHorizontalPaddingBottomAlignment));
54 } else {
55 // Center the label for vertical launcher alignment.
56 int horizontal_padding = std::max(0,
57 (tray_view->GetPreferredSize().width() -
58 tray_view->label()->GetPreferredSize().width()) / 2);
59 tray_view->SetBorder(views::Border::CreateEmptyBorder(
60 kTrayLabelItemVerticalPaddingVerticalAlignment,
61 horizontal_padding,
62 kTrayLabelItemVerticalPaddingVerticalAlignment,
63 horizontal_padding));
67 void GetAccessibleLabelFromDescendantViews(
68 views::View* view,
69 std::vector<base::string16>& out_labels) {
70 ui::AXViewState temp_state;
71 view->GetAccessibleState(&temp_state);
72 if (!temp_state.name.empty())
73 out_labels.push_back(temp_state.name);
75 // Do not descend into static text labels which may compute their own labels
76 // recursively.
77 if (temp_state.role == ui::AX_ROLE_STATIC_TEXT)
78 return;
80 for (int i = 0; i < view->child_count(); ++i)
81 GetAccessibleLabelFromDescendantViews(view->child_at(i), out_labels);
84 } // namespace ash