Home | History | Annotate | Download | only in wm
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef ASH_WM_WINDOW_ANIMATIONS_H_
      6 #define ASH_WM_WINDOW_ANIMATIONS_H_
      7 
      8 #include "ash/ash_export.h"
      9 #include "ui/gfx/transform.h"
     10 #include "ui/views/corewm/window_animations.h"
     11 
     12 namespace aura {
     13 class Window;
     14 }
     15 namespace ui {
     16 class Layer;
     17 }
     18 
     19 // This is only for animations specific to Ash. For window animations shared
     20 // with desktop Chrome, see ui/views/corewm/window_animations.h.
     21 namespace ash {
     22 
     23 // An extension of the window animations provided by CoreWm. These should be
     24 // Ash-specific only.
     25 enum WindowVisibilityAnimationType {
     26   // Window scale/rotates down to its launcher icon.
     27   WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE =
     28       views::corewm::WINDOW_VISIBILITY_ANIMATION_MAX,
     29   // Fade in/out using brightness and grayscale web filters.
     30   WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE
     31 };
     32 
     33 // Direction for ash-specific window animations used in workspaces and
     34 // lock/unlock animations.
     35 enum LayerScaleAnimationDirection {
     36   LAYER_SCALE_ANIMATION_ABOVE,
     37   LAYER_SCALE_ANIMATION_BELOW,
     38 };
     39 
     40 // Amount of time for the cross fade animation.
     41 extern const int kCrossFadeDurationMS;
     42 
     43 // Animate a cross-fade of |window| from its current bounds to |new_bounds|.
     44 ASH_EXPORT void CrossFadeToBounds(aura::Window* window,
     45                                   const gfx::Rect& new_bounds);
     46 
     47 // Cross fades |layer| (which is a clone of |window|s layer before it was
     48 // resized) to |window|s current bounds. |new_workspace| is the Window of the
     49 // workspace |window| was added to.
     50 // This takes ownership of |layer|.
     51 ASH_EXPORT void CrossFadeWindowBetweenWorkspaces(aura::Window* new_workspace,
     52                                                  aura::Window* window,
     53                                                  ui::Layer* layer);
     54 
     55 // Returns the duration of the cross-fade animation based on the |old_bounds|
     56 // and |new_bounds| of the window.
     57 ASH_EXPORT base::TimeDelta GetCrossFadeDuration(const gfx::Rect& old_bounds,
     58                                                 const gfx::Rect& new_bounds);
     59 
     60 ASH_EXPORT bool AnimateOnChildWindowVisibilityChanged(aura::Window* window,
     61                                                       bool visible);
     62 
     63 // Creates vector of animation sequences that lasts for |duration| and changes
     64 // brightness and grayscale to |target_value|. Caller takes ownership of
     65 // returned LayerAnimationSequence objects.
     66 ASH_EXPORT std::vector<ui::LayerAnimationSequence*>
     67 CreateBrightnessGrayscaleAnimationSequence(float target_value,
     68                                            base::TimeDelta duration);
     69 
     70 // Applies scale related to the specified AshWindowScaleType.
     71 ASH_EXPORT void SetTransformForScaleAnimation(
     72     ui::Layer* layer,
     73     LayerScaleAnimationDirection type);
     74 
     75 // Returns the approximate bounds to which |window| will be animated when it
     76 // is minimized. The bounds are approximate because the minimize animation
     77 // involves rotation.
     78 ASH_EXPORT gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(
     79     aura::Window* window);
     80 
     81 }  // namespace ash
     82 
     83 #endif  // ASH_WM_WINDOW_ANIMATIONS_H_
     84