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 fc24c14932af7c4673e9a46c1d195ce8701d965a..cf23bfe146bf7a754b742edabb1d43462716fcc1 100644 |
--- a/ash/system/tray/tray_background_view.cc |
+++ b/ash/system/tray/tray_background_view.cc |
@@ -22,12 +22,15 @@ |
#include "ui/aura/window.h" |
#include "ui/aura/window_event_dispatcher.h" |
#include "ui/base/resource/resource_bundle.h" |
+#include "ui/compositor/layer.h" |
+#include "ui/compositor/scoped_layer_animation_settings.h" |
#include "ui/gfx/canvas.h" |
#include "ui/gfx/image/image_skia.h" |
#include "ui/gfx/image/image_skia_operations.h" |
#include "ui/gfx/rect.h" |
#include "ui/gfx/screen.h" |
#include "ui/gfx/skia_util.h" |
+#include "ui/gfx/transform.h" |
#include "ui/views/background.h" |
#include "ui/views/layout/box_layout.h" |
@@ -38,6 +41,7 @@ const int kTrayBackgroundHoverAlpha = 150; |
const SkColor kTrayBackgroundPressedColor = SkColorSetRGB(66, 129, 244); |
const int kAnimationDurationForPopupMS = 200; |
+const int kAnimationDurationForVisibility = 200; |
} // namespace |
@@ -307,6 +311,9 @@ TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget) |
tray_container_ = new TrayContainer(shelf_alignment_); |
SetContents(tray_container_); |
tray_event_filter_.reset(new TrayEventFilter); |
+ |
+ SetPaintToLayer(true); |
+ SetFillsBoundsOpaquely(false); |
} |
TrayBackgroundView::~TrayBackgroundView() { |
@@ -319,6 +326,41 @@ void TrayBackgroundView::Initialize() { |
SetTrayBorder(); |
} |
+void TrayBackgroundView::SetVisible(bool set_visible) { |
flackr
2014/04/30 16:06:40
s/set_visible/visible to match the variable name i
jonross
2014/04/30 21:25:38
Done.
|
+ if (set_visible == visible()) |
+ return; |
+ |
+ if (set_visible) |
+ views::View::SetVisible(set_visible); |
flackr
2014/04/30 16:06:40
I believe you should be able to SetVisible(false)
jonross
2014/04/30 21:25:38
In order to user layer()->SetVisibility(false) I w
|
+ |
+ layer()->GetAnimator()->StopAnimating(); |
+ ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator()); |
+ animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
+ kAnimationDurationForVisibility)); |
+ animation.SetPreemptionStrategy( |
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
+ animation.AddObserver(this); |
+ |
+ if (set_visible) { |
+ layer()->SetOpacity(1.0f); |
+ gfx::Transform transform; |
+ transform.Translate(0.0f, 0.0f); |
+ transform.Scale(1.0f, 1.0f); |
+ layer()->SetTransform(transform); |
+ } else { |
+ layer()->SetOpacity(0.0f); |
+ gfx::Transform transform; |
+ if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM || |
+ shelf_alignment_ == SHELF_ALIGNMENT_TOP) { |
flackr
2014/04/30 16:06:40
nit: bad indent, should line up with above line.
jonross
2014/04/30 21:25:38
Done.
|
+ transform.Translate(width(), height() / 2.0f); |
+ } else { |
+ transform.Translate(width() / 2.0f, height()); |
+ } |
+ transform.Scale(0.01f, 0.01f); |
flackr
2014/04/30 16:06:40
Use constants for non 0 or 1 values.
jonross
2014/04/30 21:25:38
Done.
|
+ layer()->SetTransform(transform); |
+ } |
+} |
+ |
const char* TrayBackgroundView::GetClassName() const { |
return kViewClassName; |
} |
@@ -387,6 +429,18 @@ ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { |
} |
void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
+ if (!visible() && shelf_alignment_ != alignment) { |
+ // A translation transform was applied when becoming hidden. Swap the |
+ // transform to be the offscreen position for the new alignment. |
flackr
2014/04/30 16:06:40
It'd probably make more sense to set the correct t
jonross
2014/04/30 21:25:38
Done.
|
+ gfx::Transform transform; |
+ if (alignment == SHELF_ALIGNMENT_BOTTOM || alignment == SHELF_ALIGNMENT_TOP) |
+ transform.Translate(width(), height() / 2.0f); |
+ else |
+ transform.Translate(width() /2.0f, height()); |
+ transform.Scale(0.01f, 0.01f); |
+ layer()->SetTransform(transform); |
+ } |
+ |
shelf_alignment_ = alignment; |
SetTrayBorder(); |
tray_container_->SetAlignment(alignment); |
@@ -420,6 +474,11 @@ void TrayBackgroundView::SetTrayBorder() { |
top_edge, left_edge, bottom_edge, right_edge)); |
} |
+void TrayBackgroundView::OnImplicitAnimationsCompleted() { |
+ if (layer()->opacity() == 0.0f) |
+ views::View::SetVisible(false); |
+} |
+ |
void TrayBackgroundView::InitializeBubbleAnimations( |
views::Widget* bubble_widget) { |
wm::SetWindowVisibilityAnimationType( |