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" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
11 #include "ash/shelf/shelf_widget.h" | 11 #include "ash/shelf/shelf_widget.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
14 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
15 #include "ash/system/status_area_widget_delegate.h" | 15 #include "ash/system/status_area_widget_delegate.h" |
16 #include "ash/system/tray/system_tray.h" | 16 #include "ash/system/tray/system_tray.h" |
17 #include "ash/system/tray/tray_constants.h" | 17 #include "ash/system/tray/tray_constants.h" |
18 #include "ash/system/tray/tray_event_filter.h" | 18 #include "ash/system/tray/tray_event_filter.h" |
19 #include "ash/wm/window_animations.h" | 19 #include "ash/wm/window_animations.h" |
| 20 #include "base/command_line.h" |
20 #include "grit/ash_resources.h" | 21 #include "grit/ash_resources.h" |
21 #include "ui/accessibility/ax_view_state.h" | 22 #include "ui/accessibility/ax_view_state.h" |
22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
23 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/compositor/layer.h" | 26 #include "ui/compositor/layer.h" |
26 #include "ui/compositor/layer_animation_element.h" | 27 #include "ui/compositor/layer_animation_element.h" |
27 #include "ui/compositor/scoped_layer_animation_settings.h" | 28 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 29 #include "ui/events/event_constants.h" |
28 #include "ui/gfx/animation/tween.h" | 30 #include "ui/gfx/animation/tween.h" |
29 #include "ui/gfx/canvas.h" | 31 #include "ui/gfx/canvas.h" |
30 #include "ui/gfx/image/image_skia.h" | 32 #include "ui/gfx/image/image_skia.h" |
31 #include "ui/gfx/image/image_skia_operations.h" | 33 #include "ui/gfx/image/image_skia_operations.h" |
32 #include "ui/gfx/rect.h" | 34 #include "ui/gfx/rect.h" |
33 #include "ui/gfx/screen.h" | 35 #include "ui/gfx/screen.h" |
34 #include "ui/gfx/skia_util.h" | 36 #include "ui/gfx/skia_util.h" |
35 #include "ui/gfx/transform.h" | 37 #include "ui/gfx/transform.h" |
36 #include "ui/views/background.h" | 38 #include "ui/views/background.h" |
37 #include "ui/views/layout/box_layout.h" | 39 #include "ui/views/layout/box_layout.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 return false; | 421 return false; |
420 } | 422 } |
421 | 423 |
422 gfx::Rect TrayBackgroundView::GetFocusBounds() { | 424 gfx::Rect TrayBackgroundView::GetFocusBounds() { |
423 // 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 |
424 // 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 |
425 // should be only around the container. | 427 // should be only around the container. |
426 return GetContentsBounds(); | 428 return GetContentsBounds(); |
427 } | 429 } |
428 | 430 |
| 431 void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { |
| 432 if (event->type() == ui::ET_GESTURE_TAP_DOWN && |
| 433 CommandLine::ForCurrentProcess()-> |
| 434 HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) { |
| 435 SetDrawBackgroundAsActive(true); |
| 436 } else if ((event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 437 event->type() == ui::ET_GESTURE_TAP_CANCEL) && |
| 438 CommandLine::ForCurrentProcess()-> |
| 439 HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) { |
| 440 SetDrawBackgroundAsActive(false); |
| 441 } |
| 442 ActionableView::OnGestureEvent(event); |
| 443 } |
| 444 |
429 void TrayBackgroundView::UpdateBackground(int alpha) { | 445 void TrayBackgroundView::UpdateBackground(int alpha) { |
430 // The animator should never fire when the alternate shelf layout is used. | 446 // The animator should never fire when the alternate shelf layout is used. |
431 if (!background_ || draw_background_as_active_) | 447 if (!background_ || draw_background_as_active_) |
432 return; | 448 return; |
433 background_->set_alpha(hide_background_animator_.alpha() + | 449 background_->set_alpha(hide_background_animator_.alpha() + |
434 hover_background_animator_.alpha()); | 450 hover_background_animator_.alpha()); |
435 SchedulePaint(); | 451 SchedulePaint(); |
436 } | 452 } |
437 | 453 |
438 void TrayBackgroundView::SetContents(views::View* contents) { | 454 void TrayBackgroundView::SetContents(views::View* contents) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 case SHELF_ALIGNMENT_RIGHT: | 637 case SHELF_ALIGNMENT_RIGHT: |
622 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | 638 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
623 case SHELF_ALIGNMENT_TOP: | 639 case SHELF_ALIGNMENT_TOP: |
624 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; | 640 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; |
625 } | 641 } |
626 NOTREACHED(); | 642 NOTREACHED(); |
627 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 643 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
628 } | 644 } |
629 | 645 |
630 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { | 646 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { |
| 647 if (draw_background_as_active_ == visible) |
| 648 return; |
631 draw_background_as_active_ = visible; | 649 draw_background_as_active_ = visible; |
632 if (!background_) | 650 if (!background_) |
633 return; | 651 return; |
634 | 652 |
635 // Do not change gradually, changing color between grey and blue is weird. | 653 // Do not change gradually, changing color between grey and blue is weird. |
636 if (draw_background_as_active_) | 654 if (draw_background_as_active_) |
637 background_->set_color(kTrayBackgroundPressedColor); | 655 background_->set_color(kTrayBackgroundPressedColor); |
638 else if (hovered_) | 656 else if (hovered_) |
639 background_->set_alpha(kTrayBackgroundHoverAlpha); | 657 background_->set_alpha(kTrayBackgroundHoverAlpha); |
640 else | 658 else |
641 background_->set_alpha(kTrayBackgroundAlpha); | 659 background_->set_alpha(kTrayBackgroundAlpha); |
642 SchedulePaint(); | 660 SchedulePaint(); |
643 } | 661 } |
644 | 662 |
645 void TrayBackgroundView::UpdateBubbleViewArrow( | 663 void TrayBackgroundView::UpdateBubbleViewArrow( |
646 views::TrayBubbleView* bubble_view) { | 664 views::TrayBubbleView* bubble_view) { |
647 // Nothing to do here. | 665 // Nothing to do here. |
648 } | 666 } |
649 | 667 |
650 } // namespace ash | 668 } // namespace ash |
OLD | NEW |