Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | 13 #include "base/compiler_specific.h" |
|
James Cook
2016/05/27 00:02:51
not needed
sky
2016/05/27 03:18:04
Done.
| |
| 11 #include "base/macros.h" | 14 #include "base/macros.h" |
| 12 #include "base/memory/scoped_vector.h" | |
| 13 #include "ui/gfx/geometry/rect.h" | |
| 14 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
| 15 #include "ui/views/widget/widget.h" | |
| 16 | 16 |
| 17 namespace aura { | 17 namespace gfx { |
| 18 class Window; | 18 class Rect; |
| 19 } | |
| 20 | |
| 21 namespace ui { | |
| 22 class Layer; | |
| 23 } | |
| 24 | |
| 25 namespace views { | |
| 26 class Widget; | |
| 27 } | 19 } |
| 28 | 20 |
| 29 namespace ash { | 21 namespace ash { |
| 30 | 22 |
| 31 class ScopedWindowCopy; | 23 class ScopedOverviewAnimationSettings; |
| 24 | |
| 25 namespace wm { | |
| 26 class WmWindow; | |
| 27 } | |
| 32 | 28 |
| 33 // Manages a window, and it's transient children, in the overview mode. This | 29 // 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 | 30 // 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 | 31 // fit in certain bounds. The window's state is restored on destruction of this |
| 36 // object. | 32 // object. |
| 37 class ASH_EXPORT ScopedTransformOverviewWindow { | 33 class ASH_EXPORT ScopedTransformOverviewWindow { |
| 38 public: | 34 public: |
| 39 typedef ScopedVector<ScopedOverviewAnimationSettings> ScopedAnimationSettings; | 35 using ScopedAnimationSettings = |
| 36 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>; | |
| 40 | 37 |
| 41 // Returns |rect| having been shrunk to fit within |bounds| (preserving the | 38 // 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| | 39 // 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 | 40 // tall in the original window getting replaced by a window caption that is |
| 44 // |title_height| tall in transformed window. | 41 // |title_height| tall in transformed window. |
| 45 static gfx::Rect ShrinkRectToFitPreservingAspectRatio(const gfx::Rect& rect, | 42 static gfx::Rect ShrinkRectToFitPreservingAspectRatio(const gfx::Rect& rect, |
| 46 const gfx::Rect& bounds, | 43 const gfx::Rect& bounds, |
| 47 int top_view_inset, | 44 int top_view_inset, |
| 48 int title_height); | 45 int title_height); |
| 49 | 46 |
| 50 // Returns the transform turning |src_rect| into |dst_rect|. | 47 // Returns the transform turning |src_rect| into |dst_rect|. |
| 51 static gfx::Transform GetTransformForRect(const gfx::Rect& src_rect, | 48 static gfx::Transform GetTransformForRect(const gfx::Rect& src_rect, |
| 52 const gfx::Rect& dst_rect); | 49 const gfx::Rect& dst_rect); |
| 53 | 50 |
| 54 explicit ScopedTransformOverviewWindow(aura::Window* window); | 51 explicit ScopedTransformOverviewWindow(wm::WmWindow* window); |
| 55 ~ScopedTransformOverviewWindow(); | 52 ~ScopedTransformOverviewWindow(); |
| 56 | 53 |
| 57 gfx::Transform get_overview_transform() const { return overview_transform_; } | 54 gfx::Transform get_overview_transform() const { return overview_transform_; } |
| 58 | 55 |
| 59 void set_overview_transform(const gfx::Transform& transform) { | 56 void set_overview_transform(const gfx::Transform& transform) { |
| 60 overview_transform_ = transform; | 57 overview_transform_ = transform; |
| 61 } | 58 } |
| 62 | 59 |
| 63 // Starts an animation sequence which will use animation settings specified by | 60 // Starts an animation sequence which will use animation settings specified by |
| 64 // |animation_type|. The |animation_settings| container is populated with | 61 // |animation_type|. The |animation_settings| container is populated with |
| 65 // scoped entities and the container should be destroyed at the end of the | 62 // scoped entities and the container should be destroyed at the end of the |
| 66 // animation sequence. | 63 // animation sequence. |
| 67 // | 64 // |
| 68 // Example: | 65 // Example: |
| 69 // ScopedTransformOverviewWindow overview_window(window); | 66 // ScopedTransformOverviewWindow overview_window(window); |
| 70 // ScopedTransformOverviewWindow::ScopedAnimationSettings scoped_settings; | 67 // ScopedTransformOverviewWindow::ScopedAnimationSettings scoped_settings; |
| 71 // overview_window.BeginScopedAnimation( | 68 // overview_window.BeginScopedAnimation( |
| 72 // OverviewAnimationType::OVERVIEW_ANIMATION_SELECTOR_ITEM_SCROLL_CANCEL, | 69 // OverviewAnimationType::OVERVIEW_ANIMATION_SELECTOR_ITEM_SCROLL_CANCEL, |
| 73 // &animation_settings); | 70 // &animation_settings); |
| 74 // // Calls to SetTransform & SetOpacity will use the same animation settings | 71 // // Calls to SetTransform & SetOpacity will use the same animation settings |
| 75 // // until scoped_settings is destroyed. | 72 // // until scoped_settings is destroyed. |
| 76 // overview_window.SetTransform(root_window, new_transform); | 73 // overview_window.SetTransform(root_window, new_transform); |
| 77 // overview_window.SetOpacity(1); | 74 // overview_window.SetOpacity(1); |
| 78 void BeginScopedAnimation( | 75 void BeginScopedAnimation( |
| 79 OverviewAnimationType animation_type, | 76 OverviewAnimationType animation_type, |
| 80 ScopedAnimationSettings* animation_settings); | 77 ScopedAnimationSettings* animation_settings); |
| 81 | 78 |
| 82 // Returns true if this window selector window contains the |target|. | 79 // Returns true if this window selector window contains the |target|. |
| 83 bool Contains(const aura::Window* target) const; | 80 bool Contains(const wm::WmWindow* target) const; |
| 84 | 81 |
| 85 // Returns the original target bounds of all transformed windows. | 82 // Returns the original target bounds of all transformed windows. |
| 86 gfx::Rect GetTargetBoundsInScreen() const; | 83 gfx::Rect GetTargetBoundsInScreen() const; |
| 87 | 84 |
| 88 // Restores and animates the managed window to it's non overview mode state. | 85 // Restores and animates the managed window to it's non overview mode state. |
| 89 void RestoreWindow(); | 86 void RestoreWindow(); |
| 90 | 87 |
| 91 // Forces the managed window to be shown (ie not hidden or minimized) when | 88 // Forces the managed window to be shown (ie not hidden or minimized) when |
| 92 // calling RestoreWindow(). | 89 // calling RestoreWindow(). |
| 93 void ShowWindowOnExit(); | 90 void ShowWindowOnExit(); |
| 94 | 91 |
| 95 // Informs the ScopedTransformOverviewWindow that the window being watched was | 92 // Informs the ScopedTransformOverviewWindow that the window being watched was |
| 96 // destroyed. This resets the internal window pointer. | 93 // destroyed. This resets the internal window pointer. |
| 97 void OnWindowDestroyed(); | 94 void OnWindowDestroyed(); |
| 98 | 95 |
| 99 // Prepares for overview mode by doing any necessary actions before entering. | 96 // Prepares for overview mode by doing any necessary actions before entering. |
| 100 void PrepareForOverview(); | 97 void PrepareForOverview(); |
| 101 | 98 |
| 102 // Applies the |transform| to the overview window and all of its transient | 99 // Applies the |transform| to the overview window and all of its transient |
| 103 // children. | 100 // children. |
| 104 void SetTransform(aura::Window* root_window, | 101 void SetTransform(wm::WmWindow* root_window, const gfx::Transform& transform); |
| 105 const gfx::Transform& transform); | |
| 106 | 102 |
| 107 // Set's the opacity of the managed windows. | 103 // Set's the opacity of the managed windows. |
| 108 void SetOpacity(float opacity); | 104 void SetOpacity(float opacity); |
| 109 | 105 |
| 110 aura::Window* window() const { return window_; } | 106 wm::WmWindow* window() const { return window_; } |
| 111 | 107 |
| 112 // Closes the transient root of the window managed by |this|. | 108 // Closes the transient root of the window managed by |this|. |
| 113 void Close(); | 109 void Close(); |
| 114 | 110 |
| 115 private: | 111 private: |
| 116 // Shows the window if it was minimized. | 112 // Shows the window if it was minimized. |
| 117 void ShowWindowIfMinimized(); | 113 void ShowWindowIfMinimized(); |
| 118 | 114 |
| 119 // A weak pointer to the real window in the overview. | 115 // A weak pointer to the real window in the overview. |
| 120 aura::Window* window_; | 116 wm::WmWindow* window_; |
| 121 | 117 |
| 122 // If true, the window was minimized and should be restored if the window | 118 // If true, the window was minimized and should be restored if the window |
| 123 // was not selected. | 119 // was not selected. |
| 124 bool minimized_; | 120 bool minimized_; |
| 125 | 121 |
| 126 // Tracks if this window was ignored by the shelf. | 122 // Tracks if this window was ignored by the shelf. |
| 127 bool ignored_by_shelf_; | 123 bool ignored_by_shelf_; |
| 128 | 124 |
| 129 // True if the window has been transformed for overview mode. | 125 // True if the window has been transformed for overview mode. |
| 130 bool overview_started_; | 126 bool overview_started_; |
| 131 | 127 |
| 132 // The original transform of the window before entering overview mode. | 128 // The original transform of the window before entering overview mode. |
| 133 gfx::Transform original_transform_; | 129 gfx::Transform original_transform_; |
| 134 | 130 |
| 135 // Keeps track of the original transform used when |this| has been positioned | 131 // Keeps track of the original transform used when |this| has been positioned |
| 136 // during SelectorItem layout. | 132 // during SelectorItem layout. |
| 137 gfx::Transform overview_transform_; | 133 gfx::Transform overview_transform_; |
| 138 | 134 |
| 139 // The original opacity of the window before entering overview mode. | 135 // The original opacity of the window before entering overview mode. |
| 140 float original_opacity_; | 136 float original_opacity_; |
| 141 | 137 |
| 142 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); | 138 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); |
| 143 }; | 139 }; |
| 144 | 140 |
| 145 } // namespace ash | 141 } // namespace ash |
| 146 | 142 |
| 147 #endif // ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ | 143 #endif // ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
| OLD | NEW |