- add sources.
[platform/framework/web/crosswalk.git] / src / ash / wm / workspace / desktop_background_fade_controller.h
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_WORKSPACE_DESKTOP_BACKGROUND_FADE_CONTROLLER_H_
6 #define ASH_WM_WORKSPACE_DESKTOP_BACKGROUND_FADE_CONTROLLER_H_
7
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/compositor/layer_animation_observer.h"
12
13 namespace aura {
14 class Window;
15 }
16
17 namespace base {
18 class TimeDelta;
19 }
20
21 namespace ash {
22 namespace internal {
23
24 class ColoredWindowController;
25
26 // DesktopBackgroundFadeController handles fading in or out the desktop. It is
27 // used when maximizing or restoring a window. It is implemented as a colored
28 // layer whose opacity varies. This results in fading in or out all the windows
29 // the DesktopBackgroundFadeController is placed on top of. This is used
30 // instead of varying the opacity for two reasons:
31 // . The window showing background and the desktop workspace do not have a
32 //   common parent that can be animated. This could be fixed, but wouldn't
33 //   address the following.
34 // . When restoring the window is moved back to the desktop workspace. If we
35 //   animated the opacity of the desktop workspace the cross fade would be
36 //   effected.
37 class ASH_EXPORT DesktopBackgroundFadeController
38     : public ui::ImplicitAnimationObserver {
39  public:
40   // Direction to fade.
41   enum Direction {
42     FADE_IN,
43     FADE_OUT,
44   };
45
46   // Creates a new DesktopBackgroundFadeController. |parent| is the Window to
47 //   parent the newly created window to. The newly created window is stacked
48 //   directly on top of |position_above|. The window animating the fade is
49 //   destroyed as soon as the animation completes.
50   DesktopBackgroundFadeController(aura::Window* parent,
51                                   aura::Window* position_above,
52                                   base::TimeDelta duration,
53                                   Direction direction);
54   virtual ~DesktopBackgroundFadeController();
55
56  private:
57   // ImplicitAnimationObserver overrides:
58   virtual void OnImplicitAnimationsCompleted() OVERRIDE;
59
60   scoped_ptr<ColoredWindowController> window_controller_;
61
62   DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundFadeController);
63 };
64
65 }  // namespace internal
66 }  // namespace ash
67
68 #endif  // ASH_WM_WORKSPACE_DESKTOP_BACKGROUND_FADE_CONTROLLER_H_