diff options
author | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-28 23:21:31 +0000 |
---|---|---|
committer | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-28 23:21:31 +0000 |
commit | 5cc1b6590873a23e33a6a14ff8e992f3dba69679 (patch) | |
tree | 879aef806332971dd1349e01ad5d9de6aef1a172 /ash | |
parent | 18fe6adb58e43b891619a7e267ffe4d500f32d80 (diff) | |
download | chromium_src-5cc1b6590873a23e33a6a14ff8e992f3dba69679.zip chromium_src-5cc1b6590873a23e33a6a14ff8e992f3dba69679.tar.gz chromium_src-5cc1b6590873a23e33a6a14ff8e992f3dba69679.tar.bz2 |
Creating multi profile animations for switching users and teleporting of windows.
This CL is adding window animations for the following multi profile related actions:
- switching the user
- teleporting of windows
- window ownership changes
The user switch animation is as follows:
Time: ----->
Screen: A X B
- The desktop cross dissolves between A -> B
- User A's windows fade out between A -> X
- User B's windows get faded in between X -> B
- User A's shelf gets hidden between A -> X
- The user icon in the system tray as well as the shelf configuration changes at 'X'.
- User B's shelf gets faded on between X -> B
So at time X the user would see a half way cross dissolved desktop and shared windows (if there are any).
Since there is no guarantee that there is an animation going from A -> X an additional timer was used to kick off the second animation portion.
Further gotchas:
- Animations of the individual shelf items were in the past incorrectly performed with another animator which produced a lag for some components (e.g. the activation bar lagged and / or there was a gap between icons in the tray and the screen border when playing the animation fast.
- Wallpaper loading was so delayed that the animations started after all other animations were done.
BUG=336639, 307279
Review URL: https://codereview.chromium.org/130983007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247517 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/default_user_wallpaper_delegate.cc | 8 | ||||
-rw-r--r-- | ash/default_user_wallpaper_delegate.h | 3 | ||||
-rw-r--r-- | ash/desktop_background/desktop_background_view.cc | 6 | ||||
-rw-r--r-- | ash/desktop_background/user_wallpaper_delegate.h | 7 | ||||
-rw-r--r-- | ash/shelf/shelf_layout_manager.cc | 14 | ||||
-rw-r--r-- | ash/shelf/shelf_layout_manager.h | 7 | ||||
-rw-r--r-- | ash/shelf/shelf_view.cc | 28 | ||||
-rw-r--r-- | ash/system/tray/default_system_tray_delegate.cc | 3 | ||||
-rw-r--r-- | ash/system/tray/default_system_tray_delegate.h | 1 | ||||
-rw-r--r-- | ash/system/tray/system_tray_delegate.h | 5 |
10 files changed, 79 insertions, 3 deletions
diff --git a/ash/default_user_wallpaper_delegate.cc b/ash/default_user_wallpaper_delegate.cc index 168fc9d..5caddf0 100644 --- a/ash/default_user_wallpaper_delegate.cc +++ b/ash/default_user_wallpaper_delegate.cc @@ -13,6 +13,14 @@ int DefaultUserWallpaperDelegate::GetAnimationType() { return views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; } +int DefaultUserWallpaperDelegate::GetAnimationDurationOverride() { + return 0; +} + +void DefaultUserWallpaperDelegate::SetAnimationDurationOverride( + int animation_duration_in_ms) { +} + bool DefaultUserWallpaperDelegate::ShouldShowInitialAnimation() { return false; } diff --git a/ash/default_user_wallpaper_delegate.h b/ash/default_user_wallpaper_delegate.h index 2e22e30..9978738 100644 --- a/ash/default_user_wallpaper_delegate.h +++ b/ash/default_user_wallpaper_delegate.h @@ -19,6 +19,9 @@ class ASH_EXPORT DefaultUserWallpaperDelegate : public UserWallpaperDelegate { // UserWallpaperDelegate overrides: virtual int GetAnimationType() OVERRIDE; + virtual int GetAnimationDurationOverride() OVERRIDE; + virtual void SetAnimationDurationOverride( + int animation_duration_in_ms) OVERRIDE; virtual bool ShouldShowInitialAnimation() OVERRIDE; virtual void UpdateWallpaper() OVERRIDE; virtual void InitializeWallpaper() OVERRIDE; diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc index 6a7bf82..acf4e3b 100644 --- a/ash/desktop_background/desktop_background_view.cc +++ b/ash/desktop_background/desktop_background_view.cc @@ -207,6 +207,12 @@ views::Widget* CreateDesktopBackground(aura::Window* root_window, Shell::GetInstance()->session_state_delegate()->NumberOfLoggedInUsers()) { views::corewm::SetWindowVisibilityAnimationTransition( desktop_widget->GetNativeView(), views::corewm::ANIMATE_SHOW); + int duration_override = wallpaper_delegate->GetAnimationDurationOverride(); + if (duration_override) { + views::corewm::SetWindowVisibilityAnimationDuration( + desktop_widget->GetNativeView(), + base::TimeDelta::FromMilliseconds(duration_override)); + } } else { // Disable animation if transition to login screen from an empty background. views::corewm::SetWindowVisibilityAnimationTransition( diff --git a/ash/desktop_background/user_wallpaper_delegate.h b/ash/desktop_background/user_wallpaper_delegate.h index 440d284..e1e7f70 100644 --- a/ash/desktop_background/user_wallpaper_delegate.h +++ b/ash/desktop_background/user_wallpaper_delegate.h @@ -18,6 +18,13 @@ class ASH_EXPORT UserWallpaperDelegate { // wallpaper. virtual int GetAnimationType() = 0; + // Returns the wallpaper animation duration in ms. A value of 0 indicates + // that the default should be used. + virtual int GetAnimationDurationOverride() = 0; + + // Sets wallpaper animation duration in ms. Pass 0 to use the default. + virtual void SetAnimationDurationOverride(int animation_duration_in_ms) = 0; + // Should the slower initial animation be shown (as opposed to the faster // animation that's used e.g. when switching from one user's wallpaper to // another's on the login screen)? diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 21fb0b3..b78cc15 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc @@ -207,7 +207,8 @@ ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf) gesture_drag_status_(GESTURE_DRAG_NONE), gesture_drag_amount_(0.f), gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), - update_shelf_observer_(NULL) { + update_shelf_observer_(NULL), + duration_override_in_ms_(0) { Shell::GetInstance()->AddShellObserver(this); Shell::GetInstance()->lock_state_controller()->AddObserver(this); aura::client::GetActivationClient(root_window_)->AddObserver(this); @@ -498,6 +499,11 @@ void ShelfLayoutManager::CancelGestureDrag() { gesture_drag_status_ = GESTURE_DRAG_NONE; } +void ShelfLayoutManager::SetAnimationDurationOverride( + int duration_override_in_ms) { + duration_override_in_ms_ = duration_override_in_ms; +} + //////////////////////////////////////////////////////////////////////////////// // ShelfLayoutManager, aura::LayoutManager implementation: @@ -660,13 +666,15 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity( ui::ScopedLayerAnimationSettings status_animation_setter( GetLayer(shelf_->status_area_widget())->GetAnimator()); if (animate) { + int duration = duration_override_in_ms_ ? duration_override_in_ms_ : + kCrossFadeDurationMS; shelf_animation_setter.SetTransitionDuration( - base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); + base::TimeDelta::FromMilliseconds(duration)); shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); shelf_animation_setter.SetPreemptionStrategy( ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); status_animation_setter.SetTransitionDuration( - base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); + base::TimeDelta::FromMilliseconds(duration)); status_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); status_animation_setter.SetPreemptionStrategy( ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h index 18d6ba4..7a96c3a 100644 --- a/ash/shelf/shelf_layout_manager.h +++ b/ash/shelf/shelf_layout_manager.h @@ -167,6 +167,10 @@ class ASH_EXPORT ShelfLayoutManager : void CompleteGestureDrag(const ui::GestureEvent& gesture); void CancelGestureDrag(); + // Set an animation duration override for the show / hide animation of the + // shelf. Specifying 0 leads to use the default. + void SetAnimationDurationOverride(int duration_override_in_ms); + // Overridden from aura::LayoutManager: virtual void OnWindowResized() OVERRIDE; virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; @@ -408,6 +412,9 @@ class ASH_EXPORT ShelfLayoutManager : // The bounds of the dock. gfx::Rect dock_bounds_; + // The show hide animation duration override or 0 for default. + int duration_override_in_ms_; + DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); }; diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index f3d840e..5796796 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -121,6 +121,28 @@ const float kDraggedImageOpacity = 0.5f; namespace { +// A class to temporarily disable a given bounds animator. +class BoundsAnimatorDisabler { + public: + BoundsAnimatorDisabler(views::BoundsAnimator* bounds_animator) + : old_duration_(bounds_animator->GetAnimationDuration()), + bounds_animator_(bounds_animator) { + bounds_animator_->SetAnimationDuration(1); + } + + ~BoundsAnimatorDisabler() { + bounds_animator_->SetAnimationDuration(old_duration_); + } + + private: + // The previous animation duration. + int old_duration_; + // The bounds animator which gets used. + views::BoundsAnimator* bounds_animator_; + + DISALLOW_COPY_AND_ASSIGN(BoundsAnimatorDisabler); +}; + // The MenuModelAdapter gets slightly changed to adapt the menu appearance to // our requirements. class ShelfMenuModelAdapter : public views::MenuModelAdapter { @@ -1490,6 +1512,12 @@ gfx::Size ShelfView::GetPreferredSize() { } void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { + // This bounds change is produced by the shelf movement and all content has + // to follow. Using an animation at that time would produce a time lag since + // the animation of the BoundsAnimator has itself a delay before it arrives + // at the required location. As such we tell the animator to go there + // immediately. + BoundsAnimatorDisabler disabler(bounds_animator_.get()); LayoutToIdealBounds(); FOR_EACH_OBSERVER(ShelfIconObserver, observers_, OnShelfIconPositionsChanged()); diff --git a/ash/system/tray/default_system_tray_delegate.cc b/ash/system/tray/default_system_tray_delegate.cc index ef51585d..382cbbc 100644 --- a/ash/system/tray/default_system_tray_delegate.cc +++ b/ash/system/tray/default_system_tray_delegate.cc @@ -276,4 +276,7 @@ int DefaultSystemTrayDelegate::GetSystemTrayMenuWidth() { return 300; } +void DefaultSystemTrayDelegate::ActiveUserWasChanged() { +} + } // namespace ash diff --git a/ash/system/tray/default_system_tray_delegate.h b/ash/system/tray/default_system_tray_delegate.h index f85b6ca..ee51893 100644 --- a/ash/system/tray/default_system_tray_delegate.h +++ b/ash/system/tray/default_system_tray_delegate.h @@ -88,6 +88,7 @@ class ASH_EXPORT DefaultSystemTrayDelegate : public SystemTrayDelegate { virtual bool GetSessionLengthLimit( base::TimeDelta* session_length_limit) OVERRIDE; virtual int GetSystemTrayMenuWidth() OVERRIDE; + virtual void ActiveUserWasChanged() OVERRIDE; private: bool bluetooth_enabled_; diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h index ee325dd..d12d764 100644 --- a/ash/system/tray/system_tray_delegate.h +++ b/ash/system/tray/system_tray_delegate.h @@ -314,6 +314,11 @@ class ASH_EXPORT SystemTrayDelegate { // Get the system tray menu size in pixels (dependent on the language). virtual int GetSystemTrayMenuWidth() = 0; + + // The active user has been changed. This will be called when the UI is ready + // to be switched to the new user. + // Note: This will happen after SessionStateObserver::ActiveUserChanged fires. + virtual void ActiveUserWasChanged() = 0; }; } // namespace ash |