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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // Used to indicate which direction the resize occurs in. | 32 // Used to indicate which direction the resize occurs in. |
33 static const int kBoundsChangeDirection_None; | 33 static const int kBoundsChangeDirection_None; |
34 static const int kBoundsChangeDirection_Horizontal; | 34 static const int kBoundsChangeDirection_Horizontal; |
35 static const int kBoundsChangeDirection_Vertical; | 35 static const int kBoundsChangeDirection_Vertical; |
36 | 36 |
37 WindowResizer(aura::Window* window, | 37 WindowResizer(aura::Window* window, |
38 const gfx::Point& location, | 38 const gfx::Point& location, |
39 int window_component, | 39 int window_component, |
40 int grid_size); | 40 int grid_size); |
41 ~WindowResizer(); | 41 virtual ~WindowResizer(); |
42 | 42 |
43 // Returns a bitmask of the kBoundsChange_ values. | 43 // Returns a bitmask of the kBoundsChange_ values. |
44 static int GetBoundsChangeForWindowComponent(int component); | 44 static int GetBoundsChangeForWindowComponent(int component); |
45 | 45 |
46 // Returns a location >= |location| that is aligned to fall on increments of | 46 // Returns a location >= |location| that is aligned to fall on increments of |
47 // |grid_size|. | 47 // |grid_size|. |
48 static int AlignToGrid(int location, int grid_size); | 48 static int AlignToGrid(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. |
52 void Drag(const gfx::Point& location); | 52 void Drag(const gfx::Point& location); |
53 | 53 |
54 // Invoked to complete the drag. | 54 // Invoked to complete the drag. |
55 void CompleteDrag(); | 55 void CompleteDrag(); |
56 | 56 |
57 // Returns true if the drag will result in changing the window in anyway. | 57 // Returns true if the drag will result in changing the window in anyway. |
58 bool is_resizable() const { return is_resizable_; } | 58 bool is_resizable() const { return is_resizable_; } |
59 | 59 |
60 // See description above members for details. | 60 // See description above members for details. |
61 const gfx::Rect& initial_bounds() const { return initial_bounds_; } | 61 const gfx::Rect& initial_bounds() const { return initial_bounds_; } |
62 const gfx::Point& initial_location_in_parent() const { | 62 const gfx::Point& initial_location_in_parent() const { |
63 return initial_location_in_parent_; | 63 return initial_location_in_parent_; |
64 } | 64 } |
65 int window_component() const { return window_component_; } | 65 int window_component() const { return window_component_; } |
66 aura::Window* window() const { return window_; } | 66 aura::Window* window() const { return window_; } |
| 67 int grid_size() const { return grid_size_; } |
| 68 bool did_move_or_resize() const { return did_move_or_resize_; } |
| 69 int bounds_change() const { return bounds_change_; } |
| 70 |
| 71 protected: |
| 72 // Returns the bounds to give to the window once the mouse has moved to |
| 73 // |location|. |
| 74 virtual gfx::Rect GetBoundsForDrag(const gfx::Point& location); |
| 75 |
| 76 // Returns the final bounds. This differs from current bounds if a grid_size |
| 77 // was specified. |
| 78 virtual gfx::Rect GetFinalBounds(); |
67 | 79 |
68 private: | 80 private: |
69 // Returns the bounds to give to the window once the mouse has moved to | |
70 // |location|. | |
71 gfx::Rect GetBoundsForDrag(const gfx::Point& location); | |
72 | |
73 // Returns the new origin of the window. The arguments are the difference | 81 // Returns the new origin of the window. The arguments are the difference |
74 // between the current location and the initial location. | 82 // between the current location and the initial location. |
75 gfx::Point GetOriginForDrag(int delta_x, int delta_y) const; | 83 gfx::Point GetOriginForDrag(int delta_x, int delta_y) const; |
76 | 84 |
77 // Returns the size of the window for the drag. | 85 // Returns the size of the window for the drag. |
78 gfx::Size GetSizeForDrag(int* delta_x, int* delta_y) const; | 86 gfx::Size GetSizeForDrag(int* delta_x, int* delta_y) const; |
79 | 87 |
80 // Returns the width of the window. | 88 // Returns the width of the window. |
81 int GetWidthForDrag(int min_width, int* delta_x) const; | 89 int GetWidthForDrag(int min_width, int* delta_x) const; |
82 | 90 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 bool did_move_or_resize_; | 122 bool did_move_or_resize_; |
115 | 123 |
116 internal::RootWindowEventFilter* root_filter_; | 124 internal::RootWindowEventFilter* root_filter_; |
117 | 125 |
118 DISALLOW_COPY_AND_ASSIGN(WindowResizer); | 126 DISALLOW_COPY_AND_ASSIGN(WindowResizer); |
119 }; | 127 }; |
120 | 128 |
121 } // namespace aura | 129 } // namespace aura |
122 | 130 |
123 #endif // ASH_WM_WINDOW_RESIZER_H_ | 131 #endif // ASH_WM_WINDOW_RESIZER_H_ |
OLD | NEW |