summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 15:49:24 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 15:49:24 +0000
commit6e7c156915c1023fb5c2c3d949ec8cb2bc8e7dc1 (patch)
treefceb372c93bb818fa515dcbeac106f13d69e34be
parentef8f2b81cf1f65fb1a4b7abe8ca7b9d398e1c2dd (diff)
downloadchromium_src-6e7c156915c1023fb5c2c3d949ec8cb2bc8e7dc1.zip
chromium_src-6e7c156915c1023fb5c2c3d949ec8cb2bc8e7dc1.tar.gz
chromium_src-6e7c156915c1023fb5c2c3d949ec8cb2bc8e7dc1.tar.bz2
Animate the omnibox show/hide.
Also speeds up all animations from 200ms->120ms per feedback from Glen. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/9176012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118447 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/window_animations.cc118
-rw-r--r--ash/wm/window_animations.h15
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc9
-rw-r--r--ui/gfx/compositor/layer_animator.cc2
4 files changed, 116 insertions, 28 deletions
diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc
index 9ac6a44..6688146 100644
--- a/ash/wm/window_animations.cc
+++ b/ash/wm/window_animations.cc
@@ -14,13 +14,32 @@
namespace ash {
namespace internal {
+const char kWindowVisibilityAnimationTypeKey[] =
+ "WindowVisibilityAnimationType";
+} // namespace internal
+
+void SetWindowVisibilityAnimationType(aura::Window* window,
+ WindowVisibilityAnimationType type) {
+ window->SetIntProperty(internal::kWindowVisibilityAnimationTypeKey, type);
+}
+
+namespace internal {
namespace {
-const float kWindowAnimation_HideOpacity = 0.0f;
-const float kWindowAnimation_ShowOpacity = 1.0f;
+const float kWindowAnimation_HideOpacity = 0.f;
+const float kWindowAnimation_ShowOpacity = 1.f;
const float kWindowAnimation_TranslateFactor = -0.025f;
const float kWindowAnimation_ScaleFactor = 1.05f;
+const float kWindowAnimation_Vertical_TranslateY = 15.f;
+
+// Gets/sets the WindowVisibilityAnimationType associated with a window.
+WindowVisibilityAnimationType GetWindowVisibilityAnimationType(
+ aura::Window* window) {
+ return static_cast<WindowVisibilityAnimationType>(
+ window->GetIntProperty(kWindowVisibilityAnimationTypeKey));
+}
+
// Observes a hide animation.
// A window can be hidden for a variety of reasons. Sometimes, Hide() will be
// called and life is simple. Sometimes, the window is actually bound to a
@@ -70,31 +89,26 @@ class HidingWindowAnimationObserver : public ui::ImplicitAnimationObserver,
DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserver);
};
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// WindowAnimation, public:
-
-void AnimateShowWindow(aura::Window* window) {
- // Set the start state pre-animation.
+// Shows a window using an animation, animating its opacity from 0.f to 1.f, and
+// its transform from |start_transform| to |end_transform|.
+void AnimateShowWindowCommon(aura::Window* window,
+ const ui::Transform& start_transform,
+ const ui::Transform& end_transform) {
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
- ui::Transform transform;
- transform.ConcatScale(kWindowAnimation_ScaleFactor,
- kWindowAnimation_ScaleFactor);
- transform.ConcatTranslate(
- kWindowAnimation_TranslateFactor * window->bounds().width(),
- kWindowAnimation_TranslateFactor * window->bounds().height());
- window->layer()->SetTransform(transform);
+ window->layer()->SetTransform(start_transform);
{
// Property sets within this scope will be implicitly animated.
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
- window->layer()->SetTransform(ui::Transform());
+ window->layer()->SetTransform(end_transform);
window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
}
}
-void AnimateHideWindow(aura::Window* window) {
+// Hides a window using an animation, animating its opacity from 1.f to 0.f, and
+// its transform to |end_transform|.
+void AnimateHideWindowCommon(aura::Window* window,
+ const ui::Transform& end_transform) {
// The window's layer was just hidden, but we need it to draw until it's fully
// transparent, so we show it again. This is undone once the animation is
// complete.
@@ -105,14 +119,68 @@ void AnimateHideWindow(aura::Window* window) {
settings.AddImplicitObserver(new HidingWindowAnimationObserver(window));
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
+ window->layer()->SetTransform(end_transform);
+ }
+}
- ui::Transform transform;
- transform.ConcatScale(kWindowAnimation_ScaleFactor,
- kWindowAnimation_ScaleFactor);
- transform.ConcatTranslate(
- kWindowAnimation_TranslateFactor * window->bounds().width(),
- kWindowAnimation_TranslateFactor * window->bounds().height());
- window->layer()->SetTransform(transform);
+// Show/Hide windows using a shrink animation.
+void AnimateShowWindow_Drop(aura::Window* window) {
+ ui::Transform transform;
+ transform.ConcatScale(kWindowAnimation_ScaleFactor,
+ kWindowAnimation_ScaleFactor);
+ transform.ConcatTranslate(
+ kWindowAnimation_TranslateFactor * window->bounds().width(),
+ kWindowAnimation_TranslateFactor * window->bounds().height());
+ AnimateShowWindowCommon(window, transform, ui::Transform());
+}
+
+void AnimateHideWindow_Drop(aura::Window* window) {
+ ui::Transform transform;
+ transform.ConcatScale(kWindowAnimation_ScaleFactor,
+ kWindowAnimation_ScaleFactor);
+ transform.ConcatTranslate(
+ kWindowAnimation_TranslateFactor * window->bounds().width(),
+ kWindowAnimation_TranslateFactor * window->bounds().height());
+ AnimateHideWindowCommon(window, transform);
+}
+
+// Show/Hide windows using a vertical Glenimation.
+void AnimateShowWindow_Vertical(aura::Window* window) {
+ ui::Transform transform;
+ transform.ConcatTranslate(0, kWindowAnimation_Vertical_TranslateY);
+ AnimateShowWindowCommon(window, transform, ui::Transform());
+}
+
+void AnimateHideWindow_Vertical(aura::Window* window) {
+ ui::Transform transform;
+ transform.ConcatTranslate(0, kWindowAnimation_Vertical_TranslateY);
+ AnimateHideWindowCommon(window, transform);
+}
+
+} // namespace
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowAnimation, public:
+
+void AnimateShowWindow(aura::Window* window) {
+ switch (GetWindowVisibilityAnimationType(window)) {
+ case WINDOW_VISIBILITY_ANIMATION_TYPE_DROP:
+ AnimateShowWindow_Drop(window);
+ break;
+ case WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL:
+ AnimateShowWindow_Vertical(window);
+ break;
+ }
+}
+
+void AnimateHideWindow(aura::Window* window) {
+ switch (GetWindowVisibilityAnimationType(window)) {
+ case WINDOW_VISIBILITY_ANIMATION_TYPE_DROP:
+ AnimateHideWindow_Drop(window);
+ break;
+ case WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL:
+ AnimateHideWindow_Vertical(window);
+ break;
}
}
diff --git a/ash/wm/window_animations.h b/ash/wm/window_animations.h
index 146e1d8..6f022aa 100644
--- a/ash/wm/window_animations.h
+++ b/ash/wm/window_animations.h
@@ -6,14 +6,25 @@
#define ASH_WM_WINDOW_ANIMATIONS_H_
#pragma once
+#include "ash/ash_export.h"
+
namespace aura {
class Window;
}
namespace ash {
-namespace internal {
-// Implements a variety of canned animations for window transitions.
+// A variety of canned animations for window transitions.
+enum WindowVisibilityAnimationType {
+ WINDOW_VISIBILITY_ANIMATION_TYPE_DROP = 0, // Default. Window shrinks in.
+ WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL // Vertical Glenimation.
+};
+
+void ASH_EXPORT SetWindowVisibilityAnimationType(
+ aura::Window* window,
+ WindowVisibilityAnimationType type);
+
+namespace internal {
void AnimateShowWindow(aura::Window* window);
void AnimateHideWindow(aura::Window* window);
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
index 9821dc0..85ba2a2 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -44,6 +44,9 @@
#include "ui/views/widget/native_widget_win.h"
#endif
#endif
+#if defined(USE_AURA)
+#include "ash/wm/window_animations.h"
+#endif
namespace {
@@ -346,6 +349,12 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() {
params.parent_widget = location_bar_->GetWidget();
params.bounds = GetPopupBounds();
popup_->Init(params);
+#if defined(USE_AURA)
+ // TODO(beng): This should be if defined(USE_ASH)
+ ash::SetWindowVisibilityAnimationType(
+ popup_->GetNativeView(),
+ ash::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL);
+#endif
popup_->SetContentsView(this);
popup_->StackAbove(omnibox_view_->GetRelativeWindowForPopup());
if (!popup_.get()) {
diff --git a/ui/gfx/compositor/layer_animator.cc b/ui/gfx/compositor/layer_animator.cc
index 60a31dd..4a5cafa 100644
--- a/ui/gfx/compositor/layer_animator.cc
+++ b/ui/gfx/compositor/layer_animator.cc
@@ -21,7 +21,7 @@ class LayerAnimator;
namespace {
static const base::TimeDelta kDefaultTransitionDuration =
- base::TimeDelta::FromMilliseconds(200);
+ base::TimeDelta::FromMilliseconds(120);
static const base::TimeDelta kTimerInterval =
base::TimeDelta::FromMilliseconds(10);