Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: ash/common/wm/workspace/multi_window_resize_controller.h

Issue 2035543004: Shuffles and renames ash/common/wm classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: random changes for chrome tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_COMMON_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ 5 #ifndef ASH_COMMON_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
6 #define ASH_COMMON_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ 6 #define ASH_COMMON_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "ash/common/wm/wm_window_observer.h" 12 #include "ash/common/wm_window_observer.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/views/mouse_watcher.h" 16 #include "ui/views/mouse_watcher.h"
17 17
18 namespace views { 18 namespace views {
19 class Widget; 19 class Widget;
20 } 20 }
21 21
22 namespace ash { 22 namespace ash {
23 class MultiWindowResizeControllerTest; 23 class MultiWindowResizeControllerTest;
24 class WorkspaceWindowResizer; 24 class WorkspaceWindowResizer;
25 25
26 // Two directions resizes happen in. 26 // Two directions resizes happen in.
27 enum Direction { 27 enum Direction {
28 TOP_BOTTOM, 28 TOP_BOTTOM,
29 LEFT_RIGHT, 29 LEFT_RIGHT,
30 }; 30 };
31 31
32 // MultiWindowResizeController is responsible for determining and showing a 32 // MultiWindowResizeController is responsible for determining and showing a
33 // widget that allows resizing multiple windows at the same time. 33 // widget that allows resizing multiple windows at the same time.
34 // MultiWindowResizeController is driven by WorkspaceEventFilter. 34 // MultiWindowResizeController is driven by WorkspaceEventFilter.
35 class ASH_EXPORT MultiWindowResizeController 35 class ASH_EXPORT MultiWindowResizeController
36 : public views::MouseWatcherListener, 36 : public views::MouseWatcherListener,
37 public wm::WmWindowObserver { 37 public WmWindowObserver {
38 public: 38 public:
39 MultiWindowResizeController(); 39 MultiWindowResizeController();
40 ~MultiWindowResizeController() override; 40 ~MultiWindowResizeController() override;
41 41
42 // If necessary, shows the resize widget. |window| is the window the mouse 42 // If necessary, shows the resize widget. |window| is the window the mouse
43 // is over, |component| the edge and |point| the location of the mouse. 43 // is over, |component| the edge and |point| the location of the mouse.
44 void Show(wm::WmWindow* window, int component, const gfx::Point& point); 44 void Show(WmWindow* window, int component, const gfx::Point& point);
45 45
46 // Hides the resize widget. 46 // Hides the resize widget.
47 void Hide(); 47 void Hide();
48 48
49 // MouseWatcherListenre overrides: 49 // MouseWatcherListenre overrides:
50 void MouseMovedOutOfHost() override; 50 void MouseMovedOutOfHost() override;
51 51
52 // WindowObserver overrides: 52 // WindowObserver overrides:
53 void OnWindowDestroying(wm::WmWindow* window) override; 53 void OnWindowDestroying(WmWindow* window) override;
54 54
55 private: 55 private:
56 friend class MultiWindowResizeControllerTest; 56 friend class MultiWindowResizeControllerTest;
57 57
58 // Used to track the two resizable windows and direction. 58 // Used to track the two resizable windows and direction.
59 struct ResizeWindows { 59 struct ResizeWindows {
60 ResizeWindows(); 60 ResizeWindows();
61 ResizeWindows(const ResizeWindows& other); 61 ResizeWindows(const ResizeWindows& other);
62 ~ResizeWindows(); 62 ~ResizeWindows();
63 63
64 // Returns true if |other| equals this ResizeWindows. This does *not* 64 // Returns true if |other| equals this ResizeWindows. This does *not*
65 // consider the windows in |other_windows|. 65 // consider the windows in |other_windows|.
66 bool Equals(const ResizeWindows& other) const; 66 bool Equals(const ResizeWindows& other) const;
67 67
68 // Returns true if this ResizeWindows is valid. 68 // Returns true if this ResizeWindows is valid.
69 bool is_valid() const { return window1 && window2; } 69 bool is_valid() const { return window1 && window2; }
70 70
71 // The left/top window to resize. 71 // The left/top window to resize.
72 wm::WmWindow* window1; 72 WmWindow* window1;
73 73
74 // Other window to resize. 74 // Other window to resize.
75 wm::WmWindow* window2; 75 WmWindow* window2;
76 76
77 // Direction 77 // Direction
78 Direction direction; 78 Direction direction;
79 79
80 // Windows after |window2| that are to be resized. Determined at the time 80 // Windows after |window2| that are to be resized. Determined at the time
81 // the resize starts. 81 // the resize starts.
82 std::vector<wm::WmWindow*> other_windows; 82 std::vector<WmWindow*> other_windows;
83 }; 83 };
84 84
85 class ResizeMouseWatcherHost; 85 class ResizeMouseWatcherHost;
86 class ResizeView; 86 class ResizeView;
87 87
88 void CreateMouseWatcher(); 88 void CreateMouseWatcher();
89 89
90 // Returns a ResizeWindows based on the specified arguments. Use is_valid() 90 // Returns a ResizeWindows based on the specified arguments. Use is_valid()
91 // to test if the return value is a valid multi window resize location. 91 // to test if the return value is a valid multi window resize location.
92 ResizeWindows DetermineWindows(wm::WmWindow* window, 92 ResizeWindows DetermineWindows(WmWindow* window,
93 int window_component, 93 int window_component,
94 const gfx::Point& point) const; 94 const gfx::Point& point) const;
95 95
96 // Variant of DetermineWindows() that uses the current location of the mouse 96 // Variant of DetermineWindows() that uses the current location of the mouse
97 // to determine the resize windows. 97 // to determine the resize windows.
98 ResizeWindows DetermineWindowsFromScreenPoint(wm::WmWindow* window) const; 98 ResizeWindows DetermineWindowsFromScreenPoint(WmWindow* window) const;
99 99
100 // Finds a window by edge (one of the constants HitTestCompat. 100 // Finds a window by edge (one of the constants HitTestCompat.
101 wm::WmWindow* FindWindowByEdge(wm::WmWindow* window_to_ignore, 101 WmWindow* FindWindowByEdge(WmWindow* window_to_ignore,
102 int edge_want, 102 int edge_want,
103 int x_in_parent, 103 int x_in_parent,
104 int y_in_parent) const; 104 int y_in_parent) const;
105 105
106 // Returns the first window touching |window|. 106 // Returns the first window touching |window|.
107 wm::WmWindow* FindWindowTouching(wm::WmWindow* window, 107 WmWindow* FindWindowTouching(WmWindow* window, Direction direction) const;
108 Direction direction) const;
109 108
110 // Places any windows touching |start| into |others|. 109 // Places any windows touching |start| into |others|.
111 void FindWindowsTouching(wm::WmWindow* start, 110 void FindWindowsTouching(WmWindow* start,
112 Direction direction, 111 Direction direction,
113 std::vector<wm::WmWindow*>* others) const; 112 std::vector<WmWindow*>* others) const;
114 113
115 // Shows the resizer if the mouse is still at a valid location. This is called 114 // Shows the resizer if the mouse is still at a valid location. This is called
116 // from the |show_timer_|. 115 // from the |show_timer_|.
117 void ShowIfValidMouseLocation(); 116 void ShowIfValidMouseLocation();
118 117
119 // Shows the widget immediately. 118 // Shows the widget immediately.
120 void ShowNow(); 119 void ShowNow();
121 120
122 // Returns true if the widget is showing. 121 // Returns true if the widget is showing.
123 bool IsShowing() const; 122 bool IsShowing() const;
(...skipping 15 matching lines...) Expand all
139 const gfx::Point& location_in_parent) const; 138 const gfx::Point& location_in_parent) const;
140 139
141 // Returns true if |location_in_screen| is over the resize widget. 140 // Returns true if |location_in_screen| is over the resize widget.
142 bool IsOverResizeWidget(const gfx::Point& location_in_screen) const; 141 bool IsOverResizeWidget(const gfx::Point& location_in_screen) const;
143 142
144 // Returns true if |location_in_screen| is over the resize windows 143 // Returns true if |location_in_screen| is over the resize windows
145 // (or the resize widget itself). 144 // (or the resize widget itself).
146 bool IsOverWindows(const gfx::Point& location_in_screen) const; 145 bool IsOverWindows(const gfx::Point& location_in_screen) const;
147 146
148 // Returns true if |location_in_screen| is over |component| in |window|. 147 // Returns true if |location_in_screen| is over |component| in |window|.
149 bool IsOverComponent(wm::WmWindow* window, 148 bool IsOverComponent(WmWindow* window,
150 const gfx::Point& location_in_screen, 149 const gfx::Point& location_in_screen,
151 int component) const; 150 int component) const;
152 151
153 // Windows and direction to resize. 152 // Windows and direction to resize.
154 ResizeWindows windows_; 153 ResizeWindows windows_;
155 154
156 // Timer used before showing. 155 // Timer used before showing.
157 base::OneShotTimer show_timer_; 156 base::OneShotTimer show_timer_;
158 157
159 std::unique_ptr<views::Widget> resize_widget_; 158 std::unique_ptr<views::Widget> resize_widget_;
(...skipping 11 matching lines...) Expand all
171 // |resize_widget_| is non-NULL (ie the widget is showing) we ignore calls 170 // |resize_widget_| is non-NULL (ie the widget is showing) we ignore calls
172 // to Show(). 171 // to Show().
173 std::unique_ptr<views::MouseWatcher> mouse_watcher_; 172 std::unique_ptr<views::MouseWatcher> mouse_watcher_;
174 173
175 DISALLOW_COPY_AND_ASSIGN(MultiWindowResizeController); 174 DISALLOW_COPY_AND_ASSIGN(MultiWindowResizeController);
176 }; 175 };
177 176
178 } // namespace ash 177 } // namespace ash
179 178
180 #endif // ASH_COMMON_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ 179 #endif // ASH_COMMON_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698