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_WORKSPACE_WINDOW_RESIZER_H_ | 5 #ifndef ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ |
6 #define ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ | 6 #define ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 // Min height we'll force on screen when dragging the caption. | 34 // Min height we'll force on screen when dragging the caption. |
35 // TODO: this should come from a property on the window. | 35 // TODO: this should come from a property on the window. |
36 static const int kMinOnscreenHeight; | 36 static const int kMinOnscreenHeight; |
37 | 37 |
38 virtual ~WorkspaceWindowResizer(); | 38 virtual ~WorkspaceWindowResizer(); |
39 | 39 |
40 static WorkspaceWindowResizer* Create( | 40 static WorkspaceWindowResizer* Create( |
41 aura::Window* window, | 41 aura::Window* window, |
42 const gfx::Point& location, | 42 const gfx::Point& location, |
43 int window_component, | 43 int window_component, |
44 int grid_size, | |
45 const std::vector<aura::Window*>& attached_windows); | 44 const std::vector<aura::Window*>& attached_windows); |
46 | 45 |
47 // Returns true if the drag will result in changing the window in anyway. | 46 // Returns true if the drag will result in changing the window in anyway. |
48 bool is_resizable() const { return details_.is_resizable; } | 47 bool is_resizable() const { return details_.is_resizable; } |
49 | 48 |
50 const gfx::Point& initial_location_in_parent() const { | 49 const gfx::Point& initial_location_in_parent() const { |
51 return details_.initial_location_in_parent; | 50 return details_.initial_location_in_parent; |
52 } | 51 } |
53 | 52 |
54 // Overridden from WindowResizer: | 53 // Overridden from WindowResizer: |
55 virtual void Drag(const gfx::Point& location) OVERRIDE; | 54 virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE; |
56 virtual void CompleteDrag() OVERRIDE; | 55 virtual void CompleteDrag(int event_flags) OVERRIDE; |
57 virtual void RevertDrag() OVERRIDE; | 56 virtual void RevertDrag() OVERRIDE; |
58 | 57 |
59 private: | 58 private: |
60 WorkspaceWindowResizer(const Details& details, | 59 WorkspaceWindowResizer(const Details& details, |
61 const std::vector<aura::Window*>& attached_windows); | 60 const std::vector<aura::Window*>& attached_windows); |
62 | 61 |
63 private: | 62 private: |
64 // Type of snapping. | 63 // Type of snapping. |
65 enum SnapType { | 64 enum SnapType { |
66 // Snap to the left/right edge of the screen. | 65 // Snap to the left/right edge of the screen. |
67 SNAP_LEFT_EDGE, | 66 SNAP_LEFT_EDGE, |
68 SNAP_RIGHT_EDGE, | 67 SNAP_RIGHT_EDGE, |
69 | 68 |
70 // No snap position. | 69 // No snap position. |
71 SNAP_NONE | 70 SNAP_NONE |
72 }; | 71 }; |
73 | 72 |
74 // Returns the final bounds to place the window at. This differs from | 73 // Returns the final bounds to place the window at. This differs from |
75 // the current if there is a grid. | 74 // the current if there is a grid. |
76 gfx::Rect GetFinalBounds(const gfx::Rect& bounds) const; | 75 gfx::Rect GetFinalBounds(const gfx::Rect& bounds, int grid_size) const; |
77 | 76 |
78 // Lays out the attached windows. |bounds| is the bounds of the main window. | 77 // Lays out the attached windows. |bounds| is the bounds of the main window. |
79 void LayoutAttachedWindows(const gfx::Rect& bounds); | 78 void LayoutAttachedWindows(const gfx::Rect& bounds, int grid_size); |
80 | 79 |
81 // Calculates the size (along the primary axis) of the attached windows. | 80 // Calculates the size (along the primary axis) of the attached windows. |
82 // |initial_size| is the initial size of the main window, |current_size| the | 81 // |initial_size| is the initial size of the main window, |current_size| the |
83 // new size of the main window, |start| the position to layout the attached | 82 // new size of the main window, |start| the position to layout the attached |
84 // windows from and |end| the coordinate to position to. | 83 // windows from and |end| the coordinate to position to. |
85 void CalculateAttachedSizes( | 84 void CalculateAttachedSizes( |
86 int initial_size, | 85 int initial_size, |
87 int current_size, | 86 int current_size, |
88 int start, | 87 int start, |
89 int end, | 88 int end, |
| 89 int grid_size, |
90 std::vector<int>* sizes) const; | 90 std::vector<int>* sizes) const; |
91 | 91 |
92 // Adjusts the bounds to enforce that windows are vertically contained in the | 92 // Adjusts the bounds to enforce that windows are vertically contained in the |
93 // work area. | 93 // work area. |
94 void AdjustBoundsForMainWindow(gfx::Rect* bounds) const; | 94 void AdjustBoundsForMainWindow(gfx::Rect* bounds, int grid_size) const; |
95 | 95 |
96 // Snaps the window bounds to the work area edges if necessary. | 96 // Snaps the window bounds to the work area edges if necessary. |
97 void SnapToWorkAreaEdges(const gfx::Rect& work_area, gfx::Rect* bounds) const; | 97 void SnapToWorkAreaEdges( |
| 98 const gfx::Rect& work_area, |
| 99 gfx::Rect* bounds, |
| 100 int grid_size) const; |
98 | 101 |
99 // Returns true if the window touches the bottom edge of the work area. | 102 // Returns true if the window touches the bottom edge of the work area. |
100 bool TouchesBottomOfScreen() const; | 103 bool TouchesBottomOfScreen() const; |
101 | 104 |
102 // Returns a coordinate along the primary axis. Used to share code for | 105 // Returns a coordinate along the primary axis. Used to share code for |
103 // left/right multi window resize and top/bottom resize. | 106 // left/right multi window resize and top/bottom resize. |
104 int PrimaryAxisSize(const gfx::Size& size) const; | 107 int PrimaryAxisSize(const gfx::Size& size) const; |
105 int PrimaryAxisCoordinate(int x, int y) const; | 108 int PrimaryAxisCoordinate(int x, int y) const; |
106 | 109 |
107 // Updates the bounds of the phantom window. | 110 // Updates the bounds of the phantom window. |
108 void UpdatePhantomWindow(const gfx::Point& location, const gfx::Rect& bounds); | 111 void UpdatePhantomWindow( |
| 112 const gfx::Point& location, |
| 113 const gfx::Rect& bounds, |
| 114 int grid_size); |
109 | 115 |
110 // Restacks the windows z-order position so that one of the windows is at the | 116 // Restacks the windows z-order position so that one of the windows is at the |
111 // top of the z-order, and the rest directly underneath it. | 117 // top of the z-order, and the rest directly underneath it. |
112 void RestackWindows(); | 118 void RestackWindows(); |
113 | 119 |
114 // Returns the SnapType for the specified point. SNAP_NONE is used if no | 120 // Returns the SnapType for the specified point. SNAP_NONE is used if no |
115 // snapping should be used. | 121 // snapping should be used. |
116 SnapType GetSnapType(const gfx::Point& location) const; | 122 SnapType GetSnapType(const gfx::Point& location) const; |
117 | 123 |
118 aura::Window* window() const { return details_.window; } | 124 aura::Window* window() const { return details_.window; } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // the screen. | 171 // the screen. |
166 int num_mouse_moves_since_bounds_change_; | 172 int num_mouse_moves_since_bounds_change_; |
167 | 173 |
168 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); | 174 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); |
169 }; | 175 }; |
170 | 176 |
171 } // namespace internal | 177 } // namespace internal |
172 } // namespace ash | 178 } // namespace ash |
173 | 179 |
174 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ | 180 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ |
OLD | NEW |