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 3 // found in the LICENSE file. 4 5 #ifndef ASH_WM_DOCK_DOCK_WINDOW_RESIZER_H_ 6 #define ASH_WM_DOCK_DOCK_WINDOW_RESIZER_H_ 7 8 #include "ash/wm/window_resizer.h" 9 #include "base/compiler_specific.h" 10 11 namespace gfx { 12 class Point; 13 class Rect; 14 } 15 16 namespace aura { 17 class RootWindow; 18 } 19 20 namespace ash { 21 22 namespace internal { 23 class DockedWindowLayoutManager; 24 } 25 26 // DockWindowResizer is used by ToplevelWindowEventFilter to handle dragging, 27 // moving or resizing of a window while it is docked to the side of a screen. 28 class ASH_EXPORT DockedWindowResizer : public WindowResizer { 29 public: 30 virtual ~DockedWindowResizer(); 31 32 // Creates a new DockWindowResizer. The caller takes ownership of the 33 // returned object. The ownership of |next_window_resizer| is taken by the 34 // returned object. Returns NULL if not resizable. 35 static DockedWindowResizer* Create(WindowResizer* next_window_resizer, 36 aura::Window* window, 37 const gfx::Point& location, 38 int window_component, 39 aura::client::WindowMoveSource source); 40 41 // WindowResizer: 42 virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE; 43 virtual void CompleteDrag(int event_flags) OVERRIDE; 44 virtual void RevertDrag() OVERRIDE; 45 virtual aura::Window* GetTarget() OVERRIDE; 46 virtual const gfx::Point& GetInitialLocation() const OVERRIDE; 47 48 private: 49 // Creates DockWindowResizer that adds the ability to attach / detach 50 // windows to / from the dock. This object takes ownership of 51 // |next_window_resizer|. 52 DockedWindowResizer(WindowResizer* next_window_resizer, 53 const Details& details); 54 55 // Checks if the provided window bounds should snap to the side of a screen. 56 // If so the offset returned gives the necessary adjustment to snap. 57 bool MaybeSnapToEdge(const gfx::Rect& bounds, gfx::Point* offset); 58 59 // Tracks the window's initial position and attachment at the start of a drag 60 // and informs the DockLayoutManager that a drag has started if necessary. 61 void StartedDragging(); 62 63 // Informs the DockLayoutManager that the drag is complete if it was informed 64 // of the drag start. 65 void FinishDragging(); 66 67 const Details details_; 68 69 gfx::Point last_location_; 70 71 // Wraps a window resizer and adds detaching / reattaching during drags. 72 scoped_ptr<WindowResizer> next_window_resizer_; 73 74 // Dock container window. 75 internal::DockedWindowLayoutManager* dock_layout_; 76 77 // Set to true once Drag() is invoked and the bounds of the window change. 78 bool did_move_or_resize_; 79 80 // Set to true if the window that is being dragged was docked before drag. 81 bool was_docked_; 82 83 // If non-NULL the destructor sets this to true. Used to determine if this has 84 // been deleted. 85 bool* destroyed_; 86 87 DISALLOW_COPY_AND_ASSIGN(DockedWindowResizer); 88 }; 89 90 } // namespace ash 91 92 #endif // ASH_WM_DOCK_DOCK_WINDOW_RESIZER_H_ 93