| 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_WINDOW_RESIZER_H_ | 5 #ifndef ASH_WM_WINDOW_RESIZER_H_ |
| 6 #define ASH_WM_WINDOW_RESIZER_H_ | 6 #define ASH_WM_WINDOW_RESIZER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/wm/drag_details.h" | 11 #include "ash/wm/drag_details.h" |
| 12 #include "ash/wm/window_state.h" | 12 #include "ash/wm/window_state.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "ui/gfx/geometry/rect.h" | |
| 15 #include "ui/wm/public/window_move_client.h" | 14 #include "ui/wm/public/window_move_client.h" |
| 16 | 15 |
| 17 namespace aura { | 16 namespace aura { |
| 18 class Window; | 17 class Window; |
| 19 } | 18 } |
| 20 | 19 |
| 20 namespace gfx { |
| 21 class Rect; |
| 22 } |
| 23 |
| 21 namespace ash { | 24 namespace ash { |
| 25 namespace wm { |
| 26 class WmWindow; |
| 27 } |
| 22 | 28 |
| 23 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving | 29 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving |
| 24 // or resizing a window. All coordinates passed to this are in the parent | 30 // or resizing a window. All coordinates passed to this are in the parent |
| 25 // windows coordinates. | 31 // windows coordinates. |
| 26 class ASH_EXPORT WindowResizer { | 32 class ASH_EXPORT WindowResizer { |
| 27 public: | 33 public: |
| 28 // Constants to identify the type of resize. | 34 // Constants to identify the type of resize. |
| 29 static const int kBoundsChange_None; | 35 static const int kBoundsChange_None; |
| 30 static const int kBoundsChange_Repositions; | 36 static const int kBoundsChange_Repositions; |
| 31 static const int kBoundsChange_Resizes; | 37 static const int kBoundsChange_Resizes; |
| 32 | 38 |
| 33 // Used to indicate which direction the resize occurs in. | 39 // Used to indicate which direction the resize occurs in. |
| 34 static const int kBoundsChangeDirection_None; | 40 static const int kBoundsChangeDirection_None; |
| 35 static const int kBoundsChangeDirection_Horizontal; | 41 static const int kBoundsChangeDirection_Horizontal; |
| 36 static const int kBoundsChangeDirection_Vertical; | 42 static const int kBoundsChangeDirection_Vertical; |
| 37 | 43 |
| 38 WindowResizer(wm::WindowState* window_state); | 44 explicit WindowResizer(wm::WindowState* window_state); |
| 39 virtual ~WindowResizer(); | 45 virtual ~WindowResizer(); |
| 40 | 46 |
| 41 // Returns a bitmask of the kBoundsChange_ values. | 47 // Returns a bitmask of the kBoundsChange_ values. |
| 42 static int GetBoundsChangeForWindowComponent(int component); | 48 static int GetBoundsChangeForWindowComponent(int component); |
| 43 | 49 |
| 44 // Returns a bitmask of the kBoundsChange_ values. | 50 // Returns a bitmask of the kBoundsChange_ values. |
| 45 static int GetPositionChangeDirectionForWindowComponent(int window_component); | 51 static int GetPositionChangeDirectionForWindowComponent(int window_component); |
| 46 | 52 |
| 47 // Invoked to drag/move/resize the window. |location| is in the coordinates | 53 // Invoked to drag/move/resize the window. |location| is in the coordinates |
| 48 // of the window supplied to the constructor. |event_flags| is the event | 54 // of the window supplied to the constructor. |event_flags| is the event |
| 49 // flags from the event. | 55 // flags from the event. |
| 50 virtual void Drag(const gfx::Point& location, int event_flags) = 0; | 56 virtual void Drag(const gfx::Point& location, int event_flags) = 0; |
| 51 | 57 |
| 52 // Invoked to complete the drag. | 58 // Invoked to complete the drag. |
| 53 virtual void CompleteDrag() = 0; | 59 virtual void CompleteDrag() = 0; |
| 54 | 60 |
| 55 // Reverts the drag. | 61 // Reverts the drag. |
| 56 virtual void RevertDrag() = 0; | 62 virtual void RevertDrag() = 0; |
| 57 | 63 |
| 58 // Returns the target window the resizer was created for. | 64 // Returns the target window the resizer was created for. |
| 59 aura::Window* GetTarget() const { | 65 wm::WmWindow* GetTarget() const { |
| 60 return window_state_ ? window_state_->aura_window() : NULL; | 66 return window_state_ ? window_state_->window() : nullptr; |
| 67 } |
| 68 // Deprecated. |
| 69 // TODO(sky): remove. |
| 70 aura::Window* GetAuraTarget() const { |
| 71 return window_state_ ? window_state_->aura_window() : nullptr; |
| 61 } | 72 } |
| 62 | 73 |
| 63 // See comment for |DragDetails::initial_location_in_parent|. | 74 // See comment for |DragDetails::initial_location_in_parent|. |
| 64 const gfx::Point& GetInitialLocation() const { | 75 const gfx::Point& GetInitialLocation() const { |
| 65 return window_state_->drag_details()->initial_location_in_parent; | 76 return window_state_->drag_details()->initial_location_in_parent; |
| 66 } | 77 } |
| 67 | 78 |
| 68 // Drag parameters established when drag starts. | 79 // Drag parameters established when drag starts. |
| 69 const DragDetails& details() const { return *window_state_->drag_details(); } | 80 const DragDetails& details() const { return *window_state_->drag_details(); } |
| 70 | 81 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // TODO(sky): move this to its own file. This is aura specific. | 113 // TODO(sky): move this to its own file. This is aura specific. |
| 103 ASH_EXPORT std::unique_ptr<WindowResizer> CreateWindowResizer( | 114 ASH_EXPORT std::unique_ptr<WindowResizer> CreateWindowResizer( |
| 104 aura::Window* window, | 115 aura::Window* window, |
| 105 const gfx::Point& point_in_parent, | 116 const gfx::Point& point_in_parent, |
| 106 int window_component, | 117 int window_component, |
| 107 aura::client::WindowMoveSource source); | 118 aura::client::WindowMoveSource source); |
| 108 | 119 |
| 109 } // namespace ash | 120 } // namespace ash |
| 110 | 121 |
| 111 #endif // ASH_WM_WINDOW_RESIZER_H_ | 122 #endif // ASH_WM_WINDOW_RESIZER_H_ |
| OLD | NEW |