| OLD | NEW |
| 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_PANELS_PANEL_WINDOW_RESIZER_H_ | 5 #ifndef ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ |
| 6 #define ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ | 6 #define ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ |
| 7 | 7 |
| 8 #include "ash/wm/window_resizer.h" | 8 #include "ash/wm/window_resizer.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 | 11 |
| 12 namespace gfx { | 12 namespace gfx { |
| 13 class Rect; | 13 class Rect; |
| 14 class Point; | 14 class Point; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace ash { | 17 namespace ash { |
| 18 | 18 |
| 19 // PanelWindowResizer is used by ToplevelWindowEventFilter to handle dragging, | 19 // PanelWindowResizer is used by ToplevelWindowEventFilter to handle dragging, |
| 20 // moving or resizing panel window. These can be attached and detached from the | 20 // moving or resizing panel window. These can be attached and detached from the |
| 21 // launcher. | 21 // launcher. |
| 22 class ASH_EXPORT PanelWindowResizer : public WindowResizer { | 22 class ASH_EXPORT PanelWindowResizer : public WindowResizer { |
| 23 public: | 23 public: |
| 24 virtual ~PanelWindowResizer(); | 24 virtual ~PanelWindowResizer(); |
| 25 | 25 |
| 26 // Creates a new PanelWindowResizer. The caller takes ownership of the | 26 // Creates a new PanelWindowResizer. The caller takes ownership of the |
| 27 // returned object. The ownership of |next_window_resizer| is taken by the | 27 // returned object. The ownership of |next_window_resizer| is taken by the |
| 28 // returned object. Returns NULL if not resizable. | 28 // returned object. Returns NULL if not resizable. |
| 29 static PanelWindowResizer* Create(WindowResizer* next_window_resizer, | 29 static PanelWindowResizer* Create(WindowResizer* next_window_resizer, |
| 30 aura::Window* window, | 30 wm::WindowState* window_state); |
| 31 const gfx::Point& location, | |
| 32 int window_component, | |
| 33 aura::client::WindowMoveSource source); | |
| 34 | 31 |
| 35 // WindowResizer: | 32 // WindowResizer: |
| 36 virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE; | 33 virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE; |
| 37 virtual void CompleteDrag() OVERRIDE; | 34 virtual void CompleteDrag() OVERRIDE; |
| 38 virtual void RevertDrag() OVERRIDE; | 35 virtual void RevertDrag() OVERRIDE; |
| 39 virtual aura::Window* GetTarget() OVERRIDE; | |
| 40 virtual const gfx::Point& GetInitialLocation() const OVERRIDE; | |
| 41 | 36 |
| 42 private: | 37 private: |
| 43 // Creates PanelWindowResizer that adds the ability to attach / detach panel | 38 // Creates PanelWindowResizer that adds the ability to attach / detach panel |
| 44 // windows as well as reparenting them to the panel layer while dragging to | 39 // windows as well as reparenting them to the panel layer while dragging to |
| 45 // |next_window_resizer|. This object takes ownership of | 40 // |next_window_resizer|. This object takes ownership of |
| 46 // |next_window_resizer|. | 41 // |next_window_resizer|. |
| 47 PanelWindowResizer(WindowResizer* next_window_resizer, | 42 PanelWindowResizer(WindowResizer* next_window_resizer, |
| 48 const Details& details); | 43 wm::WindowState* window_state); |
| 49 | 44 |
| 50 // Checks if the provided window bounds should attach to the launcher. If true | 45 // Checks if the provided window bounds should attach to the launcher. If true |
| 51 // the offset gives the necessary adjustment to snap to the launcher. | 46 // the offset gives the necessary adjustment to snap to the launcher. |
| 52 bool AttachToLauncher(const gfx::Rect& bounds, gfx::Point* offset); | 47 bool AttachToLauncher(const gfx::Rect& bounds, gfx::Point* offset); |
| 53 | 48 |
| 54 // Tracks the panel's initial position and attachment at the start of a drag | 49 // Tracks the panel's initial position and attachment at the start of a drag |
| 55 // and informs the PanelLayoutManager that a drag has started if necessary. | 50 // and informs the PanelLayoutManager that a drag has started if necessary. |
| 56 void StartedDragging(); | 51 void StartedDragging(); |
| 57 | 52 |
| 58 // Informs the PanelLayoutManager that the drag is complete if it was informed | 53 // Informs the PanelLayoutManager that the drag is complete if it was informed |
| 59 // of the drag start. | 54 // of the drag start. |
| 60 void FinishDragging(); | 55 void FinishDragging(); |
| 61 | 56 |
| 62 // Updates the dragged panel's index in the launcher. | 57 // Updates the dragged panel's index in the launcher. |
| 63 void UpdateLauncherPosition(); | 58 void UpdateLauncherPosition(); |
| 64 | 59 |
| 65 const Details details_; | |
| 66 | |
| 67 // Last pointer location in screen coordinates. | 60 // Last pointer location in screen coordinates. |
| 68 gfx::Point last_location_; | 61 gfx::Point last_location_; |
| 69 | 62 |
| 70 // Wraps a window resizer and adds panel detaching / reattaching and snapping | 63 // Wraps a window resizer and adds panel detaching / reattaching and snapping |
| 71 // to launcher behavior during drags. | 64 // to launcher behavior during drags. |
| 72 scoped_ptr<WindowResizer> next_window_resizer_; | 65 scoped_ptr<WindowResizer> next_window_resizer_; |
| 73 | 66 |
| 74 // Panel container window. | 67 // Panel container window. |
| 75 aura::Window* panel_container_; | 68 aura::Window* panel_container_; |
| 76 aura::Window* initial_panel_container_; | 69 aura::Window* initial_panel_container_; |
| 77 | 70 |
| 78 // Set to true once Drag() is invoked and the bounds of the window change. | 71 // Set to true once Drag() is invoked and the bounds of the window change. |
| 79 bool did_move_or_resize_; | 72 bool did_move_or_resize_; |
| 80 | 73 |
| 81 // True if the window started attached to the launcher. | 74 // True if the window started attached to the launcher. |
| 82 const bool was_attached_; | 75 const bool was_attached_; |
| 83 | 76 |
| 84 // True if the window should attach to the launcher after releasing. | |
| 85 bool should_attach_; | |
| 86 | |
| 87 base::WeakPtrFactory<PanelWindowResizer> weak_ptr_factory_; | 77 base::WeakPtrFactory<PanelWindowResizer> weak_ptr_factory_; |
| 88 | 78 |
| 89 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizer); | 79 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizer); |
| 90 }; | 80 }; |
| 91 | 81 |
| 92 } // namespace ash | 82 } // namespace ash |
| 93 | 83 |
| 94 #endif // ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ | 84 #endif // ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ |
| OLD | NEW |