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