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

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

Issue 10823199: While dragging a window, show a semi-transparent aura window instead of the standard gray phantom wi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-upload Created 8 years, 4 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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "ui/base/animation/animation_delegate.h" 11 #include "ui/base/animation/animation_delegate.h"
12 #include "ui/gfx/display.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;
17 class RootWindow;
16 } 18 }
17 19
18 namespace ui { 20 namespace ui {
19 class SlideAnimation; 21 class SlideAnimation;
20 } 22 }
21 23
22 namespace views { 24 namespace views {
23 class Widget; 25 class Widget;
24 } 26 }
25 27
26 namespace ash { 28 namespace ash {
27 namespace internal { 29 namespace internal {
28 30
29 // PhantomWindowController is responsible for showing a phantom representation 31 // PhantomWindowController is responsible for showing a phantom representation
30 // 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.
31 class ASH_EXPORT PhantomWindowController : public ui::AnimationDelegate { 33 class ASH_EXPORT PhantomWindowController : public ui::AnimationDelegate {
32 public: 34 public:
35 enum Style {
36 STYLE_SHADOW, // for window snapping.
37 STYLE_WINDOW, // for window dragging.
38 };
39
33 explicit PhantomWindowController(aura::Window* window); 40 explicit PhantomWindowController(aura::Window* window);
34 virtual ~PhantomWindowController(); 41 virtual ~PhantomWindowController();
35 42
43 // Sets the display where the phantom is placed.
44 void SetDestinationDisplay(const gfx::Display& dst_display);
45
36 // Bounds last passed to Show(). 46 // Bounds last passed to Show().
37 const gfx::Rect& bounds() const { return bounds_; } 47 const gfx::Rect& bounds() const { return bounds_; }
38 48
39 // Shows the phantom window at the specified location (coordinates of the 49 // Shows the phantom window at the specified location (coordinates of the
40 // parent). This does not immediately show the window. 50 // parent). This does not immediately show the window.
41 void Show(const gfx::Rect& bounds); 51 void Show(const gfx::Rect& bounds);
42 52
43 // This is used to set bounds for the phantom window immediately. This should 53 // This is used to set bounds for the phantom window immediately. This should
44 // be called only when the phantom window is already visible. 54 // be called only when the phantom window is already visible.
45 void SetBounds(const gfx::Rect& bounds); 55 void SetBounds(const gfx::Rect& bounds);
46 56
47 // Hides the phantom. 57 // Hides the phantom.
48 void Hide(); 58 void Hide();
49 59
50 // Returns true if the phantom is showing. 60 // Returns true if the phantom is showing.
51 bool IsShowing() const; 61 bool IsShowing() const;
52 62
53 // If set, the phantom window is stacked below this window, otherwise it 63 // If set, the phantom window is stacked below this window, otherwise it
54 // is stacked above the window passed to the constructor. 64 // is stacked above the window passed to the constructor.
55 void set_phantom_below_window(aura::Window* phantom_below_window) { 65 void set_phantom_below_window(aura::Window* phantom_below_window) {
56 phantom_below_window_ = phantom_below_window; 66 phantom_below_window_ = phantom_below_window;
57 } 67 }
58 68
69 // Sets/gets the style of the phantom window.
70 void set_style(Style style);
71 Style style() const { return style_; }
72
73 // Sets/gets the opacity of the phantom window.
74 void SetOpacity(float opacity);
75 float GetOpacity() const;
76
59 // ui::AnimationDelegate overrides: 77 // ui::AnimationDelegate overrides:
60 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; 78 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
61 79
62 private: 80 private:
63 // Creates and shows the |phantom_widget_| at |bounds|. 81 // Creates and shows the |phantom_widget_| at |bounds|.
64 void CreatePhantomWidget(const gfx::Rect& bounds); 82 void CreatePhantomWidget(const gfx::Rect& bounds);
65 83
84 // Sets bounds of the phantom window. The window is shown on |dst_display_|
85 // if its id() is valid. Otherwise, a display nearest to |bounds| is chosen.
86 void SetBoundsInternal(const gfx::Rect& bounds);
87
66 // Window the phantom is placed beneath. 88 // Window the phantom is placed beneath.
67 aura::Window* window_; 89 aura::Window* window_;
68 90
91 // The display where the phantom is placed. When dst_display_.id() is -1 (i.e.
92 // the default), a display nearest to the current |bounds_| is automatically
93 // used.
94 gfx::Display dst_display_;
95
69 // If set, the phantom window should get stacked below this window. 96 // If set, the phantom window should get stacked below this window.
70 aura::Window* phantom_below_window_; 97 aura::Window* phantom_below_window_;
71 98
72 // Initially the bounds of |window_|. Each time Show() is invoked 99 // Initially the bounds of |window_|. Each time Show() is invoked
73 // |start_bounds_| is then reset to the bounds of |phantom_widget_| and 100 // |start_bounds_| is then reset to the bounds of |phantom_widget_| and
74 // |bounds_| is set to the value passed into Show(). The animation animates 101 // |bounds_| is set to the value passed into Show(). The animation animates
75 // between these two values. 102 // between these two values.
76 gfx::Rect start_bounds_; 103 gfx::Rect start_bounds_;
77 gfx::Rect bounds_; 104 gfx::Rect bounds_;
78 105
79 views::Widget* phantom_widget_; 106 views::Widget* phantom_widget_;
80 107
81 // Used to transition the bounds. 108 // Used to transition the bounds.
82 scoped_ptr<ui::SlideAnimation> animation_; 109 scoped_ptr<ui::SlideAnimation> animation_;
83 110
111 // The style of the phantom window.
112 Style style_;
113
84 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController); 114 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController);
85 }; 115 };
86 116
87 } // namespace internal 117 } // namespace internal
88 } // namespace ash 118 } // namespace ash
89 119
90 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_ 120 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698