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 "ash/wm/window_resizer.h" | 9 #include "ash/wm/window_resizer.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 | 11 |
12 namespace ash { | 12 namespace ash { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
| 15 class RootWindowEventFilter; |
| 16 |
15 // WindowResizer implementation for workspaces. This enforces that windows are | 17 // WindowResizer implementation for workspaces. This enforces that windows are |
16 // not allowed to vertically move or resize outside of the work area. As windows | 18 // not allowed to vertically move or resize outside of the work area. As windows |
17 // are moved outside the work area they are shrunk. We remember the height of | 19 // are moved outside the work area they are shrunk. We remember the height of |
18 // the window before it was moved so that if the window is again moved up we | 20 // the window before it was moved so that if the window is again moved up we |
19 // attempt to restore the old height. | 21 // attempt to restore the old height. |
20 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer { | 22 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer { |
21 public: | 23 public: |
22 WorkspaceWindowResizer(aura::Window* window, | |
23 const gfx::Point& location, | |
24 int window_component, | |
25 int grid_size); | |
26 virtual ~WorkspaceWindowResizer(); | 24 virtual ~WorkspaceWindowResizer(); |
27 | 25 |
28 protected: | 26 // Creates a new WorkspaceWindowResizer. The caller takes ownership of the |
29 // WindowResizer overrides: | 27 // returned object. Returns NULL if not resizable. |
30 virtual gfx::Rect GetBoundsForDrag(const gfx::Point& location) OVERRIDE; | 28 static WorkspaceWindowResizer* Create( |
31 virtual gfx::Rect GetFinalBounds() OVERRIDE; | 29 aura::Window* window, |
| 30 const gfx::Point& location, |
| 31 int window_component, |
| 32 int grid_size); |
| 33 |
| 34 // Returns true if the drag will result in changing the window in anyway. |
| 35 bool is_resizable() const { return details_.is_resizable; } |
| 36 |
| 37 const gfx::Point& initial_location_in_parent() const { |
| 38 return details_.initial_location_in_parent; |
| 39 } |
| 40 |
| 41 // Overridden from WindowResizer: |
| 42 virtual void Drag(const gfx::Point& location); |
| 43 virtual void CompleteDrag(); |
| 44 virtual void RevertDrag(); |
32 | 45 |
33 private: | 46 private: |
34 // Used to maintain the height of the window before we started collapsing it. | 47 explicit WorkspaceWindowResizer(const Details& details); |
35 static void SetHeightBeforeObscured(aura::Window* window, int height); | |
36 static void ClearHeightBeforeObscured(aura::Window* window); | |
37 static int GetHeightBeforeObscured(aura::Window* window); | |
38 | 48 |
39 // Adjusts the bounds to enforce that windows are vertically contained in the | 49 // Adjusts the bounds to enforce that windows are vertically contained in the |
40 // work area. | 50 // work area. |
41 void AdjustBounds(gfx::Rect* bounds) const; | 51 void AdjustBoundsForMainWindow(gfx::Rect* bounds) const; |
| 52 void AdjustBoundsForWindow(const gfx::Rect& work_area, |
| 53 aura::Window* window, |
| 54 gfx::Rect* bounds) const; |
| 55 |
| 56 // Clears the cached height of the window being dragged. |
| 57 void ClearCachedHeights(); |
42 | 58 |
43 // Returns true if the window touches the bottom of the work area. | 59 // Returns true if the window touches the bottom of the work area. |
44 bool WindowTouchesBottomOfScreen() const; | 60 bool TouchesBottomOfScreen() const; |
| 61 |
| 62 aura::Window* window() const { return details_.window; } |
| 63 |
| 64 const Details details_; |
45 | 65 |
46 // True if the window size (height) should be constrained. | 66 // True if the window size (height) should be constrained. |
47 const bool constrain_size_; | 67 const bool constrain_size_; |
48 | 68 |
| 69 // Set to true once Drag() is invoked and the bounds of the window change. |
| 70 bool did_move_or_resize_; |
| 71 |
| 72 internal::RootWindowEventFilter* root_filter_; |
| 73 |
49 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); | 74 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); |
50 }; | 75 }; |
51 | 76 |
52 } // namespace internal | 77 } // namespace internal |
53 } // namespace ash | 78 } // namespace ash |
54 | 79 |
55 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ | 80 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ |
OLD | NEW |