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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 // |grid_size|. | 41 // |grid_size|. |
42 static int AlignToGrid(int location, int grid_size); | 42 static int AlignToGrid(int location, int grid_size); |
43 | 43 |
44 // Variant of AlignToGrid that rounds up. | 44 // Variant of AlignToGrid that rounds up. |
45 static int AlignToGridRoundUp(int location, int grid_size); | 45 static int AlignToGridRoundUp(int location, int grid_size); |
46 | 46 |
47 // Variant of AlignToGrid that rounds down. | 47 // Variant of AlignToGrid that rounds down. |
48 static int AlignToGridRoundDown(int location, int grid_size); | 48 static int AlignToGridRoundDown(int location, int grid_size); |
49 | 49 |
50 // Invoked to drag/move/resize the window. |location| is in the coordinates | 50 // Invoked to drag/move/resize the window. |location| is in the coordinates |
51 // of the window supplied to the constructor. | 51 // of the window supplied to the constructor. |event_flags| is the event |
52 virtual void Drag(const gfx::Point& location) = 0; | 52 // flags from mouse event. |
sky
2012/04/16 21:16:30
'from mouse' -> 'from the'
jennyz
2012/04/16 23:09:40
Done.
| |
53 virtual void Drag(const gfx::Point& location, int event_flags) = 0; | |
53 | 54 |
54 // Invoked to complete the drag. | 55 // Invoked to complete the drag. |
55 virtual void CompleteDrag() = 0; | 56 virtual void CompleteDrag(int event_flags) = 0; |
56 | 57 |
57 // Reverts the drag. | 58 // Reverts the drag. |
58 virtual void RevertDrag() = 0; | 59 virtual void RevertDrag() = 0; |
59 | 60 |
60 protected: | 61 protected: |
61 struct Details { | 62 struct Details { |
62 Details(); | 63 Details(); |
63 Details(aura::Window* window, | 64 Details(aura::Window* window, |
64 const gfx::Point& location, | 65 const gfx::Point& location, |
65 int window_component, | 66 int window_component); |
66 int grid_size); | |
67 ~Details(); | 67 ~Details(); |
68 | 68 |
69 // The window we're resizing. | 69 // The window we're resizing. |
70 aura::Window* window; | 70 aura::Window* window; |
71 | 71 |
72 // Initial bounds of the window. | 72 // Initial bounds of the window. |
73 gfx::Rect initial_bounds; | 73 gfx::Rect initial_bounds; |
74 | 74 |
75 // Location passed to the constructor, in |window->parent()|'s coordinates. | 75 // Location passed to the constructor, in |window->parent()|'s coordinates. |
76 gfx::Point initial_location_in_parent; | 76 gfx::Point initial_location_in_parent; |
77 | 77 |
78 // The component the user pressed on. | 78 // The component the user pressed on. |
79 int window_component; | 79 int window_component; |
80 | 80 |
81 // Bitmask of the |kBoundsChange_| constants. | 81 // Bitmask of the |kBoundsChange_| constants. |
82 int bounds_change; | 82 int bounds_change; |
83 | 83 |
84 // Bitmask of the |kBoundsChangeDirection_| constants. | 84 // Bitmask of the |kBoundsChangeDirection_| constants. |
85 int position_change_direction; | 85 int position_change_direction; |
86 | 86 |
87 // Bitmask of the |kBoundsChangeDirection_| constants. | 87 // Bitmask of the |kBoundsChangeDirection_| constants. |
88 int size_change_direction; | 88 int size_change_direction; |
89 | 89 |
90 // Will the drag actually modify the window? | 90 // Will the drag actually modify the window? |
91 bool is_resizable; | 91 bool is_resizable; |
92 | |
93 // Size of the grid. | |
94 int grid_size; | |
95 }; | 92 }; |
96 | 93 |
97 static gfx::Rect CalculateBoundsForDrag( | 94 static gfx::Rect CalculateBoundsForDrag( |
98 const Details& details, | 95 const Details& details, |
99 const gfx::Point& location); | 96 const gfx::Point& location, |
97 int grid_size); | |
100 | 98 |
101 static gfx::Rect AdjustBoundsToGrid(const gfx::Rect& bounds, | 99 static gfx::Rect AdjustBoundsToGrid(const gfx::Rect& bounds, |
102 int grid_size); | 100 int grid_size); |
103 | 101 |
104 static bool IsBottomEdge(int component); | 102 static bool IsBottomEdge(int component); |
105 | 103 |
106 private: | 104 private: |
107 // Returns the new origin of the window. The arguments are the difference | 105 // Returns the new origin of the window. The arguments are the difference |
108 // between the current location and the initial location. | 106 // between the current location and the initial location. |
109 static gfx::Point GetOriginForDrag(const Details& details, | 107 static gfx::Point GetOriginForDrag(const Details& details, |
110 int delta_x, | 108 int delta_x, |
111 int delta_y); | 109 int delta_y); |
112 | 110 |
113 // Returns the size of the window for the drag. | 111 // Returns the size of the window for the drag. |
114 static gfx::Size GetSizeForDrag(const Details& details, | 112 static gfx::Size GetSizeForDrag(const Details& details, |
115 int* delta_x, | 113 int* delta_x, |
116 int* delta_y); | 114 int* delta_y, |
115 int grid_size); | |
117 | 116 |
118 // Returns the width of the window. | 117 // Returns the width of the window. |
119 static int GetWidthForDrag(const Details& details, | 118 static int GetWidthForDrag(const Details& details, |
120 int min_width, | 119 int min_width, |
121 int* delta_x); | 120 int* delta_x, |
121 int grid_size); | |
122 | 122 |
123 // Returns the height of the drag. | 123 // Returns the height of the drag. |
124 static int GetHeightForDrag(const Details& details, | 124 static int GetHeightForDrag(const Details& details, |
125 int min_height, | 125 int min_height, |
126 int* delta_y); | 126 int* delta_y, |
127 int grid_size); | |
127 }; | 128 }; |
128 | 129 |
129 } // namespace aura | 130 } // namespace aura |
130 | 131 |
131 #endif // ASH_WM_WINDOW_RESIZER_H_ | 132 #endif // ASH_WM_WINDOW_RESIZER_H_ |
OLD | NEW |