| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_DOCK_DOCK_WINDOW_RESIZER_H_ | 5 #ifndef ASH_WM_DOCK_DOCK_WINDOW_RESIZER_H_ |
| 6 #define ASH_WM_DOCK_DOCK_WINDOW_RESIZER_H_ | 6 #define ASH_WM_DOCK_DOCK_WINDOW_RESIZER_H_ |
| 7 | 7 |
| 8 #include "ash/wm/dock/dock_types.h" | 8 #include "ash/wm/dock/dock_types.h" |
| 9 #include "ash/wm/window_resizer.h" | 9 #include "ash/wm/window_resizer.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 | 13 |
| 14 namespace gfx { | 14 namespace gfx { |
| 15 class Point; | 15 class Point; |
| 16 class Rect; | 16 class Rect; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace aura { | 19 namespace aura { |
| 20 class RootWindow; | 20 class RootWindow; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace ash { | 23 namespace ash { |
| 24 namespace internal { | 24 namespace internal { |
| 25 | 25 |
| 26 class DockedWindowLayoutManager; | 26 class DockedWindowLayoutManager; |
| 27 class PhantomWindowController; | |
| 28 | 27 |
| 29 // DockWindowResizer is used by ToplevelWindowEventFilter to handle dragging, | 28 // DockWindowResizer is used by ToplevelWindowEventFilter to handle dragging, |
| 30 // moving or resizing of a window while it is docked to the side of a screen. | 29 // moving or resizing of a window while it is docked to the side of a screen. |
| 31 class ASH_EXPORT DockedWindowResizer : public WindowResizer { | 30 class ASH_EXPORT DockedWindowResizer : public WindowResizer { |
| 32 public: | 31 public: |
| 33 virtual ~DockedWindowResizer(); | 32 virtual ~DockedWindowResizer(); |
| 34 | 33 |
| 35 // Creates a new DockWindowResizer. The caller takes ownership of the | 34 // Creates a new DockWindowResizer. The caller takes ownership of the |
| 36 // returned object. The ownership of |next_window_resizer| is taken by the | 35 // returned object. The ownership of |next_window_resizer| is taken by the |
| 37 // returned object. Returns NULL if not resizable. | 36 // returned object. Returns NULL if not resizable. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 48 virtual aura::Window* GetTarget() OVERRIDE; | 47 virtual aura::Window* GetTarget() OVERRIDE; |
| 49 virtual const gfx::Point& GetInitialLocation() const OVERRIDE; | 48 virtual const gfx::Point& GetInitialLocation() const OVERRIDE; |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 // Creates DockWindowResizer that adds the ability to attach / detach | 51 // Creates DockWindowResizer that adds the ability to attach / detach |
| 53 // windows to / from the dock. This object takes ownership of | 52 // windows to / from the dock. This object takes ownership of |
| 54 // |next_window_resizer|. | 53 // |next_window_resizer|. |
| 55 DockedWindowResizer(WindowResizer* next_window_resizer, | 54 DockedWindowResizer(WindowResizer* next_window_resizer, |
| 56 const Details& details); | 55 const Details& details); |
| 57 | 56 |
| 58 // Returns the side of the screen that the window should dock to or | |
| 59 // DOCKED_ALIGNMENT_NONE when the window is not on a side or when some other | |
| 60 // windows are already docked on the other side or when launcher (shelf) is | |
| 61 // aligned on the same side. | |
| 62 DockedAlignment GetDraggedWindowAlignment(); | |
| 63 | |
| 64 // Checks if the provided window bounds should snap to the side of a screen. | 57 // Checks if the provided window bounds should snap to the side of a screen. |
| 65 // If so the offset returned gives the necessary adjustment to snap. | 58 // If so the offset returned gives the necessary adjustment to snap. |
| 66 bool MaybeSnapToEdge(const gfx::Rect& bounds, gfx::Point* offset); | 59 bool MaybeSnapToEdge(const gfx::Rect& bounds, gfx::Point* offset); |
| 67 | 60 |
| 68 // Tracks the window's initial position and attachment at the start of a drag | 61 // Tracks the window's initial position and attachment at the start of a drag |
| 69 // and informs the DockLayoutManager that a drag has started if necessary. | 62 // and informs the DockLayoutManager that a drag has started if necessary. |
| 70 void StartedDragging(); | 63 void StartedDragging(); |
| 71 | 64 |
| 72 // Informs the DockLayoutManager that the drag is complete if it was informed | 65 // Informs the DockLayoutManager that the drag is complete if it was informed |
| 73 // of the drag start. | 66 // of the drag start. |
| 74 void FinishedDragging(); | 67 void FinishedDragging(); |
| 75 | 68 |
| 76 // Updates the bounds of the phantom window that is used as a docking hint. | |
| 77 void UpdateSnapPhantomWindow(); | |
| 78 | |
| 79 const Details details_; | 69 const Details details_; |
| 80 | 70 |
| 81 gfx::Point last_location_; | 71 gfx::Point last_location_; |
| 82 | 72 |
| 83 // Wraps a window resizer and adds detaching / reattaching during drags. | 73 // Wraps a window resizer and adds detaching / reattaching during drags. |
| 84 scoped_ptr<WindowResizer> next_window_resizer_; | 74 scoped_ptr<WindowResizer> next_window_resizer_; |
| 85 | 75 |
| 86 // Dock container window. | 76 // Dock container window. |
| 87 internal::DockedWindowLayoutManager* dock_layout_; | 77 internal::DockedWindowLayoutManager* dock_layout_; |
| 88 internal::DockedWindowLayoutManager* initial_dock_layout_; | 78 internal::DockedWindowLayoutManager* initial_dock_layout_; |
| 89 | 79 |
| 90 // Set to true once Drag() is invoked and the bounds of the window change. | 80 // Set to true once Drag() is invoked and the bounds of the window change. |
| 91 bool did_move_or_resize_; | 81 bool did_move_or_resize_; |
| 92 | 82 |
| 93 // Gives a preview of where the the window will end up. | |
| 94 scoped_ptr<PhantomWindowController> snap_phantom_window_controller_; | |
| 95 | |
| 96 // Set to true if the window that is being dragged was docked before drag. | 83 // Set to true if the window that is being dragged was docked before drag. |
| 97 bool was_docked_; | 84 bool was_docked_; |
| 98 | 85 |
| 99 // True if the dragged window is docked during the drag. | 86 // True if the dragged window is docked during the drag. |
| 100 bool is_docked_; | 87 bool is_docked_; |
| 101 | 88 |
| 102 base::WeakPtrFactory<DockedWindowResizer> weak_ptr_factory_; | 89 base::WeakPtrFactory<DockedWindowResizer> weak_ptr_factory_; |
| 103 | 90 |
| 104 DISALLOW_COPY_AND_ASSIGN(DockedWindowResizer); | 91 DISALLOW_COPY_AND_ASSIGN(DockedWindowResizer); |
| 105 }; | 92 }; |
| 106 | 93 |
| 107 } // namespace internal | 94 } // namespace internal |
| 108 } // namespace ash | 95 } // namespace ash |
| 109 | 96 |
| 110 #endif // ASH_WM_DOCK_DOCK_WINDOW_RESIZER_H_ | 97 #endif // ASH_WM_DOCK_DOCK_WINDOW_RESIZER_H_ |
| OLD | NEW |