15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef ASH_WM_WINDOW_ANIMATIONS_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define ASH_WM_WINDOW_ANIMATIONS_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/ash_export.h"
9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/gfx/animation/tween.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/transform.h"
12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/wm/core/window_animations.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace aura {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Window;
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui {
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Layer;
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class LayerTreeOwner;
20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace views {
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// This is only for animations specific to Ash. For window animations shared
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// with desktop Chrome, see ui/views/corewm/window_animations.h.
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ash {
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// An extension of the window animations provided by CoreWm. These should be
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Ash-specific only.
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)enum WindowVisibilityAnimationType {
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Window scale/rotates down to its launcher icon.
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE =
33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      ::wm::WINDOW_VISIBILITY_ANIMATION_MAX,
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Fade in/out using brightness and grayscale web filters.
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Direction for ash-specific window animations used in workspaces and
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// lock/unlock animations.
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)enum LayerScaleAnimationDirection {
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  LAYER_SCALE_ANIMATION_ABOVE,
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  LAYER_SCALE_ANIMATION_BELOW,
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
452385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch// Amount of time for the cross fade animation.
462385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdochextern const int kCrossFadeDurationMS;
472385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch
48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Implementation of cross fading. Window is the window being cross faded. It
49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// should be at the target bounds. |old_layer_owner| contains the previous layer
50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// from |window|.  |tween_type| specifies the tween type of the cross fade
51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// animation.
52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)ASH_EXPORT base::TimeDelta CrossFadeAnimation(
53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    aura::Window* window,
54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    scoped_ptr<ui::LayerTreeOwner> old_layer_owner,
55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    gfx::Tween::Type tween_type);
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ASH_EXPORT bool AnimateOnChildWindowVisibilityChanged(aura::Window* window,
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                      bool visible);
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Creates vector of animation sequences that lasts for |duration| and changes
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// brightness and grayscale to |target_value|. Caller takes ownership of
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// returned LayerAnimationSequence objects.
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)ASH_EXPORT std::vector<ui::LayerAnimationSequence*>
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)CreateBrightnessGrayscaleAnimationSequence(float target_value,
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                           base::TimeDelta duration);
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Applies scale related to the specified AshWindowScaleType.
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)ASH_EXPORT void SetTransformForScaleAnimation(
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ui::Layer* layer,
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    LayerScaleAnimationDirection type);
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
72ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// Returns the approximate bounds to which |window| will be animated when it
73ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// is minimized. The bounds are approximate because the minimize animation
74ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// involves rotation.
75ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben MurdochASH_EXPORT gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(
76ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    aura::Window* window);
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
78ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch}  // namespace ash
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // ASH_WM_WINDOW_ANIMATIONS_H_
81