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

Side by Side Diff: ash/system/overview/overview_button_tray.cc

Issue 2099103002: Give Ash material design tray items the correct size and layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for review Created 4 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/overview/overview_button_tray.h" 5 #include "ash/system/overview/overview_button_tray.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/shelf_constants.h" 9 #include "ash/common/shelf/shelf_constants.h"
10 #include "ash/common/shelf/shelf_types.h" 10 #include "ash/common/shelf/shelf_types.h"
11 #include "ash/common/shelf/wm_shelf_util.h" 11 #include "ash/common/shelf/wm_shelf_util.h"
12 #include "ash/common/system/tray/system_tray_delegate.h" 12 #include "ash/common/system/tray/system_tray_delegate.h"
13 #include "ash/common/system/tray/tray_constants.h"
13 #include "ash/common/system/tray/tray_utils.h" 14 #include "ash/common/system/tray/tray_utils.h"
14 #include "ash/common/wm/overview/window_selector_controller.h" 15 #include "ash/common/wm/overview/window_selector_controller.h"
15 #include "ash/common/wm_shell.h" 16 #include "ash/common/wm_shell.h"
16 #include "ash/shelf/shelf_util.h" 17 #include "ash/shelf/shelf_util.h"
17 #include "ash/shell.h" 18 #include "ash/shell.h"
18 #include "ash/system/status_area_widget.h" 19 #include "ash/system/status_area_widget.h"
19 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 20 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
20 #include "grit/ash_resources.h" 21 #include "grit/ash_resources.h"
21 #include "grit/ash_strings.h" 22 #include "grit/ash_strings.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 110
110 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) { 111 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) {
111 if (alignment == shelf_alignment()) 112 if (alignment == shelf_alignment())
112 return; 113 return;
113 114
114 TrayBackgroundView::SetShelfAlignment(alignment); 115 TrayBackgroundView::SetShelfAlignment(alignment);
115 SetIconBorderForShelfAlignment(); 116 SetIconBorderForShelfAlignment();
116 } 117 }
117 118
118 void OverviewButtonTray::SetIconBorderForShelfAlignment() { 119 void OverviewButtonTray::SetIconBorderForShelfAlignment() {
119 if (IsHorizontalAlignment(shelf_alignment())) { 120 if (ash::MaterialDesignController::IsShelfMaterial()) {
121 // Pad button size to align with other controls in the system tray.
122 const gfx::ImageSkia image = icon_->GetImage();
123 const int top_padding = (kTrayItemSize - image.height()) / 2;
124 const int left_padding = (kTrayItemSize - image.width()) / 2;
125 const int bottom_padding = kTrayItemSize - image.height() - top_padding;
126 const int right_padding = kTrayItemSize - image.width() - left_padding;
127
120 icon_->SetBorder(views::Border::CreateEmptyBorder( 128 icon_->SetBorder(views::Border::CreateEmptyBorder(
121 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding, 129 top_padding, left_padding, bottom_padding, right_padding));
122 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding));
123 } else { 130 } else {
124 icon_->SetBorder(views::Border::CreateEmptyBorder( 131 if (IsHorizontalAlignment(shelf_alignment())) {
125 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding, 132 icon_->SetBorder(views::Border::CreateEmptyBorder(
126 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding)); 133 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding,
134 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding));
135 } else {
136 icon_->SetBorder(views::Border::CreateEmptyBorder(
137 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding,
138 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding));
139 }
127 } 140 }
128 } 141 }
129 142
130 void OverviewButtonTray::UpdateIconVisibility() { 143 void OverviewButtonTray::UpdateIconVisibility() {
131 // The visibility of the OverviewButtonTray has diverge from 144 // The visibility of the OverviewButtonTray has diverge from
132 // WindowSelectorController::CanSelect. The visibility of the button should 145 // WindowSelectorController::CanSelect. The visibility of the button should
133 // not change during transient times in which CanSelect is false. Such as when 146 // not change during transient times in which CanSelect is false. Such as when
134 // a modal dialog is present. 147 // a modal dialog is present.
135 Shell* shell = Shell::GetInstance(); 148 Shell* shell = Shell::GetInstance();
136 SessionStateDelegate* session_state_delegate = 149 SessionStateDelegate* session_state_delegate =
137 WmShell::Get()->GetSessionStateDelegate(); 150 WmShell::Get()->GetSessionStateDelegate();
138 151
139 SetVisible( 152 SetVisible(
140 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && 153 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() &&
141 session_state_delegate->IsActiveUserSessionStarted() && 154 session_state_delegate->IsActiveUserSessionStarted() &&
142 !session_state_delegate->IsScreenLocked() && 155 !session_state_delegate->IsScreenLocked() &&
143 session_state_delegate->GetSessionState() == 156 session_state_delegate->GetSessionState() ==
144 SessionStateDelegate::SESSION_STATE_ACTIVE && 157 SessionStateDelegate::SESSION_STATE_ACTIVE &&
145 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != 158 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() !=
146 LoginStatus::KIOSK_APP); 159 LoginStatus::KIOSK_APP);
147 } 160 }
148 161
149 } // namespace ash 162 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698