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

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

Issue 2455183002: Simplify layout of tray items and fix spacing for MD. (Closed)
Patch Set: tda review Created 4 years, 1 month 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/common/system/tray/tray_item_view.cc ('k') | no next file » | 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/common/system/tray/tray_utils.h" 5 #include "ash/common/system/tray/tray_utils.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/wm_shelf_util.h" 9 #include "ash/common/shelf/wm_shelf_util.h"
10 #include "ash/common/system/tray/tray_constants.h" 10 #include "ash/common/system/tray/tray_constants.h"
(...skipping 19 matching lines...) Expand all
30 gfx::FontList().Derive(1, gfx::Font::NORMAL, gfx::Font::Weight::BOLD)); 30 gfx::FontList().Derive(1, gfx::Font::NORMAL, gfx::Font::Weight::BOLD));
31 label->SetShadows(gfx::ShadowValues( 31 label->SetShadows(gfx::ShadowValues(
32 1, 32 1,
33 gfx::ShadowValue(gfx::Vector2d(0, 1), 0, SkColorSetARGB(64, 0, 0, 0)))); 33 gfx::ShadowValue(gfx::Vector2d(0, 1), 0, SkColorSetARGB(64, 0, 0, 0))));
34 label->SetAutoColorReadabilityEnabled(false); 34 label->SetAutoColorReadabilityEnabled(false);
35 label->SetEnabledColor(SK_ColorWHITE); 35 label->SetEnabledColor(SK_ColorWHITE);
36 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); 36 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255));
37 } 37 }
38 } 38 }
39 39
40 // TODO(yiyix): Instead of using a fixed padding beside each tray item, take
41 // internal icon padding into account when adjusting tray icon spacing. See
42 // crbug.com/653292.
43 void SetTrayImageItemBorder(views::View* tray_view, ShelfAlignment alignment) { 40 void SetTrayImageItemBorder(views::View* tray_view, ShelfAlignment alignment) {
41 if (MaterialDesignController::IsShelfMaterial())
42 return;
43
44 const int tray_image_item_padding = GetTrayConstant(TRAY_IMAGE_ITEM_PADDING); 44 const int tray_image_item_padding = GetTrayConstant(TRAY_IMAGE_ITEM_PADDING);
45 if (IsHorizontalAlignment(alignment)) { 45 if (IsHorizontalAlignment(alignment)) {
46 tray_view->SetBorder(views::Border::CreateEmptyBorder( 46 tray_view->SetBorder(views::Border::CreateEmptyBorder(
47 0, tray_image_item_padding, 0, tray_image_item_padding)); 47 0, tray_image_item_padding, 0, tray_image_item_padding));
48 } else { 48 } else {
49 tray_view->SetBorder(views::Border::CreateEmptyBorder( 49 tray_view->SetBorder(views::Border::CreateEmptyBorder(
50 tray_image_item_padding, 50 tray_image_item_padding,
51 kTrayImageItemHorizontalPaddingVerticalAlignment, 51 kTrayImageItemHorizontalPaddingVerticalAlignment,
52 tray_image_item_padding, 52 tray_image_item_padding,
53 kTrayImageItemHorizontalPaddingVerticalAlignment)); 53 kTrayImageItemHorizontalPaddingVerticalAlignment));
54 } 54 }
55 } 55 }
56 56
57 void SetTrayLabelItemBorder(TrayItemView* tray_view, ShelfAlignment alignment) { 57 void SetTrayLabelItemBorder(TrayItemView* tray_view, ShelfAlignment alignment) {
58 if (MaterialDesignController::IsShelfMaterial())
59 return;
60
58 if (IsHorizontalAlignment(alignment)) { 61 if (IsHorizontalAlignment(alignment)) {
59 tray_view->SetBorder(views::Border::CreateEmptyBorder( 62 tray_view->SetBorder(views::Border::CreateEmptyBorder(
60 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, 63 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0,
61 kTrayLabelItemHorizontalPaddingBottomAlignment)); 64 kTrayLabelItemHorizontalPaddingBottomAlignment));
62 } else { 65 } else {
63 // Center the label for vertical launcher alignment. 66 // Center the label for vertical launcher alignment.
64 int horizontal_padding = 67 int horizontal_padding =
65 std::max(0, (tray_view->GetPreferredSize().width() - 68 std::max(0, (tray_view->GetPreferredSize().width() -
66 tray_view->label()->GetPreferredSize().width()) / 69 tray_view->label()->GetPreferredSize().width()) /
67 2); 70 2);
(...skipping 23 matching lines...) Expand all
91 bool CanOpenWebUISettings(LoginStatus status) { 94 bool CanOpenWebUISettings(LoginStatus status) {
92 // TODO(tdanderson): Consider moving this into WmShell, or introduce a 95 // TODO(tdanderson): Consider moving this into WmShell, or introduce a
93 // CanShowSettings() method in each delegate type that has a 96 // CanShowSettings() method in each delegate type that has a
94 // ShowSettings() method. 97 // ShowSettings() method.
95 return status != LoginStatus::NOT_LOGGED_IN && 98 return status != LoginStatus::NOT_LOGGED_IN &&
96 status != LoginStatus::LOCKED && 99 status != LoginStatus::LOCKED &&
97 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); 100 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
98 } 101 }
99 102
100 } // namespace ash 103 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_item_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698