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

Side by Side Diff: trunk/src/ash/wm/workspace/phantom_window_controller.h

Issue 132183006: Revert 244050 "This is part 1 of implemeting phantom windows for..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
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"
12 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
13 14
14 namespace aura { 15 namespace aura {
15 class Window; 16 class Window;
16 } 17 }
17 18
19 namespace gfx {
20 class SlideAnimation;
21 }
22
18 namespace views { 23 namespace views {
19 class Widget; 24 class Widget;
20 } 25 }
21 26
22 namespace ash { 27 namespace ash {
23 namespace internal { 28 namespace internal {
24 29
25 // PhantomWindowController is responsible for showing a phantom representation 30 // PhantomWindowController is responsible for showing a phantom representation
26 // of a window. It's used to show a preview of how snapping or docking a window 31 // of a window. It's used used during dragging a window to show a snap location.
27 // will affect the window's bounds. 32 class ASH_EXPORT PhantomWindowController : public gfx::AnimationDelegate {
28 class ASH_EXPORT PhantomWindowController {
29 public: 33 public:
30 explicit PhantomWindowController(aura::Window* window); 34 explicit PhantomWindowController(aura::Window* window);
35 virtual ~PhantomWindowController();
31 36
32 // Hides the phantom window without any animation. 37 // Bounds last passed to Show().
33 virtual ~PhantomWindowController(); 38 const gfx::Rect& bounds_in_screen() const { return bounds_in_screen_; }
34 39
35 // Animates the phantom window towards |bounds_in_screen|. 40 // Animates the phantom window towards |bounds_in_screen|.
36 // Creates two (if start bounds intersect any root window other than the 41 // Creates two (if start bounds intersect any root window other than the
37 // root window that matches the target bounds) or one (otherwise) phantom 42 // root window that matches the target bounds) or one (otherwise) phantom
38 // widgets to display animated rectangle in each root. 43 // widgets to display animated rectangle in each root.
39 // This does not immediately show the window. 44 // This does not immediately show the window.
40 void Show(const gfx::Rect& bounds_in_screen); 45 void Show(const gfx::Rect& bounds_in_screen);
41 46
47 // Hides the phantom.
48 void Hide();
49
50 // Returns true if the phantom is showing.
51 bool IsShowing() const;
52
42 // If set, the phantom window is stacked below this window, otherwise it 53 // If set, the phantom window is stacked below this window, otherwise it
43 // is stacked above the window passed to the constructor. 54 // is stacked above the window passed to the constructor.
44 void set_phantom_below_window(aura::Window* phantom_below_window) { 55 void set_phantom_below_window(aura::Window* phantom_below_window) {
45 phantom_below_window_ = phantom_below_window; 56 phantom_below_window_ = phantom_below_window;
46 } 57 }
47 58
59 // gfx::AnimationDelegate overrides:
60 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
61
48 private: 62 private:
49 friend class PhantomWindowControllerTest; 63 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomWindowShow);
50 64
51 // Creates, shows and returns a phantom widget at |bounds| 65 // Creates, shows and returns a phantom widget at |bounds|
52 // with kShellWindowId_ShelfContainer in |root_window| as a parent. 66 // with kShellWindowId_ShelfContainer in |root_window| as a parent.
53 scoped_ptr<views::Widget> CreatePhantomWidget( 67 views::Widget* CreatePhantomWidget(aura::Window* root_window,
54 aura::Window* root_window, 68 const gfx::Rect& bounds_in_screen);
55 const gfx::Rect& bounds_in_screen);
56 69
57 // Window the phantom is placed beneath. 70 // Window the phantom is placed beneath.
58 aura::Window* window_; 71 aura::Window* window_;
59 72
60 // If set, the phantom window should get stacked below this window. 73 // If set, the phantom window should get stacked below this window.
61 aura::Window* phantom_below_window_; 74 aura::Window* phantom_below_window_;
62 75
76 // Initially the bounds of |window_| (in screen coordinates).
77 // Each time Show() is invoked |start_bounds_| is then reset to the bounds of
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
63 // Target bounds of the animation in screen coordinates. 82 // Target bounds of the animation in screen coordinates.
64 gfx::Rect target_bounds_in_screen_; 83 gfx::Rect bounds_in_screen_;
65 84
66 // Phantom representation of the window which is in the root window matching 85 // The primary phantom representation of the window. It is parented by the
67 // |target_bounds_in_screen_|. 86 // root window matching the target bounds.
68 scoped_ptr<views::Widget> phantom_widget_in_target_root_; 87 views::Widget* phantom_widget_;
69 88
70 // Phantom representation of the window which is in the root window matching 89 // If the animation starts on another display, this is the secondary phantom
71 // the window's initial bounds. This allows animations to progress from one 90 // representation of the window used on the initial display, otherwise this is
72 // display to the other. NULL if the phantom window starts and ends in the 91 // NULL. This allows animation to progress from one display into the other.
73 // same root window. 92 views::Widget* phantom_widget_start_;
74 scoped_ptr<views::Widget> phantom_widget_in_start_root_; 93
94 // Used to transition the bounds.
95 scoped_ptr<gfx::SlideAnimation> animation_;
75 96
76 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController); 97 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController);
77 }; 98 };
78 99
79 } // namespace internal 100 } // namespace internal
80 } // namespace ash 101 } // namespace ash
81 102
82 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ 103 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_
OLDNEW
« no previous file with comments | « trunk/src/ash/wm/gestures/system_pinch_handler.cc ('k') | trunk/src/ash/wm/workspace/phantom_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698