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/ash_switches.h" | |
8 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
9 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
11 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
12 #include "ash/shell.h" | 11 #include "ash/shell.h" |
13 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
14 #include "ash/system/status_area_widget.h" | 13 #include "ash/system/status_area_widget.h" |
15 #include "ash/system/status_area_widget_delegate.h" | 14 #include "ash/system/status_area_widget_delegate.h" |
16 #include "ash/system/tray/system_tray.h" | 15 #include "ash/system/tray/system_tray.h" |
17 #include "ash/system/tray/tray_constants.h" | 16 #include "ash/system/tray/tray_constants.h" |
18 #include "ash/system/tray/tray_event_filter.h" | 17 #include "ash/system/tray/tray_event_filter.h" |
19 #include "ash/wm/window_animations.h" | 18 #include "ash/wm/window_animations.h" |
20 #include "base/command_line.h" | 19 #include "base/command_line.h" |
21 #include "grit/ash_resources.h" | 20 #include "grit/ash_resources.h" |
22 #include "ui/accessibility/ax_view_state.h" | 21 #include "ui/accessibility/ax_view_state.h" |
23 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
24 #include "ui/aura/window_event_dispatcher.h" | 23 #include "ui/aura/window_event_dispatcher.h" |
25 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/base/ui_base_switches_util.h" |
26 #include "ui/compositor/layer.h" | 26 #include "ui/compositor/layer.h" |
27 #include "ui/compositor/layer_animation_element.h" | 27 #include "ui/compositor/layer_animation_element.h" |
28 #include "ui/compositor/scoped_layer_animation_settings.h" | 28 #include "ui/compositor/scoped_layer_animation_settings.h" |
29 #include "ui/events/event_constants.h" | 29 #include "ui/events/event_constants.h" |
30 #include "ui/gfx/animation/tween.h" | 30 #include "ui/gfx/animation/tween.h" |
31 #include "ui/gfx/canvas.h" | 31 #include "ui/gfx/canvas.h" |
32 #include "ui/gfx/image/image_skia.h" | 32 #include "ui/gfx/image/image_skia.h" |
33 #include "ui/gfx/image/image_skia_operations.h" | 33 #include "ui/gfx/image/image_skia_operations.h" |
34 #include "ui/gfx/rect.h" | 34 #include "ui/gfx/rect.h" |
35 #include "ui/gfx/screen.h" | 35 #include "ui/gfx/screen.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 tray_container_(NULL), | 303 tray_container_(NULL), |
304 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | 304 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), |
305 background_(NULL), | 305 background_(NULL), |
306 hide_background_animator_(this, 0, kTrayBackgroundAlpha), | 306 hide_background_animator_(this, 0, kTrayBackgroundAlpha), |
307 hover_background_animator_( | 307 hover_background_animator_( |
308 this, | 308 this, |
309 0, | 309 0, |
310 kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha), | 310 kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha), |
311 hovered_(false), | 311 hovered_(false), |
312 draw_background_as_active_(false), | 312 draw_background_as_active_(false), |
313 touch_feedback_enabled_(false), | |
314 widget_observer_(new TrayWidgetObserver(this)) { | 313 widget_observer_(new TrayWidgetObserver(this)) { |
315 set_notify_enter_exit_on_child(true); | 314 set_notify_enter_exit_on_child(true); |
316 | 315 |
317 // Initially we want to paint the background, but without the hover effect. | 316 // Initially we want to paint the background, but without the hover effect. |
318 hide_background_animator_.SetPaintsBackground( | 317 hide_background_animator_.SetPaintsBackground( |
319 true, BACKGROUND_CHANGE_IMMEDIATE); | 318 true, BACKGROUND_CHANGE_IMMEDIATE); |
320 hover_background_animator_.SetPaintsBackground( | 319 hover_background_animator_.SetPaintsBackground( |
321 false, BACKGROUND_CHANGE_IMMEDIATE); | 320 false, BACKGROUND_CHANGE_IMMEDIATE); |
322 | 321 |
323 tray_container_ = new TrayContainer(shelf_alignment_); | 322 tray_container_ = new TrayContainer(shelf_alignment_); |
324 SetContents(tray_container_); | 323 SetContents(tray_container_); |
325 tray_event_filter_.reset(new TrayEventFilter); | 324 tray_event_filter_.reset(new TrayEventFilter); |
326 | 325 |
327 SetPaintToLayer(true); | 326 SetPaintToLayer(true); |
328 SetFillsBoundsOpaquely(false); | 327 SetFillsBoundsOpaquely(false); |
329 // Start the tray items not visible, because visibility changes are animated. | 328 // Start the tray items not visible, because visibility changes are animated. |
330 views::View::SetVisible(false); | 329 views::View::SetVisible(false); |
331 | |
332 if (CommandLine::ForCurrentProcess()-> | |
333 HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) { | |
334 touch_feedback_enabled_ = true; | |
335 } | |
336 } | 330 } |
337 | 331 |
338 TrayBackgroundView::~TrayBackgroundView() { | 332 TrayBackgroundView::~TrayBackgroundView() { |
339 if (GetWidget()) | 333 if (GetWidget()) |
340 GetWidget()->RemoveObserver(widget_observer_.get()); | 334 GetWidget()->RemoveObserver(widget_observer_.get()); |
341 } | 335 } |
342 | 336 |
343 void TrayBackgroundView::Initialize() { | 337 void TrayBackgroundView::Initialize() { |
344 GetWidget()->AddObserver(widget_observer_.get()); | 338 GetWidget()->AddObserver(widget_observer_.get()); |
345 SetTrayBorder(); | 339 SetTrayBorder(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 422 } |
429 | 423 |
430 gfx::Rect TrayBackgroundView::GetFocusBounds() { | 424 gfx::Rect TrayBackgroundView::GetFocusBounds() { |
431 // The tray itself expands to the right and bottom edge of the screen to make | 425 // The tray itself expands to the right and bottom edge of the screen to make |
432 // sure clicking on the edges brings up the popup. However, the focus border | 426 // sure clicking on the edges brings up the popup. However, the focus border |
433 // should be only around the container. | 427 // should be only around the container. |
434 return GetContentsBounds(); | 428 return GetContentsBounds(); |
435 } | 429 } |
436 | 430 |
437 void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { | 431 void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { |
438 if (touch_feedback_enabled_) { | 432 if (switches::IsTouchFeedbackEnabled()) { |
439 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 433 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
440 SetDrawBackgroundAsActive(true); | 434 SetDrawBackgroundAsActive(true); |
441 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 435 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
442 event->type() == ui::ET_GESTURE_TAP_CANCEL) { | 436 event->type() == ui::ET_GESTURE_TAP_CANCEL) { |
443 SetDrawBackgroundAsActive(false); | 437 SetDrawBackgroundAsActive(false); |
444 } | 438 } |
445 } | 439 } |
446 ActionableView::OnGestureEvent(event); | 440 ActionableView::OnGestureEvent(event); |
447 } | 441 } |
448 | 442 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 background_->set_alpha(kTrayBackgroundAlpha); | 657 background_->set_alpha(kTrayBackgroundAlpha); |
664 SchedulePaint(); | 658 SchedulePaint(); |
665 } | 659 } |
666 | 660 |
667 void TrayBackgroundView::UpdateBubbleViewArrow( | 661 void TrayBackgroundView::UpdateBubbleViewArrow( |
668 views::TrayBubbleView* bubble_view) { | 662 views::TrayBubbleView* bubble_view) { |
669 // Nothing to do here. | 663 // Nothing to do here. |
670 } | 664 } |
671 | 665 |
672 } // namespace ash | 666 } // namespace ash |
OLD | NEW |