Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ | |
| 6 #define ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "ash/ash_export.h" | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/timer.h" | |
| 13 #include "ui/gfx/rect.h" | |
| 14 #include "ui/views/mouse_watcher.h" | |
| 15 | |
| 16 namespace aura { | |
| 17 class Window; | |
| 18 } | |
| 19 | |
| 20 namespace views { | |
| 21 class Widget; | |
| 22 } | |
| 23 | |
| 24 namespace ash { | |
| 25 namespace internal { | |
| 26 | |
| 27 class WorkspaceWindowResizer; | |
| 28 | |
| 29 // Two directions resizes happen in. | |
| 30 enum Direction { | |
| 31 TOP_BOTTOM, | |
| 32 LEFT_RIGHT, | |
| 33 }; | |
| 34 | |
| 35 // MultiWindowResizeController is responsible for determining and showing a | |
| 36 // widget that allows resizing multiple windows at the same time. | |
| 37 // MultiWindowResizeController is driven by WorkspaceEventFilter. | |
| 38 class ASH_EXPORT MultiWindowResizeController : | |
| 39 public views::MouseWatcherListener { | |
| 40 public: | |
| 41 MultiWindowResizeController(); | |
| 42 ~MultiWindowResizeController(); | |
|
Ben Goodger (Google)
2012/03/06 15:40:45
virtual
| |
| 43 | |
| 44 // If necessary, shows the resize widget. |window| is the window the mouse | |
| 45 // is over, |component| the edge and |point| the location of the mouse. | |
| 46 void Show(aura::Window* window, int component, const gfx::Point& point); | |
| 47 | |
| 48 // Hides the resize widget. | |
| 49 void Hide(); | |
| 50 | |
| 51 void set_grid_size(int grid_size) { grid_size_ = grid_size; } | |
| 52 | |
| 53 // MouseWatcherListenre overrides: | |
| 54 virtual void MouseMovedOutOfHost() OVERRIDE; | |
| 55 | |
| 56 private: | |
| 57 // Used to track the two resizable windows and direction. | |
| 58 struct ResizeWindows { | |
| 59 ResizeWindows(); | |
| 60 ~ResizeWindows(); | |
| 61 | |
| 62 // Returns true if |other| equals this ResizeWindows. | |
| 63 bool Equals(const ResizeWindows& other) const; | |
| 64 | |
| 65 // Returns true if this ResizeWindows is valid. | |
| 66 bool is_valid() const { return window1 && window2; } | |
| 67 | |
| 68 // The left/top window to resize. | |
| 69 aura::Window* window1; | |
| 70 | |
| 71 // Other window to resize. | |
| 72 aura::Window* window2; | |
| 73 | |
| 74 // Direction | |
| 75 Direction direction; | |
| 76 }; | |
| 77 | |
| 78 class ResizeMouseWatcherHost; | |
| 79 class ResizeView; | |
| 80 | |
| 81 // Returns a ResizeWindows based on the specified arguments. Use is_valid() | |
| 82 // to test if the return value is a valid multi window resize location. | |
| 83 ResizeWindows DetermineWindows(aura::Window* window, | |
| 84 int window_component, | |
| 85 const gfx::Point& point) const; | |
| 86 | |
| 87 // Finds a window by edge (one of the constants HitTestCompat. | |
| 88 aura::Window* FindWindowByEdge(aura::Window* window_to_ignore, | |
| 89 int edge_want, | |
| 90 int x, | |
| 91 int y) const; | |
| 92 | |
| 93 // Shows the widget immediately. | |
| 94 void ShowNow(); | |
| 95 | |
| 96 // Returns true if the widget is showing. | |
| 97 bool IsShowing() const; | |
| 98 | |
| 99 // Initiates a resize. | |
| 100 void StartResize(const gfx::Point& screen_location); | |
| 101 | |
| 102 // Resizes to the new location. | |
| 103 void Resize(const gfx::Point& screen_location); | |
| 104 | |
| 105 // Completes the resize. | |
| 106 void CompleteResize(); | |
| 107 | |
| 108 // Cancels the resize. | |
| 109 void CancelResize(); | |
| 110 | |
| 111 // Returns the bounds for the resize widget. | |
| 112 gfx::Rect CalculateResizeWidgetBounds() const; | |
| 113 | |
| 114 // Returns true if |screen_location| is over the resize windows (or the resize | |
| 115 // widget itself). | |
| 116 bool IsOverWindows(const gfx::Point& screen_location) const; | |
| 117 | |
| 118 // Returns true if |screen_location| is over |window|. | |
| 119 bool IsOverWindow(aura::Window* window, | |
| 120 const gfx::Point& screen_location) const; | |
| 121 | |
| 122 // Windows and direction to resize. | |
| 123 ResizeWindows windows_; | |
| 124 | |
| 125 // Timer used before showing. | |
| 126 base::OneShotTimer<MultiWindowResizeController> show_timer_; | |
| 127 | |
| 128 views::Widget* resize_widget_; | |
| 129 | |
| 130 // If non-null we're in a resize loop. | |
| 131 scoped_ptr<WorkspaceWindowResizer> window_resizer_; | |
| 132 | |
| 133 // Bounds the widget was last shown at. | |
| 134 gfx::Rect show_bounds_; | |
| 135 | |
| 136 // Size of the grid. | |
| 137 int grid_size_; | |
| 138 | |
| 139 DISALLOW_COPY_AND_ASSIGN(MultiWindowResizeController); | |
| 140 }; | |
| 141 | |
| 142 } // namespace internal | |
| 143 } // namespace ash | |
| 144 | |
| 145 #endif // ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ | |
| OLD | NEW |