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
3 // found in the LICENSE file.
5 #ifndef ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_
6 #define ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/rect.h"
23 // PhantomWindowController is responsible for showing a phantom representation
24 // of a window. It's used to show a preview of how snapping or docking a window
25 // will affect the window's bounds.
26 class ASH_EXPORT PhantomWindowController
{
28 explicit PhantomWindowController(aura::Window
* window
);
30 // Hides the phantom window without any animation.
31 virtual ~PhantomWindowController();
33 // Animates the phantom window towards |bounds_in_screen|. The animation used
34 // depends on whether the alternate caption button style is used.
35 void Show(const gfx::Rect
& bounds_in_screen
);
37 // If set, the phantom window is stacked below this window, otherwise it
38 // is stacked above the window passed to the constructor.
39 void set_phantom_below_window(aura::Window
* phantom_below_window
) {
40 phantom_below_window_
= phantom_below_window
;
44 friend class PhantomWindowControllerTest
;
46 // Animates the phantom window towards |bounds_in_screen| when the alternate
47 // caption button style is used.
48 void ShowAlternate(const gfx::Rect
& bounds_in_screen
);
50 // Animates the phantom window towards |bounds_in_screen| when the legacy
51 // caption button style is used.
52 void ShowLegacy(const gfx::Rect
& bounds_in_screen
);
54 // Creates, shows and returns a phantom widget at |bounds|
55 // with kShellWindowId_ShelfContainer in |root_window| as a parent.
56 scoped_ptr
<views::Widget
> CreatePhantomWidget(
57 aura::Window
* root_window
,
58 const gfx::Rect
& bounds_in_screen
);
60 // Window the phantom is placed beneath.
61 aura::Window
* window_
;
63 // If set, the phantom window should get stacked below this window.
64 aura::Window
* phantom_below_window_
;
66 // Target bounds (including the shadows if any) of the animation in screen
68 gfx::Rect target_bounds_in_screen_
;
70 // Phantom representation of the window which is in the root window matching
71 // |target_bounds_in_screen_|.
72 scoped_ptr
<views::Widget
> phantom_widget_in_target_root_
;
74 // Phantom representation of the window which is in the root window matching
75 // the window's initial bounds. This allows animations to progress from one
76 // display to the other. NULL if the phantom window starts and ends in the
77 // same root window. Not used when using the alternate caption button style.
78 scoped_ptr
<views::Widget
> phantom_widget_in_start_root_
;
80 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController
);
85 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_