Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / ash / wm / drag_window_controller.h
blob2a158c056addb16e96c0fe4563753858aa849a63
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_DRAG_WINDOW_CONTROLLER_H_
6 #define ASH_WM_DRAG_WINDOW_CONTROLLER_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/gfx/display.h"
13 #include "ui/gfx/geometry/rect.h"
15 namespace aura {
16 class Window;
19 namespace ui {
20 class Layer;
21 class LayerTreeOwner;
24 namespace views {
25 class Widget;
28 namespace ash {
30 // DragWindowController is responsible for showing a semi-transparent window
31 // while dragging a window across displays.
32 class ASH_EXPORT DragWindowController {
33 public:
34 explicit DragWindowController(aura::Window* window);
35 virtual ~DragWindowController();
37 // Sets the display where the window is placed after the window is dropped.
38 void SetDestinationDisplay(const gfx::Display& dst_display);
40 // Shows the drag window at the specified location (coordinates of the
41 // parent). If |layer| is non-NULL, it is shown on top of the drag window.
42 // |layer| is owned by the caller.
43 // This does not immediately show the window.
44 void Show();
46 // Hides the drag window.
47 void Hide();
49 // This is used to set bounds for the drag window immediately. This should
50 // be called only when the drag window is already visible.
51 void SetBounds(const gfx::Rect& bounds);
53 // Sets the opacity of the drag window.
54 void SetOpacity(float opacity);
56 private:
57 FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, DragWindowController);
59 // Creates and shows the |drag_widget_| at |bounds|.
60 // |layer| is shown on top of the drag window if it is non-NULL.
61 // |layer| is not owned by this object.
62 void CreateDragWidget(const gfx::Rect& bounds);
64 // Sets bounds of the drag window. The window is shown on |dst_display_|
65 // if its id() is valid. Otherwise, a display nearest to |bounds| is chosen.
66 void SetBoundsInternal(const gfx::Rect& bounds);
68 // Recreates a fresh layer for |window_| and all its child windows.
69 void RecreateWindowLayers();
71 // Window the drag window is placed beneath.
72 aura::Window* window_;
74 // The display where the drag is placed. When dst_display_.id() is
75 // kInvalidDisplayID (i.e. the default), a display nearest to the current
76 // |bounds_| is automatically used.
77 gfx::Display dst_display_;
79 // Initially the bounds of |window_|. Each time Show() is invoked
80 // |start_bounds_| is then reset to the bounds of |drag_widget_| and
81 // |bounds_| is set to the value passed into Show(). The animation animates
82 // between these two values.
83 gfx::Rect bounds_;
85 views::Widget* drag_widget_;
87 // The copy of window_->layer() and its descendants.
88 scoped_ptr<ui::LayerTreeOwner> layer_owner_;
90 DISALLOW_COPY_AND_ASSIGN(DragWindowController);
93 } // namespace ash
95 #endif // ASH_WM_DRAG_WINDOW_CONTROLLER_H_