Chromium Code Reviews| 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 (CommandLine::ForCurrentProcess()-> | |
| 433 HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) { | |
|
flackr
2014/09/03 16:41:44
Curious, does this introduce any perf hit? If so,
jonross
2014/09/03 18:51:44
Done.
| |
| 434 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | |
| 435 SetDrawBackgroundAsActive(true); | |
| 436 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | |
| 437 event->type() == ui::ET_GESTURE_TAP_CANCEL) { | |
| 438 SetDrawBackgroundAsActive(false); | |
| 439 } | |
| 440 } | |
| 441 ActionableView::OnGestureEvent(event); | |
| 442 } | |
| 443 | |
| 429 void TrayBackgroundView::UpdateBackground(int alpha) { | 444 void TrayBackgroundView::UpdateBackground(int alpha) { |
| 430 // The animator should never fire when the alternate shelf layout is used. | 445 // The animator should never fire when the alternate shelf layout is used. |
| 431 if (!background_ || draw_background_as_active_) | 446 if (!background_ || draw_background_as_active_) |
| 432 return; | 447 return; |
| 433 background_->set_alpha(hide_background_animator_.alpha() + | 448 background_->set_alpha(hide_background_animator_.alpha() + |
| 434 hover_background_animator_.alpha()); | 449 hover_background_animator_.alpha()); |
| 435 SchedulePaint(); | 450 SchedulePaint(); |
| 436 } | 451 } |
| 437 | 452 |
| 438 void TrayBackgroundView::SetContents(views::View* contents) { | 453 void TrayBackgroundView::SetContents(views::View* contents) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 case SHELF_ALIGNMENT_RIGHT: | 636 case SHELF_ALIGNMENT_RIGHT: |
| 622 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | 637 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
| 623 case SHELF_ALIGNMENT_TOP: | 638 case SHELF_ALIGNMENT_TOP: |
| 624 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; | 639 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; |
| 625 } | 640 } |
| 626 NOTREACHED(); | 641 NOTREACHED(); |
| 627 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 642 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
| 628 } | 643 } |
| 629 | 644 |
| 630 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { | 645 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { |
| 646 if (draw_background_as_active_ == visible) | |
| 647 return; | |
| 631 draw_background_as_active_ = visible; | 648 draw_background_as_active_ = visible; |
| 632 if (!background_) | 649 if (!background_) |
| 633 return; | 650 return; |
| 634 | 651 |
| 635 // Do not change gradually, changing color between grey and blue is weird. | 652 // Do not change gradually, changing color between grey and blue is weird. |
| 636 if (draw_background_as_active_) | 653 if (draw_background_as_active_) |
| 637 background_->set_color(kTrayBackgroundPressedColor); | 654 background_->set_color(kTrayBackgroundPressedColor); |
| 638 else if (hovered_) | 655 else if (hovered_) |
| 639 background_->set_alpha(kTrayBackgroundHoverAlpha); | 656 background_->set_alpha(kTrayBackgroundHoverAlpha); |
| 640 else | 657 else |
| 641 background_->set_alpha(kTrayBackgroundAlpha); | 658 background_->set_alpha(kTrayBackgroundAlpha); |
| 642 SchedulePaint(); | 659 SchedulePaint(); |
| 643 } | 660 } |
| 644 | 661 |
| 645 void TrayBackgroundView::UpdateBubbleViewArrow( | 662 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 646 views::TrayBubbleView* bubble_view) { | 663 views::TrayBubbleView* bubble_view) { |
| 647 // Nothing to do here. | 664 // Nothing to do here. |
| 648 } | 665 } |
| 649 | 666 |
| 650 } // namespace ash | 667 } // namespace ash |
| OLD | NEW |