Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: ash/system/tray/tray_utils.cc

Issue 1877543002: Revise the shelf alignment locking mechanism. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update and cleanup tests. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/tray/tray_item_view.cc ('k') | ash/system/user/tray_user.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/system/tray/tray_constants.h" 8 #include "ash/system/tray/tray_constants.h"
8 #include "ash/system/tray/tray_item_view.h" 9 #include "ash/system/tray/tray_item_view.h"
9 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
10 #include "ui/gfx/font_list.h" 11 #include "ui/gfx/font_list.h"
11 #include "ui/gfx/geometry/vector2d.h" 12 #include "ui/gfx/geometry/vector2d.h"
12 #include "ui/views/border.h" 13 #include "ui/views/border.h"
13 #include "ui/views/controls/label.h" 14 #include "ui/views/controls/label.h"
14 15
15 namespace ash { 16 namespace ash {
16 17
17 void SetupLabelForTray(views::Label* label) { 18 void SetupLabelForTray(views::Label* label) {
18 label->SetFontList(gfx::FontList().Derive(1, gfx::Font::BOLD)); 19 label->SetFontList(gfx::FontList().Derive(1, gfx::Font::BOLD));
19 label->SetAutoColorReadabilityEnabled(false); 20 label->SetAutoColorReadabilityEnabled(false);
20 label->SetEnabledColor(SK_ColorWHITE); 21 label->SetEnabledColor(SK_ColorWHITE);
21 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); 22 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255));
22 label->SetShadows(gfx::ShadowValues( 23 label->SetShadows(gfx::ShadowValues(
23 1, 24 1,
24 gfx::ShadowValue(gfx::Vector2d(0, 1), 0, SkColorSetARGB(64, 0, 0, 0)))); 25 gfx::ShadowValue(gfx::Vector2d(0, 1), 0, SkColorSetARGB(64, 0, 0, 0))));
25 } 26 }
26 27
27 void SetTrayImageItemBorder(views::View* tray_view, 28 void SetTrayImageItemBorder(views::View* tray_view,
28 ShelfAlignment alignment) { 29 ShelfAlignment alignment) {
29 if (alignment == SHELF_ALIGNMENT_BOTTOM) { 30 if (IsHorizontalAlignment(alignment)) {
30 tray_view->SetBorder(views::Border::CreateEmptyBorder( 31 tray_view->SetBorder(views::Border::CreateEmptyBorder(
31 0, 32 0, kTrayImageItemHorizontalPaddingBottomAlignment, 0,
32 kTrayImageItemHorizontalPaddingBottomAlignment,
33 0,
34 kTrayImageItemHorizontalPaddingBottomAlignment)); 33 kTrayImageItemHorizontalPaddingBottomAlignment));
35 } else { 34 } else {
36 tray_view->SetBorder(views::Border::CreateEmptyBorder( 35 tray_view->SetBorder(views::Border::CreateEmptyBorder(
37 kTrayImageItemVerticalPaddingVerticalAlignment, 36 kTrayImageItemVerticalPaddingVerticalAlignment,
38 kTrayImageItemHorizontalPaddingVerticalAlignment, 37 kTrayImageItemHorizontalPaddingVerticalAlignment,
39 kTrayImageItemVerticalPaddingVerticalAlignment, 38 kTrayImageItemVerticalPaddingVerticalAlignment,
40 kTrayImageItemHorizontalPaddingVerticalAlignment)); 39 kTrayImageItemHorizontalPaddingVerticalAlignment));
41 } 40 }
42 } 41 }
43 42
44 void SetTrayLabelItemBorder(TrayItemView* tray_view, 43 void SetTrayLabelItemBorder(TrayItemView* tray_view,
45 ShelfAlignment alignment) { 44 ShelfAlignment alignment) {
46 if (alignment == SHELF_ALIGNMENT_BOTTOM) { 45 if (IsHorizontalAlignment(alignment)) {
47 tray_view->SetBorder(views::Border::CreateEmptyBorder( 46 tray_view->SetBorder(views::Border::CreateEmptyBorder(
48 0, 47 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0,
49 kTrayLabelItemHorizontalPaddingBottomAlignment,
50 0,
51 kTrayLabelItemHorizontalPaddingBottomAlignment)); 48 kTrayLabelItemHorizontalPaddingBottomAlignment));
52 } else { 49 } else {
53 // Center the label for vertical launcher alignment. 50 // Center the label for vertical launcher alignment.
54 int horizontal_padding = std::max(0, 51 int horizontal_padding = std::max(0,
55 (tray_view->GetPreferredSize().width() - 52 (tray_view->GetPreferredSize().width() -
56 tray_view->label()->GetPreferredSize().width()) / 2); 53 tray_view->label()->GetPreferredSize().width()) / 2);
57 tray_view->SetBorder(views::Border::CreateEmptyBorder( 54 tray_view->SetBorder(views::Border::CreateEmptyBorder(
58 kTrayLabelItemVerticalPaddingVerticalAlignment, 55 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding,
59 horizontal_padding, 56 kTrayLabelItemVerticalPaddingVerticalAlignment, horizontal_padding));
60 kTrayLabelItemVerticalPaddingVerticalAlignment,
61 horizontal_padding));
62 } 57 }
63 } 58 }
64 59
65 void GetAccessibleLabelFromDescendantViews( 60 void GetAccessibleLabelFromDescendantViews(
66 views::View* view, 61 views::View* view,
67 std::vector<base::string16>& out_labels) { 62 std::vector<base::string16>& out_labels) {
68 ui::AXViewState temp_state; 63 ui::AXViewState temp_state;
69 view->GetAccessibleState(&temp_state); 64 view->GetAccessibleState(&temp_state);
70 if (!temp_state.name.empty()) 65 if (!temp_state.name.empty())
71 out_labels.push_back(temp_state.name); 66 out_labels.push_back(temp_state.name);
72 67
73 // 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
74 // recursively. 69 // recursively.
75 if (temp_state.role == ui::AX_ROLE_STATIC_TEXT) 70 if (temp_state.role == ui::AX_ROLE_STATIC_TEXT)
76 return; 71 return;
77 72
78 for (int i = 0; i < view->child_count(); ++i) 73 for (int i = 0; i < view->child_count(); ++i)
79 GetAccessibleLabelFromDescendantViews(view->child_at(i), out_labels); 74 GetAccessibleLabelFromDescendantViews(view->child_at(i), out_labels);
80 } 75 }
81 76
82 } // namespace ash 77 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_item_view.cc ('k') | ash/system/user/tray_user.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698