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 "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "ui/aura/client/window_move_client.h" |
11 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
12 | 13 |
13 namespace aura { | 14 namespace aura { |
14 class Window; | 15 class Window; |
15 } | 16 } |
16 | 17 |
17 namespace ash { | 18 namespace ash { |
18 | 19 |
19 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving | 20 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving |
20 // or resizing a window. All coordinates passed to this are in the parent | 21 // or resizing a window. All coordinates passed to this are in the parent |
(...skipping 28 matching lines...) Expand all Loading... |
49 virtual void RevertDrag() = 0; | 50 virtual void RevertDrag() = 0; |
50 | 51 |
51 // Returns the target window the resizer was created for. | 52 // Returns the target window the resizer was created for. |
52 virtual aura::Window* GetTarget() = 0; | 53 virtual aura::Window* GetTarget() = 0; |
53 | 54 |
54 protected: | 55 protected: |
55 struct Details { | 56 struct Details { |
56 Details(); | 57 Details(); |
57 Details(aura::Window* window, | 58 Details(aura::Window* window, |
58 const gfx::Point& location, | 59 const gfx::Point& location, |
59 int window_component); | 60 int window_component, |
| 61 aura::client::WindowMoveSource source); |
60 ~Details(); | 62 ~Details(); |
61 | 63 |
62 // The window we're resizing. | 64 // The window we're resizing. |
63 aura::Window* window; | 65 aura::Window* window; |
64 | 66 |
65 // Initial bounds of the window in parent coordinates. | 67 // Initial bounds of the window in parent coordinates. |
66 gfx::Rect initial_bounds_in_parent; | 68 gfx::Rect initial_bounds_in_parent; |
67 | 69 |
68 // Restore bounds (in screen coordinates) of the window before the drag | 70 // Restore bounds (in screen coordinates) of the window before the drag |
69 // started. Only set if the window is normal and is being dragged. | 71 // started. Only set if the window is normal and is being dragged. |
(...skipping 12 matching lines...) Expand all Loading... |
82 int bounds_change; | 84 int bounds_change; |
83 | 85 |
84 // Bitmask of the |kBoundsChangeDirection_| constants. | 86 // Bitmask of the |kBoundsChangeDirection_| constants. |
85 int position_change_direction; | 87 int position_change_direction; |
86 | 88 |
87 // Bitmask of the |kBoundsChangeDirection_| constants. | 89 // Bitmask of the |kBoundsChangeDirection_| constants. |
88 int size_change_direction; | 90 int size_change_direction; |
89 | 91 |
90 // Will the drag actually modify the window? | 92 // Will the drag actually modify the window? |
91 bool is_resizable; | 93 bool is_resizable; |
| 94 |
| 95 // Source of the event initiating the drag. |
| 96 aura::client::WindowMoveSource source; |
92 }; | 97 }; |
93 | 98 |
94 static gfx::Rect CalculateBoundsForDrag(const Details& details, | 99 static gfx::Rect CalculateBoundsForDrag(const Details& details, |
95 const gfx::Point& location); | 100 const gfx::Point& location); |
96 | 101 |
97 static gfx::Rect AdjustBoundsToGrid(const gfx::Rect& bounds, | 102 static gfx::Rect AdjustBoundsToGrid(const gfx::Rect& bounds, |
98 int grid_size); | 103 int grid_size); |
99 | 104 |
100 static bool IsBottomEdge(int component); | 105 static bool IsBottomEdge(int component); |
101 | 106 |
102 private: | 107 private: |
| 108 // In case of touch resizing, adjusts deltas so that the border is positioned |
| 109 // just under the touch point. |
| 110 static void AdjustDeltaForTouchResize(const Details& details, |
| 111 int* delta_x, |
| 112 int* delta_y); |
| 113 |
103 // Returns the new origin of the window. The arguments are the difference | 114 // Returns the new origin of the window. The arguments are the difference |
104 // between the current location and the initial location. | 115 // between the current location and the initial location. |
105 static gfx::Point GetOriginForDrag(const Details& details, | 116 static gfx::Point GetOriginForDrag(const Details& details, |
106 int delta_x, | 117 int delta_x, |
107 int delta_y); | 118 int delta_y); |
108 | 119 |
109 // Returns the size of the window for the drag. | 120 // Returns the size of the window for the drag. |
110 static gfx::Size GetSizeForDrag(const Details& details, | 121 static gfx::Size GetSizeForDrag(const Details& details, |
111 int* delta_x, | 122 int* delta_x, |
112 int* delta_y); | 123 int* delta_y); |
113 | 124 |
114 // Returns the width of the window. | 125 // Returns the width of the window. |
115 static int GetWidthForDrag(const Details& details, | 126 static int GetWidthForDrag(const Details& details, |
116 int min_width, | 127 int min_width, |
117 int* delta_x); | 128 int* delta_x); |
118 | 129 |
119 // Returns the height of the drag. | 130 // Returns the height of the drag. |
120 static int GetHeightForDrag(const Details& details, | 131 static int GetHeightForDrag(const Details& details, |
121 int min_height, | 132 int min_height, |
122 int* delta_y); | 133 int* delta_y); |
123 }; | 134 }; |
124 | 135 |
125 // Creates a WindowResizer for |window|. This can return a scoped_ptr | 136 // Creates a WindowResizer for |window|. This can return a scoped_ptr |
126 // initialized with NULL if |window| should not be resized nor dragged. | 137 // initialized with NULL if |window| should not be resized nor dragged. |
127 ASH_EXPORT scoped_ptr<WindowResizer> CreateWindowResizer( | 138 ASH_EXPORT scoped_ptr<WindowResizer> CreateWindowResizer( |
128 aura::Window* window, | 139 aura::Window* window, |
129 const gfx::Point& point_in_parent, | 140 const gfx::Point& point_in_parent, |
130 int window_component); | 141 int window_component, |
| 142 aura::client::WindowMoveSource source); |
131 | 143 |
132 } // namespace aura | 144 } // namespace aura |
133 | 145 |
134 #endif // ASH_WM_WINDOW_RESIZER_H_ | 146 #endif // ASH_WM_WINDOW_RESIZER_H_ |
OLD | NEW |