| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ | 5 #ifndef ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ |
| 6 #define ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ | 6 #define ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ui/base/animation/animation_delegate.h" | 12 #include "ui/gfx/animation/animation_delegate.h" |
| 13 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
| 14 | 14 |
| 15 namespace aura { | 15 namespace aura { |
| 16 class RootWindow; | 16 class RootWindow; |
| 17 class Window; | 17 class Window; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace ui { | 20 namespace gfx { |
| 21 class SlideAnimation; | 21 class SlideAnimation; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace views { | 24 namespace views { |
| 25 class Widget; | 25 class Widget; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace ash { | 28 namespace ash { |
| 29 namespace internal { | 29 namespace internal { |
| 30 | 30 |
| 31 // PhantomWindowController is responsible for showing a phantom representation | 31 // PhantomWindowController is responsible for showing a phantom representation |
| 32 // of a window. It's used used during dragging a window to show a snap location. | 32 // of a window. It's used used during dragging a window to show a snap location. |
| 33 class ASH_EXPORT PhantomWindowController : public ui::AnimationDelegate { | 33 class ASH_EXPORT PhantomWindowController : public gfx::AnimationDelegate { |
| 34 public: | 34 public: |
| 35 explicit PhantomWindowController(aura::Window* window); | 35 explicit PhantomWindowController(aura::Window* window); |
| 36 virtual ~PhantomWindowController(); | 36 virtual ~PhantomWindowController(); |
| 37 | 37 |
| 38 // Bounds last passed to Show(). | 38 // Bounds last passed to Show(). |
| 39 const gfx::Rect& bounds_in_screen() const { return bounds_in_screen_; } | 39 const gfx::Rect& bounds_in_screen() const { return bounds_in_screen_; } |
| 40 | 40 |
| 41 // Animates the phantom window towards |bounds_in_screen|. | 41 // Animates the phantom window towards |bounds_in_screen|. |
| 42 // Creates two (if start bounds intersect any root window other than the | 42 // Creates two (if start bounds intersect any root window other than the |
| 43 // root window that matches the target bounds) or one (otherwise) phantom | 43 // root window that matches the target bounds) or one (otherwise) phantom |
| 44 // widgets to display animated rectangle in each root. | 44 // widgets to display animated rectangle in each root. |
| 45 // This does not immediately show the window. | 45 // This does not immediately show the window. |
| 46 void Show(const gfx::Rect& bounds_in_screen); | 46 void Show(const gfx::Rect& bounds_in_screen); |
| 47 | 47 |
| 48 // Hides the phantom. | 48 // Hides the phantom. |
| 49 void Hide(); | 49 void Hide(); |
| 50 | 50 |
| 51 // Returns true if the phantom is showing. | 51 // Returns true if the phantom is showing. |
| 52 bool IsShowing() const; | 52 bool IsShowing() const; |
| 53 | 53 |
| 54 // If set, the phantom window is stacked below this window, otherwise it | 54 // If set, the phantom window is stacked below this window, otherwise it |
| 55 // is stacked above the window passed to the constructor. | 55 // is stacked above the window passed to the constructor. |
| 56 void set_phantom_below_window(aura::Window* phantom_below_window) { | 56 void set_phantom_below_window(aura::Window* phantom_below_window) { |
| 57 phantom_below_window_ = phantom_below_window; | 57 phantom_below_window_ = phantom_below_window; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // ui::AnimationDelegate overrides: | 60 // gfx::AnimationDelegate overrides: |
| 61 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 61 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomWindowShow); | 64 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomWindowShow); |
| 65 | 65 |
| 66 // Creates, shows and returns a phantom widget at |bounds| | 66 // Creates, shows and returns a phantom widget at |bounds| |
| 67 // with kShellWindowId_ShelfContainer in |root_window| as a parent. | 67 // with kShellWindowId_ShelfContainer in |root_window| as a parent. |
| 68 views::Widget* CreatePhantomWidget(aura::RootWindow* root_window, | 68 views::Widget* CreatePhantomWidget(aura::RootWindow* root_window, |
| 69 const gfx::Rect& bounds_in_screen); | 69 const gfx::Rect& bounds_in_screen); |
| 70 | 70 |
| 71 // Window the phantom is placed beneath. | 71 // Window the phantom is placed beneath. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 86 // The primary phantom representation of the window. It is parented by the | 86 // The primary phantom representation of the window. It is parented by the |
| 87 // root window matching the target bounds. | 87 // root window matching the target bounds. |
| 88 views::Widget* phantom_widget_; | 88 views::Widget* phantom_widget_; |
| 89 | 89 |
| 90 // If the animation starts on another display, this is the secondary phantom | 90 // If the animation starts on another display, this is the secondary phantom |
| 91 // representation of the window used on the initial display, otherwise this is | 91 // representation of the window used on the initial display, otherwise this is |
| 92 // NULL. This allows animation to progress from one display into the other. | 92 // NULL. This allows animation to progress from one display into the other. |
| 93 views::Widget* phantom_widget_start_; | 93 views::Widget* phantom_widget_start_; |
| 94 | 94 |
| 95 // Used to transition the bounds. | 95 // Used to transition the bounds. |
| 96 scoped_ptr<ui::SlideAnimation> animation_; | 96 scoped_ptr<gfx::SlideAnimation> animation_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController); | 98 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace internal | 101 } // namespace internal |
| 102 } // namespace ash | 102 } // namespace ash |
| 103 | 103 |
| 104 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ | 104 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ |
| OLD | NEW |