| 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_SNAP_SIZER_H_ | 5 #ifndef ASH_WM_WORKSPACE_SNAP_SIZER_H_ |
| 6 #define ASH_WM_WORKSPACE_SNAP_SIZER_H_ | 6 #define ASH_WM_WORKSPACE_SNAP_SIZER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
| 12 | 12 |
| 13 namespace aura { | 13 namespace aura { |
| 14 class Window; | 14 class Window; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace ash { | 17 namespace ash { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 // SnapSizer is responsible for determining the resulting bounds of a window | 20 // SnapSizer is responsible for determining the resulting bounds of a window |
| 21 // that is being snapped to the left or right side of the screen. | 21 // that is being snapped to the left or right side of the screen. |
| 22 // The bounds used in this class are in the container's coordinates. | 22 // The bounds used in this class are in the container's coordinates. |
| 23 class ASH_EXPORT SnapSizer { | 23 class ASH_EXPORT SnapSizer { |
| 24 public: | 24 public: |
| 25 enum Edge { | 25 enum Edge { |
| 26 LEFT_EDGE, | 26 LEFT_EDGE, |
| 27 RIGHT_EDGE | 27 RIGHT_EDGE |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 SnapSizer(aura::Window* window, | 30 SnapSizer(aura::Window* window, const gfx::Point& start, Edge edge); |
| 31 const gfx::Point& start, | |
| 32 Edge edge, | |
| 33 int grid_size); | |
| 34 | 31 |
| 35 // Updates the target bounds based on a mouse move. | 32 // Updates the target bounds based on a mouse move. |
| 36 void Update(const gfx::Point& location); | 33 void Update(const gfx::Point& location); |
| 37 | 34 |
| 38 // Bounds to position the window at. | 35 // Bounds to position the window at. |
| 39 const gfx::Rect& target_bounds() const { return target_bounds_; } | 36 const gfx::Rect& target_bounds() const { return target_bounds_; } |
| 40 | 37 |
| 41 // Returns the appropriate snap bounds (e.g. if a window is already snapped, | 38 // Returns the appropriate snap bounds (e.g. if a window is already snapped, |
| 42 // then it returns the next snap-bounds). | 39 // then it returns the next snap-bounds). |
| 43 gfx::Rect GetSnapBounds(const gfx::Rect& bounds); | 40 gfx::Rect GetSnapBounds(const gfx::Rect& bounds); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 64 // Returns the target bounds based on the edge and |size_index_|. | 61 // Returns the target bounds based on the edge and |size_index_|. |
| 65 gfx::Rect GetTargetBounds() const; | 62 gfx::Rect GetTargetBounds() const; |
| 66 | 63 |
| 67 // Returns true if the specified point is along the edge of the screen. | 64 // Returns true if the specified point is along the edge of the screen. |
| 68 bool AlongEdge(int x) const; | 65 bool AlongEdge(int x) const; |
| 69 | 66 |
| 70 // Window being snapped. | 67 // Window being snapped. |
| 71 aura::Window* window_; | 68 aura::Window* window_; |
| 72 | 69 |
| 73 const Edge edge_; | 70 const Edge edge_; |
| 74 const int grid_size_; | |
| 75 | 71 |
| 76 // Current target bounds for the snap. | 72 // Current target bounds for the snap. |
| 77 gfx::Rect target_bounds_; | 73 gfx::Rect target_bounds_; |
| 78 | 74 |
| 79 // Time Update() was last invoked. | 75 // Time Update() was last invoked. |
| 80 base::TimeTicks time_last_update_; | 76 base::TimeTicks time_last_update_; |
| 81 | 77 |
| 82 // Index into |kSizes| that dictates the width of the screen the target | 78 // Index into |kSizes| that dictates the width of the screen the target |
| 83 // bounds should get. | 79 // bounds should get. |
| 84 int size_index_; | 80 int size_index_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 96 // X-coordinate last supplied to Update(). | 92 // X-coordinate last supplied to Update(). |
| 97 int last_update_x_; | 93 int last_update_x_; |
| 98 | 94 |
| 99 DISALLOW_COPY_AND_ASSIGN(SnapSizer); | 95 DISALLOW_COPY_AND_ASSIGN(SnapSizer); |
| 100 }; | 96 }; |
| 101 | 97 |
| 102 } // namespace internal | 98 } // namespace internal |
| 103 } // namespace ash | 99 } // namespace ash |
| 104 | 100 |
| 105 #endif // ASH_WM_WORKSPACE_SNAP_SIZER_H_ | 101 #endif // ASH_WM_WORKSPACE_SNAP_SIZER_H_ |
| OLD | NEW |