1 // Copyright 2013 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.
5 #ifndef ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_
6 #define ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_
8 #include "base/compiler_specific.h"
9 #include "ui/gfx/rect.h"
10 #include "ui/gfx/transform.h"
27 // Manages a window in the overview mode. This class allows transforming the
28 // window with a helper to determine the best fit in certain bounds and
29 // copies the window if being moved to another display. The window's state is
30 // restored on destruction of this object.
31 class ScopedTransformOverviewWindow
{
33 // The duration of transitions used for window transforms.
34 static const int kTransitionMilliseconds
;
36 // Returns the transform necessary to fit |rect| into |bounds| preserving
37 // aspect ratio and centering.
38 static gfx::Transform
GetTransformForRectPreservingAspectRatio(
39 const gfx::Rect
& rect
,
40 const gfx::Rect
& bounds
);
42 explicit ScopedTransformOverviewWindow(aura::Window
* window
);
43 virtual ~ScopedTransformOverviewWindow();
45 // Returns true if this window selector window contains the |target|. This is
46 // used to determine if an event targetted this window.
47 bool Contains(const aura::Window
* target
) const;
49 // Returns the original bounds of all transformed windows.
50 gfx::Rect
GetBoundsInScreen() const;
52 // Restores the window if it was minimized.
55 // Restores this window on exit rather than returning it to a minimized state
56 // if it was minimized on entering overview mode.
57 void RestoreWindowOnExit();
59 // Informs the ScopedTransformOverviewWindow that the window being watched was
60 // destroyed. This resets the internal window pointer to avoid calling
61 // anything on the window at destruction time.
62 void OnWindowDestroyed();
64 // Prepares for overview mode by doing any necessary actions before entering.
65 virtual void PrepareForOverview();
67 // Sets |transform| on the window and a copy of the window if the target
68 // |root_window| is not the window's root window. If |animate| the transform
69 // is animated in, otherwise it is immediately applied.
70 void SetTransform(aura::RootWindow
* root_window
,
71 const gfx::Transform
& transform
,
74 aura::Window
* window() const { return window_
; }
77 // Applies the |transform| to the overview window and all of its transient
78 // children using animations. If |animate| the transform is animated in,
79 // otherwise it is applied immediately.
80 void SetTransformOnWindowAndTransientChildren(const gfx::Transform
& transform
,
83 // A weak pointer to the real window in the overview.
84 aura::Window
* window_
;
86 // A copy of the window used to transition the window to another root.
87 views::Widget
* window_copy_
;
89 // A weak pointer to a deep copy of the window's layers.
92 // If true, the window was minimized and should be restored if the window
96 // Tracks if this window was ignored by the shelf.
97 bool ignored_by_shelf_
;
99 // True if the window has been transformed for overview mode.
100 bool overview_started_
;
102 // The original transform of the window before entering overview mode.
103 gfx::Transform original_transform_
;
105 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow
);
110 #endif // ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_