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/wm/public/window_move_client.h" | 14 #include "ui/wm/public/window_move_client.h" |
15 | 15 |
| 16 namespace aura { |
| 17 class Window; |
| 18 } |
| 19 |
16 namespace gfx { | 20 namespace gfx { |
17 class Rect; | 21 class Rect; |
18 } | 22 } |
19 | 23 |
20 namespace ash { | 24 namespace ash { |
21 | 25 |
22 class WmWindow; | |
23 | |
24 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving | 26 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving |
25 // or resizing a window. All coordinates passed to this are in the parent | 27 // or resizing a window. All coordinates passed to this are in the parent |
26 // windows coordinates. | 28 // windows coordinates. |
27 class ASH_EXPORT WindowResizer { | 29 class ASH_EXPORT WindowResizer { |
28 public: | 30 public: |
29 // Constants to identify the type of resize. | 31 // Constants to identify the type of resize. |
30 static const int kBoundsChange_None; | 32 static const int kBoundsChange_None; |
31 static const int kBoundsChange_Repositions; | 33 static const int kBoundsChange_Repositions; |
32 static const int kBoundsChange_Resizes; | 34 static const int kBoundsChange_Resizes; |
33 | 35 |
(...skipping 16 matching lines...) Expand all Loading... |
50 // flags from the event. | 52 // flags from the event. |
51 virtual void Drag(const gfx::Point& location, int event_flags) = 0; | 53 virtual void Drag(const gfx::Point& location, int event_flags) = 0; |
52 | 54 |
53 // Invoked to complete the drag. | 55 // Invoked to complete the drag. |
54 virtual void CompleteDrag() = 0; | 56 virtual void CompleteDrag() = 0; |
55 | 57 |
56 // Reverts the drag. | 58 // Reverts the drag. |
57 virtual void RevertDrag() = 0; | 59 virtual void RevertDrag() = 0; |
58 | 60 |
59 // Returns the target window the resizer was created for. | 61 // Returns the target window the resizer was created for. |
60 WmWindow* GetTarget() const { | 62 aura::Window* GetTarget() const; |
61 return window_state_ ? window_state_->window() : nullptr; | 63 |
62 } | |
63 // See comment for |DragDetails::initial_location_in_parent|. | 64 // See comment for |DragDetails::initial_location_in_parent|. |
64 const gfx::Point& GetInitialLocation() const { | 65 const gfx::Point& GetInitialLocation() const { |
65 return window_state_->drag_details()->initial_location_in_parent; | 66 return window_state_->drag_details()->initial_location_in_parent; |
66 } | 67 } |
67 | 68 |
68 // Drag parameters established when drag starts. | 69 // Drag parameters established when drag starts. |
69 const DragDetails& details() const { return *window_state_->drag_details(); } | 70 const DragDetails& details() const { return *window_state_->drag_details(); } |
70 | 71 |
71 protected: | 72 protected: |
72 gfx::Rect CalculateBoundsForDrag(const gfx::Point& location); | 73 gfx::Rect CalculateBoundsForDrag(const gfx::Point& location); |
(...skipping 20 matching lines...) Expand all Loading... |
93 | 94 |
94 // Returns the height of the drag. | 95 // Returns the height of the drag. |
95 int GetHeightForDrag(int min_height, int* delta_y); | 96 int GetHeightForDrag(int min_height, int* delta_y); |
96 | 97 |
97 DISALLOW_COPY_AND_ASSIGN(WindowResizer); | 98 DISALLOW_COPY_AND_ASSIGN(WindowResizer); |
98 }; | 99 }; |
99 | 100 |
100 // Creates a WindowResizer for |window|. Returns a unique_ptr with null if | 101 // Creates a WindowResizer for |window|. Returns a unique_ptr with null if |
101 // |window| should not be resized nor dragged. | 102 // |window| should not be resized nor dragged. |
102 ASH_EXPORT std::unique_ptr<WindowResizer> CreateWindowResizer( | 103 ASH_EXPORT std::unique_ptr<WindowResizer> CreateWindowResizer( |
103 WmWindow* window, | 104 aura::Window* window, |
104 const gfx::Point& point_in_parent, | 105 const gfx::Point& point_in_parent, |
105 int window_component, | 106 int window_component, |
106 aura::client::WindowMoveSource source); | 107 aura::client::WindowMoveSource source); |
107 | 108 |
108 } // namespace ash | 109 } // namespace ash |
109 | 110 |
110 #endif // ASH_WM_WINDOW_RESIZER_H_ | 111 #endif // ASH_WM_WINDOW_RESIZER_H_ |
OLD | NEW |