OLD | NEW |
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_background_view.h" | 5 #include "ash/system/tray/tray_background_view.h" |
6 | 6 |
7 #include "ash/launcher/background_animator.h" | 7 #include "ash/launcher/background_animator.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/system/status_area_widget.h" | 10 #include "ash/system/status_area_widget.h" |
11 #include "ash/system/status_area_widget_delegate.h" | 11 #include "ash/system/status_area_widget_delegate.h" |
12 #include "ash/system/tray/tray_constants.h" | 12 #include "ash/system/tray/tray_constants.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/base/accessibility/accessible_view_state.h" | |
15 #include "ui/compositor/layer_animation_observer.h" | 14 #include "ui/compositor/layer_animation_observer.h" |
16 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
17 #include "ui/gfx/skia_util.h" | 16 #include "ui/gfx/skia_util.h" |
18 #include "ui/views/background.h" | 17 #include "ui/views/background.h" |
19 #include "ui/views/layout/box_layout.h" | 18 #include "ui/views/layout/box_layout.h" |
20 | 19 |
21 namespace { | 20 namespace { |
22 | 21 |
23 const SkColor kTrayBackgroundAlpha = 100; | 22 const SkColor kTrayBackgroundAlpha = 100; |
24 const SkColor kTrayBackgroundHoverAlpha = 150; | 23 const SkColor kTrayBackgroundHoverAlpha = 150; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 199 } |
201 | 200 |
202 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { | 201 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { |
203 PreferredSizeChanged(); | 202 PreferredSizeChanged(); |
204 } | 203 } |
205 | 204 |
206 void TrayBackgroundView::OnPaintFocusBorder(gfx::Canvas* canvas) { | 205 void TrayBackgroundView::OnPaintFocusBorder(gfx::Canvas* canvas) { |
207 // The tray itself expands to the right and bottom edge of the screen to make | 206 // The tray itself expands to the right and bottom edge of the screen to make |
208 // sure clicking on the edges brings up the popup. However, the focus border | 207 // sure clicking on the edges brings up the popup. However, the focus border |
209 // should be only around the container. | 208 // should be only around the container. |
210 if (HasFocus() && (focusable() || IsAccessibilityFocusable())) | 209 if (GetWidget() && GetWidget()->IsActive()) |
211 DrawBorder(canvas, GetContentsBounds()); | 210 DrawBorder(canvas, GetContentsBounds()); |
212 } | 211 } |
213 | 212 |
214 void TrayBackgroundView::GetAccessibleState(ui::AccessibleViewState* state) { | |
215 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | |
216 state->name = GetAccessibleName(); | |
217 } | |
218 | |
219 void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) { | 213 void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) { |
220 // Return focus to the login view. See crbug.com/120500. | 214 // Return focus to the login view. See crbug.com/120500. |
221 views::View* v = GetNextFocusableView(); | 215 views::View* v = GetNextFocusableView(); |
222 if (v) | 216 if (v) |
223 v->AboutToRequestFocusFromTabTraversal(reverse); | 217 v->AboutToRequestFocusFromTabTraversal(reverse); |
224 } | 218 } |
225 | 219 |
226 bool TrayBackgroundView::PerformAction(const ui::Event& event) { | 220 bool TrayBackgroundView::PerformAction(const ui::Event& event) { |
227 return false; | 221 return false; |
228 } | 222 } |
(...skipping 21 matching lines...) Expand all Loading... |
250 } | 244 } |
251 | 245 |
252 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 246 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
253 shelf_alignment_ = alignment; | 247 shelf_alignment_ = alignment; |
254 SetBorder(); | 248 SetBorder(); |
255 tray_container_->SetAlignment(alignment); | 249 tray_container_->SetAlignment(alignment); |
256 } | 250 } |
257 | 251 |
258 void TrayBackgroundView::SetBorder() { | 252 void TrayBackgroundView::SetBorder() { |
259 views::View* parent = status_area_widget_->status_area_widget_delegate(); | 253 views::View* parent = status_area_widget_->status_area_widget_delegate(); |
260 // Tray views are laid out right-to-left or bottom-to-top | 254 int child_count = parent->child_count(); |
261 int on_edge = (this == parent->child_at(0)); | 255 DCHECK(child_count > 0); |
| 256 int on_edge = (this == parent->child_at(child_count-1)); |
262 // Change the border padding for different shelf alignment. | 257 // Change the border padding for different shelf alignment. |
263 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 258 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
264 set_border(views::Border::CreateEmptyBorder( | 259 set_border(views::Border::CreateEmptyBorder( |
265 0, 0, kPaddingFromBottomOfScreenBottomAlignment, | 260 0, 0, kPaddingFromBottomOfScreenBottomAlignment, |
266 on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0)); | 261 on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0)); |
267 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | 262 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { |
268 set_border(views::Border::CreateEmptyBorder( | 263 set_border(views::Border::CreateEmptyBorder( |
269 0, kPaddingFromOuterEdgeOfLauncherVerticalAlignment, | 264 0, kPaddingFromOuterEdgeOfLauncherVerticalAlignment, |
270 on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0, | 265 on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0, |
271 kPaddingFromInnerEdgeOfLauncherVerticalAlignment)); | 266 kPaddingFromInnerEdgeOfLauncherVerticalAlignment)); |
272 } else { | 267 } else { |
273 set_border(views::Border::CreateEmptyBorder( | 268 set_border(views::Border::CreateEmptyBorder( |
274 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment, | 269 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment, |
275 on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0, | 270 on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0, |
276 kPaddingFromOuterEdgeOfLauncherVerticalAlignment)); | 271 kPaddingFromOuterEdgeOfLauncherVerticalAlignment)); |
277 } | 272 } |
278 } | 273 } |
279 | 274 |
280 void TrayBackgroundView::UpdateShouldShowLauncher() { | 275 void TrayBackgroundView::UpdateShouldShowLauncher() { |
281 status_area_widget()->UpdateShouldShowLauncher(); | 276 status_area_widget()->UpdateShouldShowLauncher(); |
282 } | 277 } |
283 | 278 |
284 } // namespace internal | 279 } // namespace internal |
285 } // namespace ash | 280 } // namespace ash |
OLD | NEW |