OLD | NEW |
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/shell.h" | 17 #include "ash/shell.h" |
17 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 18 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
18 #include "grit/ash_resources.h" | 19 #include "grit/ash_resources.h" |
19 #include "grit/ash_strings.h" | 20 #include "grit/ash_strings.h" |
20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/gfx/paint_vector_icon.h" | 23 #include "ui/gfx/paint_vector_icon.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 108 |
108 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) { | 109 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) { |
109 if (alignment == shelf_alignment()) | 110 if (alignment == shelf_alignment()) |
110 return; | 111 return; |
111 | 112 |
112 TrayBackgroundView::SetShelfAlignment(alignment); | 113 TrayBackgroundView::SetShelfAlignment(alignment); |
113 SetIconBorderForShelfAlignment(); | 114 SetIconBorderForShelfAlignment(); |
114 } | 115 } |
115 | 116 |
116 void OverviewButtonTray::SetIconBorderForShelfAlignment() { | 117 void OverviewButtonTray::SetIconBorderForShelfAlignment() { |
117 if (IsHorizontalAlignment(shelf_alignment())) { | 118 if (ash::MaterialDesignController::IsShelfMaterial()) { |
| 119 // Pad button size to align with other controls in the system tray. |
| 120 const gfx::ImageSkia image = icon_->GetImage(); |
| 121 const int vertical_padding = (kTrayItemSize - image.height()) / 2; |
| 122 const int horizontal_padding = (kTrayItemSize - image.width()) / 2; |
118 icon_->SetBorder(views::Border::CreateEmptyBorder( | 123 icon_->SetBorder(views::Border::CreateEmptyBorder( |
119 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding, | 124 gfx::Insets(vertical_padding, horizontal_padding))); |
120 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding)); | |
121 } else { | 125 } else { |
122 icon_->SetBorder(views::Border::CreateEmptyBorder( | 126 if (IsHorizontalAlignment(shelf_alignment())) { |
123 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding, | 127 icon_->SetBorder(views::Border::CreateEmptyBorder( |
124 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding)); | 128 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding, |
| 129 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding)); |
| 130 } else { |
| 131 icon_->SetBorder(views::Border::CreateEmptyBorder( |
| 132 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding, |
| 133 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding)); |
| 134 } |
125 } | 135 } |
126 } | 136 } |
127 | 137 |
128 void OverviewButtonTray::UpdateIconVisibility() { | 138 void OverviewButtonTray::UpdateIconVisibility() { |
129 // The visibility of the OverviewButtonTray has diverge from | 139 // The visibility of the OverviewButtonTray has diverge from |
130 // WindowSelectorController::CanSelect. The visibility of the button should | 140 // WindowSelectorController::CanSelect. The visibility of the button should |
131 // not change during transient times in which CanSelect is false. Such as when | 141 // not change during transient times in which CanSelect is false. Such as when |
132 // a modal dialog is present. | 142 // a modal dialog is present. |
133 Shell* shell = Shell::GetInstance(); | 143 Shell* shell = Shell::GetInstance(); |
134 SessionStateDelegate* session_state_delegate = | 144 SessionStateDelegate* session_state_delegate = |
135 WmShell::Get()->GetSessionStateDelegate(); | 145 WmShell::Get()->GetSessionStateDelegate(); |
136 | 146 |
137 SetVisible( | 147 SetVisible( |
138 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && | 148 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && |
139 session_state_delegate->IsActiveUserSessionStarted() && | 149 session_state_delegate->IsActiveUserSessionStarted() && |
140 !session_state_delegate->IsScreenLocked() && | 150 !session_state_delegate->IsScreenLocked() && |
141 session_state_delegate->GetSessionState() == | 151 session_state_delegate->GetSessionState() == |
142 SessionStateDelegate::SESSION_STATE_ACTIVE && | 152 SessionStateDelegate::SESSION_STATE_ACTIVE && |
143 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != | 153 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
144 LoginStatus::KIOSK_APP); | 154 LoginStatus::KIOSK_APP); |
145 } | 155 } |
146 | 156 |
147 } // namespace ash | 157 } // namespace ash |
OLD | NEW |