| Index: ash/system/tray/tray_background_view.cc
|
| diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
|
| index 0a2a196561af7ce97d1e7c9b6128cd793c431459..766577f571808a53364c02fc77ec3e8b81ac5496 100644
|
| --- a/ash/system/tray/tray_background_view.cc
|
| +++ b/ash/system/tray/tray_background_view.cc
|
| @@ -11,6 +11,7 @@
|
| #include "ash/system/status_area_widget_delegate.h"
|
| #include "ash/system/tray/tray_constants.h"
|
| #include "ui/aura/window.h"
|
| +#include "ui/compositor/layer_animation_observer.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/skia_util.h"
|
| #include "ui/views/background.h"
|
| @@ -32,6 +33,33 @@ const int kTrayContainerHorizontalPaddingVerticalAlignment = 1;
|
| namespace ash {
|
| namespace internal {
|
|
|
| +// Observe the tray layer animation and update the anchor when it changes.
|
| +// TODO(stevenjb): Observe or mirror the actual animation, not just the start
|
| +// and end points.
|
| +class TrayLayerAnimationObserver : public ui::LayerAnimationObserver {
|
| + public:
|
| + explicit TrayLayerAnimationObserver(TrayBackgroundView* host)
|
| + : host_(host) {
|
| + }
|
| +
|
| + virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) {
|
| + host_->AnchorUpdated();
|
| + }
|
| +
|
| + virtual void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) {
|
| + host_->AnchorUpdated();
|
| + }
|
| +
|
| + virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* sequence) {
|
| + host_->AnchorUpdated();
|
| + }
|
| +
|
| + private:
|
| + TrayBackgroundView* host_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TrayLayerAnimationObserver);
|
| +};
|
| +
|
| class TrayBackground : public views::Background {
|
| public:
|
| TrayBackground() : alpha_(kTrayBackgroundAlpha) {}
|
| @@ -131,7 +159,9 @@ TrayBackgroundView::TrayBackgroundView(
|
| ALLOW_THIS_IN_INITIALIZER_LIST(hide_background_animator_(
|
| this, 0, kTrayBackgroundAlpha)),
|
| ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(
|
| - this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) {
|
| + this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)),
|
| + ALLOW_THIS_IN_INITIALIZER_LIST(layer_animation_observer_(
|
| + new TrayLayerAnimationObserver(this))) {
|
| set_notify_enter_exit_on_child(true);
|
|
|
| // Initially we want to paint the background, but without the hover effect.
|
| @@ -144,6 +174,16 @@ TrayBackgroundView::TrayBackgroundView(
|
| }
|
|
|
| TrayBackgroundView::~TrayBackgroundView() {
|
| + if (GetWidget()) {
|
| + GetWidget()->GetNativeView()->layer()->GetAnimator()->RemoveObserver(
|
| + layer_animation_observer_.get());
|
| + }
|
| +}
|
| +
|
| +void TrayBackgroundView::Initialize() {
|
| + GetWidget()->GetNativeView()->layer()->GetAnimator()->AddObserver(
|
| + layer_animation_observer_.get());
|
| + SetBorder();
|
| }
|
|
|
| void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) {
|
| @@ -160,6 +200,21 @@ void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) {
|
| PreferredSizeChanged();
|
| }
|
|
|
| +void TrayBackgroundView::OnPaintFocusBorder(gfx::Canvas* canvas) {
|
| + // The tray itself expands to the right and bottom edge of the screen to make
|
| + // sure clicking on the edges brings up the popup. However, the focus border
|
| + // should be only around the container.
|
| + if (GetWidget() && GetWidget()->IsActive())
|
| + DrawBorder(canvas, GetContentsBounds());
|
| +}
|
| +
|
| +void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) {
|
| + // Return focus to the login view. See crbug.com/120500.
|
| + views::View* v = GetNextFocusableView();
|
| + if (v)
|
| + v->AboutToRequestFocusFromTabTraversal(reverse);
|
| +}
|
| +
|
| bool TrayBackgroundView::PerformAction(const ui::Event& event) {
|
| return false;
|
| }
|
|
|