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/gfx/animation/animation_delegate.h" | |
13 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
14 | 13 |
15 namespace aura { | 14 namespace aura { |
16 class Window; | 15 class Window; |
17 } | 16 } |
18 | 17 |
19 namespace gfx { | |
20 class SlideAnimation; | |
21 } | |
22 | |
23 namespace views { | 18 namespace views { |
24 class Widget; | 19 class Widget; |
25 } | 20 } |
26 | 21 |
27 namespace ash { | 22 namespace ash { |
28 namespace internal { | 23 namespace internal { |
29 | 24 |
30 // PhantomWindowController is responsible for showing a phantom representation | 25 // PhantomWindowController is responsible for showing a phantom representation |
31 // of a window. It's used used during dragging a window to show a snap location. | 26 // of a window. It's used to show a preview of how snapping or docking a window |
32 class ASH_EXPORT PhantomWindowController : public gfx::AnimationDelegate { | 27 // will affect the window's bounds. |
28 class ASH_EXPORT PhantomWindowController { | |
33 public: | 29 public: |
34 explicit PhantomWindowController(aura::Window* window); | 30 explicit PhantomWindowController(aura::Window* window); |
31 | |
32 // Hides the phantom window without any animation. | |
35 virtual ~PhantomWindowController(); | 33 virtual ~PhantomWindowController(); |
36 | 34 |
37 // Bounds last passed to Show(). | |
38 const gfx::Rect& bounds_in_screen() const { return bounds_in_screen_; } | |
39 | |
40 // Animates the phantom window towards |bounds_in_screen|. | 35 // Animates the phantom window towards |bounds_in_screen|. |
41 // Creates two (if start bounds intersect any root window other than the | 36 // Creates two (if start bounds intersect any root window other than the |
42 // root window that matches the target bounds) or one (otherwise) phantom | 37 // root window that matches the target bounds) or one (otherwise) phantom |
43 // widgets to display animated rectangle in each root. | 38 // widgets to display animated rectangle in each root. |
44 // This does not immediately show the window. | 39 // This does not immediately show the window. |
45 void Show(const gfx::Rect& bounds_in_screen); | 40 void Show(const gfx::Rect& bounds_in_screen); |
46 | 41 |
47 // Hides the phantom. | 42 // Starts fading out the phantom window. |
43 void StartFadeOut(); | |
sky
2013/12/19 21:25:43
Instead make Hide() take an argument indicating if
| |
44 | |
45 // Hides the phantom window without any animation. | |
48 void Hide(); | 46 void Hide(); |
49 | 47 |
50 // Returns true if the phantom is showing. | 48 // Returns true if the phantom is showing. |
51 bool IsShowing() const; | 49 bool IsShowing() const; |
52 | 50 |
53 // If set, the phantom window is stacked below this window, otherwise it | 51 // If set, the phantom window is stacked below this window, otherwise it |
54 // is stacked above the window passed to the constructor. | 52 // is stacked above the window passed to the constructor. |
55 void set_phantom_below_window(aura::Window* phantom_below_window) { | 53 void set_phantom_below_window(aura::Window* phantom_below_window) { |
56 phantom_below_window_ = phantom_below_window; | 54 phantom_below_window_ = phantom_below_window; |
57 } | 55 } |
58 | 56 |
59 // gfx::AnimationDelegate overrides: | |
60 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | |
61 | |
62 private: | 57 private: |
63 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomWindowShow); | 58 friend class PhantomWindowControllerTest; |
64 | 59 |
65 // Creates, shows and returns a phantom widget at |bounds| | 60 // Creates, shows and returns a phantom widget at |bounds| |
66 // with kShellWindowId_ShelfContainer in |root_window| as a parent. | 61 // with kShellWindowId_ShelfContainer in |root_window| as a parent. The caller |
67 views::Widget* CreatePhantomWidget(aura::Window* root_window, | 62 // takes ownership of the returned widget. |
68 const gfx::Rect& bounds_in_screen); | 63 views::Widget* CreatePhantomWidget( |
sky
2013/12/19 21:25:43
return scoped_ptr?
| |
64 aura::Window* root_window, | |
65 const gfx::Rect& bounds_in_screen) WARN_UNUSED_RESULT; | |
66 | |
67 // Starts fading the phantom window in or out. | |
68 void StartFade(bool fade_in); | |
69 | 69 |
70 // Window the phantom is placed beneath. | 70 // Window the phantom is placed beneath. |
71 aura::Window* window_; | 71 aura::Window* window_; |
72 | 72 |
73 // If set, the phantom window should get stacked below this window. | 73 // If set, the phantom window should get stacked below this window. |
74 aura::Window* phantom_below_window_; | 74 aura::Window* phantom_below_window_; |
75 | 75 |
76 // Initially the bounds of |window_| (in screen coordinates). | 76 // Target visibility of the animation. |
77 // Each time Show() is invoked |start_bounds_| is then reset to the bounds of | 77 bool target_visibility_; |
78 // |phantom_widget_| and |bounds_| is set to the value passed into Show(). | |
79 // The animation animates between these two values. | |
80 gfx::Rect start_bounds_; | |
81 | 78 |
82 // Target bounds of the animation in screen coordinates. | 79 // Target bounds (including the shadows if any) of the animation in screen |
83 gfx::Rect bounds_in_screen_; | 80 // coordinates. |
81 gfx::Rect target_bounds_in_screen_; | |
84 | 82 |
85 // The primary phantom representation of the window. It is parented by the | 83 // Phantom representation of the window which is in the root window matching |
86 // root window matching the target bounds. | 84 // |target_bounds_in_screen_|. |
87 views::Widget* phantom_widget_; | 85 scoped_ptr<views::Widget> target_phantom_widget_; |
88 | 86 |
89 // If the animation starts on another display, this is the secondary phantom | 87 // Phantom representation of the window which is in the root window matching |
90 // representation of the window used on the initial display, otherwise this is | 88 // the window's initial bounds. This allows animations to progress from one |
91 // NULL. This allows animation to progress from one display into the other. | 89 // display to the other. NULL if the phantom window starts and ends in the |
92 views::Widget* phantom_widget_start_; | 90 // same root window. |
93 | 91 scoped_ptr<views::Widget> start_phantom_widget_; |
sky
2013/12/19 21:25:43
start|target aren't particular descriptive by them
| |
94 // Used to transition the bounds. | |
95 scoped_ptr<gfx::SlideAnimation> animation_; | |
96 | 92 |
97 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController); | 93 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController); |
98 }; | 94 }; |
99 | 95 |
100 } // namespace internal | 96 } // namespace internal |
101 } // namespace ash | 97 } // namespace ash |
102 | 98 |
103 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ | 99 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ |
OLD | NEW |