Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / wm / overview / scoped_transform_overview_window.h
blob9c31dbfbc2964d6cc3e3ba499650e0fd9afcbd2f
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 "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/gfx/transform.h"
13 #include "ui/views/widget/widget.h"
15 namespace aura {
16 class Window;
19 namespace ui {
20 class Layer;
23 namespace views {
24 class Widget;
27 namespace ash {
29 class ScopedWindowCopy;
31 // Manages a window in the overview mode. This class allows transforming the
32 // window with a helper to determine the best fit in certain bounds and
33 // copies the window if being moved to another display. The window's state is
34 // restored on destruction of this object.
35 class ScopedTransformOverviewWindow {
36 public:
37 // The duration of transitions used for window transforms.
38 static const int kTransitionMilliseconds;
40 // Returns |rect| having been shrunk to fit within |bounds| (preserving the
41 // aspect ratio).
42 static gfx::Rect ShrinkRectToFitPreservingAspectRatio(
43 const gfx::Rect& rect,
44 const gfx::Rect& bounds);
46 // Returns the transform turning |src_rect| into |dst_rect|.
47 static gfx::Transform GetTransformForRect(const gfx::Rect& src_rect,
48 const gfx::Rect& dst_rect);
50 explicit ScopedTransformOverviewWindow(aura::Window* window);
51 virtual ~ScopedTransformOverviewWindow();
53 // Returns true if this window selector window contains the |target|. This is
54 // used to determine if an event targeted this window.
55 bool Contains(const aura::Window* target) const;
57 // Returns the original bounds of all transformed windows.
58 gfx::Rect GetBoundsInScreen() const;
60 // Restores the window if it was minimized.
61 void RestoreWindow();
63 // Restores this window on exit rather than returning it to a minimized state
64 // if it was minimized on entering overview mode.
65 void RestoreWindowOnExit();
67 // Informs the ScopedTransformOverviewWindow that the window being watched was
68 // destroyed. This resets the internal window pointer to avoid calling
69 // anything on the window at destruction time.
70 void OnWindowDestroyed();
72 // Prepares for overview mode by doing any necessary actions before entering.
73 virtual void PrepareForOverview();
75 // Sets |transform| on the window and a copy of the window if the target
76 // |root_window| is not the window's root window. If |animate| the transform
77 // is animated in, otherwise it is immediately applied.
78 virtual void SetTransform(aura::Window* root_window,
79 const gfx::Transform& transform,
80 bool animate);
82 aura::Window* window() const { return window_; }
84 private:
85 // Creates copies of |window| and all of its modal transient parents on the
86 // root window |target_root|.
87 void CopyWindowAndTransientParents(aura::Window* target_root,
88 aura::Window* window);
90 // Applies the |transform| to the overview window and all of its transient
91 // children using animations. If |animate| the transform is animated in,
92 // otherwise it is applied immediately.
93 void SetTransformOnWindowAndTransientChildren(const gfx::Transform& transform,
94 bool animate);
96 // A weak pointer to the real window in the overview.
97 aura::Window* window_;
99 // Copies of the window and transient parents for a different root window.
100 ScopedVector<ScopedWindowCopy> window_copies_;
102 // If true, the window was minimized and should be restored if the window
103 // was not selected.
104 bool minimized_;
106 // Tracks if this window was ignored by the shelf.
107 bool ignored_by_shelf_;
109 // True if the window has been transformed for overview mode.
110 bool overview_started_;
112 // The original transform of the window before entering overview mode.
113 gfx::Transform original_transform_;
115 // The original opacity of the window before entering overview mode.
116 float opacity_;
118 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow);
121 } // namespace ash
123 #endif // ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_