Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: ash/wm/overview/scoped_transform_overview_window.h

Issue 2012343002: Converts overview to use common ash types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ 5 #ifndef ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_
6 #define ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ 6 #define ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_
7 7
8 #include <memory>
9 #include <vector>
10
8 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
9 #include "ash/wm/overview/scoped_overview_animation_settings.h" 12 #include "ash/wm/overview/overview_animation_type.h"
10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/transform.h" 14 #include "ui/gfx/transform.h"
15 #include "ui/views/widget/widget.h"
16 15
17 namespace aura { 16 namespace gfx {
18 class Window; 17 class Rect;
19 }
20
21 namespace ui {
22 class Layer;
23 }
24
25 namespace views {
26 class Widget;
27 } 18 }
28 19
29 namespace ash { 20 namespace ash {
30 21
31 class ScopedWindowCopy; 22 class ScopedOverviewAnimationSettings;
23
24 namespace wm {
25 class WmWindow;
26 }
32 27
33 // Manages a window, and it's transient children, in the overview mode. This 28 // Manages a window, and it's transient children, in the overview mode. This
34 // class allows transforming the windows with a helper to determine the best 29 // class allows transforming the windows with a helper to determine the best
35 // fit in certain bounds. The window's state is restored on destruction of this 30 // fit in certain bounds. The window's state is restored on destruction of this
36 // object. 31 // object.
37 class ASH_EXPORT ScopedTransformOverviewWindow { 32 class ASH_EXPORT ScopedTransformOverviewWindow {
38 public: 33 public:
39 typedef ScopedVector<ScopedOverviewAnimationSettings> ScopedAnimationSettings; 34 using ScopedAnimationSettings =
35 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>;
40 36
41 // Returns |rect| having been shrunk to fit within |bounds| (preserving the 37 // Returns |rect| having been shrunk to fit within |bounds| (preserving the
42 // aspect ratio). Takes into account a window header that is |top_view_inset| 38 // aspect ratio). Takes into account a window header that is |top_view_inset|
43 // tall in the original window getting replaced by a window caption that is 39 // tall in the original window getting replaced by a window caption that is
44 // |title_height| tall in transformed window. 40 // |title_height| tall in transformed window.
45 static gfx::Rect ShrinkRectToFitPreservingAspectRatio(const gfx::Rect& rect, 41 static gfx::Rect ShrinkRectToFitPreservingAspectRatio(const gfx::Rect& rect,
46 const gfx::Rect& bounds, 42 const gfx::Rect& bounds,
47 int top_view_inset, 43 int top_view_inset,
48 int title_height); 44 int title_height);
49 45
50 // Returns the transform turning |src_rect| into |dst_rect|. 46 // Returns the transform turning |src_rect| into |dst_rect|.
51 static gfx::Transform GetTransformForRect(const gfx::Rect& src_rect, 47 static gfx::Transform GetTransformForRect(const gfx::Rect& src_rect,
52 const gfx::Rect& dst_rect); 48 const gfx::Rect& dst_rect);
53 49
54 explicit ScopedTransformOverviewWindow(aura::Window* window); 50 explicit ScopedTransformOverviewWindow(wm::WmWindow* window);
55 ~ScopedTransformOverviewWindow(); 51 ~ScopedTransformOverviewWindow();
56 52
57 gfx::Transform get_overview_transform() const { return overview_transform_; } 53 gfx::Transform get_overview_transform() const { return overview_transform_; }
58 54
59 void set_overview_transform(const gfx::Transform& transform) { 55 void set_overview_transform(const gfx::Transform& transform) {
60 overview_transform_ = transform; 56 overview_transform_ = transform;
61 } 57 }
62 58
63 // Starts an animation sequence which will use animation settings specified by 59 // Starts an animation sequence which will use animation settings specified by
64 // |animation_type|. The |animation_settings| container is populated with 60 // |animation_type|. The |animation_settings| container is populated with
65 // scoped entities and the container should be destroyed at the end of the 61 // scoped entities and the container should be destroyed at the end of the
66 // animation sequence. 62 // animation sequence.
67 // 63 //
68 // Example: 64 // Example:
69 // ScopedTransformOverviewWindow overview_window(window); 65 // ScopedTransformOverviewWindow overview_window(window);
70 // ScopedTransformOverviewWindow::ScopedAnimationSettings scoped_settings; 66 // ScopedTransformOverviewWindow::ScopedAnimationSettings scoped_settings;
71 // overview_window.BeginScopedAnimation( 67 // overview_window.BeginScopedAnimation(
72 // OverviewAnimationType::OVERVIEW_ANIMATION_SELECTOR_ITEM_SCROLL_CANCEL, 68 // OverviewAnimationType::OVERVIEW_ANIMATION_SELECTOR_ITEM_SCROLL_CANCEL,
73 // &animation_settings); 69 // &animation_settings);
74 // // Calls to SetTransform & SetOpacity will use the same animation settings 70 // // Calls to SetTransform & SetOpacity will use the same animation settings
75 // // until scoped_settings is destroyed. 71 // // until scoped_settings is destroyed.
76 // overview_window.SetTransform(root_window, new_transform); 72 // overview_window.SetTransform(root_window, new_transform);
77 // overview_window.SetOpacity(1); 73 // overview_window.SetOpacity(1);
78 void BeginScopedAnimation( 74 void BeginScopedAnimation(
79 OverviewAnimationType animation_type, 75 OverviewAnimationType animation_type,
80 ScopedAnimationSettings* animation_settings); 76 ScopedAnimationSettings* animation_settings);
81 77
82 // Returns true if this window selector window contains the |target|. 78 // Returns true if this window selector window contains the |target|.
83 bool Contains(const aura::Window* target) const; 79 bool Contains(const wm::WmWindow* target) const;
84 80
85 // Returns the original target bounds of all transformed windows. 81 // Returns the original target bounds of all transformed windows.
86 gfx::Rect GetTargetBoundsInScreen() const; 82 gfx::Rect GetTargetBoundsInScreen() const;
87 83
88 // Restores and animates the managed window to it's non overview mode state. 84 // Restores and animates the managed window to it's non overview mode state.
89 void RestoreWindow(); 85 void RestoreWindow();
90 86
91 // Forces the managed window to be shown (ie not hidden or minimized) when 87 // Forces the managed window to be shown (ie not hidden or minimized) when
92 // calling RestoreWindow(). 88 // calling RestoreWindow().
93 void ShowWindowOnExit(); 89 void ShowWindowOnExit();
94 90
95 // Informs the ScopedTransformOverviewWindow that the window being watched was 91 // Informs the ScopedTransformOverviewWindow that the window being watched was
96 // destroyed. This resets the internal window pointer. 92 // destroyed. This resets the internal window pointer.
97 void OnWindowDestroyed(); 93 void OnWindowDestroyed();
98 94
99 // Prepares for overview mode by doing any necessary actions before entering. 95 // Prepares for overview mode by doing any necessary actions before entering.
100 void PrepareForOverview(); 96 void PrepareForOverview();
101 97
102 // Applies the |transform| to the overview window and all of its transient 98 // Applies the |transform| to the overview window and all of its transient
103 // children. 99 // children.
104 void SetTransform(aura::Window* root_window, 100 void SetTransform(wm::WmWindow* root_window, const gfx::Transform& transform);
105 const gfx::Transform& transform);
106 101
107 // Set's the opacity of the managed windows. 102 // Set's the opacity of the managed windows.
108 void SetOpacity(float opacity); 103 void SetOpacity(float opacity);
109 104
110 aura::Window* window() const { return window_; } 105 wm::WmWindow* window() const { return window_; }
111 106
112 // Closes the transient root of the window managed by |this|. 107 // Closes the transient root of the window managed by |this|.
113 void Close(); 108 void Close();
114 109
115 private: 110 private:
116 // Shows the window if it was minimized. 111 // Shows the window if it was minimized.
117 void ShowWindowIfMinimized(); 112 void ShowWindowIfMinimized();
118 113
119 // A weak pointer to the real window in the overview. 114 // A weak pointer to the real window in the overview.
120 aura::Window* window_; 115 wm::WmWindow* window_;
121 116
122 // If true, the window was minimized and should be restored if the window 117 // If true, the window was minimized and should be restored if the window
123 // was not selected. 118 // was not selected.
124 bool minimized_; 119 bool minimized_;
125 120
126 // Tracks if this window was ignored by the shelf. 121 // Tracks if this window was ignored by the shelf.
127 bool ignored_by_shelf_; 122 bool ignored_by_shelf_;
128 123
129 // True if the window has been transformed for overview mode. 124 // True if the window has been transformed for overview mode.
130 bool overview_started_; 125 bool overview_started_;
131 126
132 // The original transform of the window before entering overview mode. 127 // The original transform of the window before entering overview mode.
133 gfx::Transform original_transform_; 128 gfx::Transform original_transform_;
134 129
135 // Keeps track of the original transform used when |this| has been positioned 130 // Keeps track of the original transform used when |this| has been positioned
136 // during SelectorItem layout. 131 // during SelectorItem layout.
137 gfx::Transform overview_transform_; 132 gfx::Transform overview_transform_;
138 133
139 // The original opacity of the window before entering overview mode. 134 // The original opacity of the window before entering overview mode.
140 float original_opacity_; 135 float original_opacity_;
141 136
142 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); 137 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow);
143 }; 138 };
144 139
145 } // namespace ash 140 } // namespace ash
146 141
147 #endif // ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ 142 #endif // ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698