OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
| 6 #define ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "ui/gfx/rect.h" |
| 10 #include "ui/gfx/transform.h" |
| 11 |
| 12 namespace aura { |
| 13 class RootWindow; |
| 14 class Window; |
| 15 } |
| 16 |
| 17 namespace ui { |
| 18 class Layer; |
| 19 } |
| 20 |
| 21 namespace views { |
| 22 class Widget; |
| 23 } |
| 24 |
| 25 namespace ash { |
| 26 |
| 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 { |
| 32 public: |
| 33 // The duration of transitions used for window transforms. |
| 34 static const int kTransitionMilliseconds; |
| 35 |
| 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); |
| 41 |
| 42 explicit ScopedTransformOverviewWindow(aura::Window* window); |
| 43 virtual ~ScopedTransformOverviewWindow(); |
| 44 |
| 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; |
| 48 |
| 49 // Restores the window if it was minimized. |
| 50 void RestoreWindow(); |
| 51 |
| 52 // Restores this window on exit rather than returning it to a minimized state |
| 53 // if it was minimized on entering overview mode. |
| 54 void RestoreWindowOnExit(); |
| 55 |
| 56 // Informs the ScopedTransformOverviewWindow that the window being watched was |
| 57 // destroyed. This resets the internal window pointer to avoid calling |
| 58 // anything on the window at destruction time. |
| 59 void OnWindowDestroyed(); |
| 60 |
| 61 // Sets |transform| on the window and a copy of the window if the target |
| 62 // |root_window| is not the window's root window. |
| 63 void SetTransform(aura::RootWindow* root_window, |
| 64 const gfx::Transform& transform); |
| 65 |
| 66 aura::Window* window() const { return window_; } |
| 67 |
| 68 protected: |
| 69 // Dispatched when the overview of this window has started. |
| 70 virtual void OnOverviewStarted(); |
| 71 |
| 72 private: |
| 73 // A weak pointer to the real window in the overview. |
| 74 aura::Window* window_; |
| 75 |
| 76 // A copy of the window used to transition the window to another root. |
| 77 views::Widget* window_copy_; |
| 78 |
| 79 // A weak pointer to a deep copy of the window's layers. |
| 80 ui::Layer* layer_; |
| 81 |
| 82 // If true, the window was minimized and should be restored if the window |
| 83 // was not selected. |
| 84 bool minimized_; |
| 85 |
| 86 // True if the window has been transformed for overview mode. |
| 87 bool overview_started_; |
| 88 |
| 89 // The original transform of the window before entering overview mode. |
| 90 gfx::Transform original_transform_; |
| 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); |
| 93 }; |
| 94 |
| 95 } // namespace ash |
| 96 |
| 97 #endif // ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
OLD | NEW |