| 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 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // Creates a new PanelWindowResizer. The caller takes ownership of the | 25 // Creates a new PanelWindowResizer. The caller takes ownership of the |
| 26 // returned object. The ownership of |next_window_resizer| is taken by the | 26 // returned object. The ownership of |next_window_resizer| is taken by the |
| 27 // returned object. Returns NULL if not resizable. | 27 // returned object. Returns NULL if not resizable. |
| 28 static PanelWindowResizer* Create(WindowResizer* next_window_resizer, | 28 static PanelWindowResizer* Create(WindowResizer* next_window_resizer, |
| 29 aura::Window* window, | 29 aura::Window* window, |
| 30 const gfx::Point& location, | 30 const gfx::Point& location, |
| 31 int window_component, | 31 int window_component, |
| 32 aura::client::WindowMoveSource source); | 32 aura::client::WindowMoveSource source); |
| 33 | 33 |
| 34 // WindowResizer overides: | 34 // WindowResizer: |
| 35 virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE; | 35 virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE; |
| 36 virtual void CompleteDrag(int event_flags) OVERRIDE; | 36 virtual void CompleteDrag(int event_flags) OVERRIDE; |
| 37 virtual void RevertDrag() OVERRIDE; | 37 virtual void RevertDrag() OVERRIDE; |
| 38 virtual aura::Window* GetTarget() OVERRIDE; | 38 virtual aura::Window* GetTarget() OVERRIDE; |
| 39 | 39 virtual const gfx::Point& GetInitialLocation() const OVERRIDE; |
| 40 const gfx::Point& GetInitialLocationInParentForTest() const { | |
| 41 return details_.initial_location_in_parent; | |
| 42 } | |
| 43 | 40 |
| 44 private: | 41 private: |
| 45 // Creates PanelWindowResizer that adds the ability to attach / detach panel | 42 // Creates PanelWindowResizer that adds the ability to attach / detach panel |
| 46 // windows as well as reparenting them to the panel layer while dragging to | 43 // windows as well as reparenting them to the panel layer while dragging to |
| 47 // |next_window_resizer|. This object takes ownership of | 44 // |next_window_resizer|. This object takes ownership of |
| 48 // |next_window_resizer|. | 45 // |next_window_resizer|. |
| 49 PanelWindowResizer(WindowResizer* next_window_resizer, | 46 PanelWindowResizer(WindowResizer* next_window_resizer, |
| 50 const Details& details); | 47 const Details& details); |
| 51 | 48 |
| 52 // Checks if the provided window bounds should attach to the launcher. If true | 49 // Checks if the provided window bounds should attach to the launcher. If true |
| 53 // the offset gives the necessary adjustment to snap to the launcher. | 50 // the offset gives the necessary adjustment to snap to the launcher. |
| 54 bool AttachToLauncher(const gfx::Rect& bounds, gfx::Point* offset); | 51 bool AttachToLauncher(const gfx::Rect& bounds, gfx::Point* offset); |
| 55 | 52 |
| 56 // Tracks the panel's initial position and attachment at the start of a drag | 53 // Tracks the panel's initial position and attachment at the start of a drag |
| 57 // and informs the PanelLayoutManager that a drag has started if necessary. | 54 // and informs the PanelLayoutManager that a drag has started if necessary. |
| 58 void StartedDragging(); | 55 void StartedDragging(); |
| 59 | 56 |
| 60 // Informs the PanelLayoutManager that the drag is complete if it was informed | 57 // Informs the PanelLayoutManager that the drag is complete if it was informed |
| 61 // of the drag start. | 58 // of the drag start. |
| 62 void FinishDragging(); | 59 void FinishDragging(); |
| 63 | 60 |
| 64 // Updates the dragged panel's index in the launcher. | 61 // Updates the dragged panel's index in the launcher. |
| 65 void UpdateLauncherPosition(); | 62 void UpdateLauncherPosition(); |
| 66 | 63 |
| 67 const Details details_; | 64 const Details details_; |
| 68 | 65 |
| 66 // Last pointer location in screen coordinates. |
| 67 gfx::Point last_location_; |
| 68 |
| 69 // Wraps a window resizer and adds panel detaching / reattaching and snapping | 69 // Wraps a window resizer and adds panel detaching / reattaching and snapping |
| 70 // to launcher behavior during drags. | 70 // to launcher behavior during drags. |
| 71 scoped_ptr<WindowResizer> next_window_resizer_; | 71 scoped_ptr<WindowResizer> next_window_resizer_; |
| 72 | 72 |
| 73 // Panel container window. | 73 // Panel container window. |
| 74 aura::Window* panel_container_; | 74 aura::Window* panel_container_; |
| 75 | 75 |
| 76 // Set to true once Drag() is invoked and the bounds of the window change. | 76 // Set to true once Drag() is invoked and the bounds of the window change. |
| 77 bool did_move_or_resize_; | 77 bool did_move_or_resize_; |
| 78 | 78 |
| 79 // True if the window started attached to the launcher. | 79 // True if the window started attached to the launcher. |
| 80 const bool was_attached_; | 80 const bool was_attached_; |
| 81 | 81 |
| 82 // True if the window should attach to the launcher after releasing. | 82 // True if the window should attach to the launcher after releasing. |
| 83 bool should_attach_; | 83 bool should_attach_; |
| 84 | 84 |
| 85 // If non-NULL the destructor sets this to true. Used to determine if this has | 85 // If non-NULL the destructor sets this to true. Used to determine if this has |
| 86 // been deleted. | 86 // been deleted. |
| 87 bool* destroyed_; | 87 bool* destroyed_; |
| 88 | 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizer); | 89 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizer); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 } // namespace aura | 92 } // namespace ash |
| 93 | 93 |
| 94 #endif // ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ | 94 #endif // ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ |
| OLD | NEW |