| 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 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/wm/window_resizer.h" | 10 #include "ash/wm/window_resizer.h" |
| 11 #include "ash/wm/workspace/magnetism_matcher.h" | 11 #include "ash/wm/workspace/magnetism_matcher.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "ui/aura/window_tracker.h" | 15 #include "ui/aura/window_tracker.h" |
| 16 | 16 |
| 17 namespace ash { | 17 namespace ash { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 class PhantomWindowController; | 20 class PhantomWindowController; |
| 21 class SnapSizer; | 21 class SnapSizer; |
| 22 class WindowSize; | 22 class WindowSize; |
| 23 class WorkspaceWindowResizerTest; |
| 23 | 24 |
| 24 // WindowResizer implementation for workspaces. This enforces that windows are | 25 // WindowResizer implementation for workspaces. This enforces that windows are |
| 25 // not allowed to vertically move or resize outside of the work area. As windows | 26 // not allowed to vertically move or resize outside of the work area. As windows |
| 26 // are moved outside the work area they are shrunk. We remember the height of | 27 // are moved outside the work area they are shrunk. We remember the height of |
| 27 // the window before it was moved so that if the window is again moved up we | 28 // the window before it was moved so that if the window is again moved up we |
| 28 // attempt to restore the old height. | 29 // attempt to restore the old height. |
| 29 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer { | 30 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer { |
| 30 public: | 31 public: |
| 31 // When dragging an attached window this is the min size we'll make sure is | 32 // When dragging an attached window this is the min size we'll make sure is |
| 32 // visible. In the vertical direction we take the max of this and that from | 33 // visible. In the vertical direction we take the max of this and that from |
| 33 // the delegate. | 34 // the delegate. |
| 34 static const int kMinOnscreenSize; | 35 static const int kMinOnscreenSize; |
| 35 | 36 |
| 36 // Min height we'll force on screen when dragging the caption. | 37 // Min height we'll force on screen when dragging the caption. |
| 37 // TODO: this should come from a property on the window. | 38 // TODO: this should come from a property on the window. |
| 38 static const int kMinOnscreenHeight; | 39 static const int kMinOnscreenHeight; |
| 39 | 40 |
| 40 // Snap region when dragging close to the edges. That is, as the window gets | 41 // Snap region when dragging close to the edges. That is, as the window gets |
| 41 // this close to an edge of the screen it snaps to the edge. | 42 // this close to an edge of the screen it snaps to the edge. |
| 42 static const int kScreenEdgeInset; | 43 static const int kScreenEdgeInset; |
| 43 | 44 |
| 44 virtual ~WorkspaceWindowResizer(); | 45 virtual ~WorkspaceWindowResizer(); |
| 45 | 46 |
| 46 static WorkspaceWindowResizer* Create( | 47 static WorkspaceWindowResizer* Create( |
| 47 aura::Window* window, | 48 aura::Window* window, |
| 48 const gfx::Point& location_in_parent, | 49 const gfx::Point& location_in_parent, |
| 49 int window_component, | 50 int window_component, |
| 50 const std::vector<aura::Window*>& attached_windows); | 51 const std::vector<aura::Window*>& attached_windows); |
| 51 | 52 |
| 52 // Overridden from WindowResizer: | 53 // WindowResizer: |
| 53 virtual void Drag(const gfx::Point& location_in_parent, | 54 virtual void Drag(const gfx::Point& location_in_parent, |
| 54 int event_flags) OVERRIDE; | 55 int event_flags) OVERRIDE; |
| 55 virtual void CompleteDrag(int event_flags) OVERRIDE; | 56 virtual void CompleteDrag(int event_flags) OVERRIDE; |
| 56 virtual void RevertDrag() OVERRIDE; | 57 virtual void RevertDrag() OVERRIDE; |
| 57 virtual aura::Window* GetTarget() OVERRIDE; | 58 virtual aura::Window* GetTarget() OVERRIDE; |
| 58 | 59 |
| 59 const gfx::Point& GetInitialLocationInParentForTest() const { | 60 private: |
| 60 return details_.initial_location_in_parent; | 61 friend class internal::WorkspaceWindowResizerTest; |
| 61 } | |
| 62 | 62 |
| 63 private: | 63 // WindowResizer: |
| 64 virtual const gfx::Point& GetInitialLocationForTest() const OVERRIDE; |
| 65 |
| 64 WorkspaceWindowResizer(const Details& details, | 66 WorkspaceWindowResizer(const Details& details, |
| 65 const std::vector<aura::Window*>& attached_windows); | 67 const std::vector<aura::Window*>& attached_windows); |
| 66 | 68 |
| 67 private: | 69 private: |
| 68 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom); | 70 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom); |
| 69 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize); | 71 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize); |
| 70 | 72 |
| 71 // Type of snapping. | 73 // Type of snapping. |
| 72 enum SnapType { | 74 enum SnapType { |
| 73 // Snap to the left/right edge of the screen. | 75 // Snap to the left/right edge of the screen. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // should attach. | 210 // should attach. |
| 209 MatchedEdge magnetism_edge_; | 211 MatchedEdge magnetism_edge_; |
| 210 | 212 |
| 211 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); | 213 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); |
| 212 }; | 214 }; |
| 213 | 215 |
| 214 } // namespace internal | 216 } // namespace internal |
| 215 } // namespace ash | 217 } // namespace ash |
| 216 | 218 |
| 217 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ | 219 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ |
| OLD | NEW |