| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 const gfx::Point& start, | 31 const gfx::Point& start, |
| 32 Edge edge, | 32 Edge edge, |
| 33 int grid_size); | 33 int grid_size); |
| 34 | 34 |
| 35 // Updates the target bounds based on a mouse move. | 35 // Updates the target bounds based on a mouse move. |
| 36 void Update(const gfx::Point& location); | 36 void Update(const gfx::Point& location); |
| 37 | 37 |
| 38 // Bounds to position the window at. | 38 // Bounds to position the window at. |
| 39 const gfx::Rect& target_bounds() const { return target_bounds_; } | 39 const gfx::Rect& target_bounds() const { return target_bounds_; } |
| 40 | 40 |
| 41 // Returns the appropriate snap bounds (e.g. if a window is already snapped, |
| 42 // then it returns the next snap-bounds). |
| 43 gfx::Rect GetSnapBounds(const gfx::Rect& bounds); |
| 44 |
| 41 private: | 45 private: |
| 42 // Calculates the amount to increment by. This returns one of -1, 0 or 1 and | 46 // Calculates the amount to increment by. This returns one of -1, 0 or 1 and |
| 43 // is intended to by applied to |percent_index_|. |x| is the current | 47 // is intended to by applied to |percent_index_|. |x| is the current |
| 44 // x-coordinate, and |reference_x| is used to determine whether to increase | 48 // x-coordinate, and |reference_x| is used to determine whether to increase |
| 45 // or decrease the position. It's one of |last_adjust_x_| or |last_update_x_|. | 49 // or decrease the position. It's one of |last_adjust_x_| or |last_update_x_|. |
| 46 int CalculateIncrement(int x, int reference_x) const; | 50 int CalculateIncrement(int x, int reference_x) const; |
| 47 | 51 |
| 48 // Changes the bounds. |x| is the current x-coordinate and |delta| the amount | 52 // Changes the bounds. |x| is the current x-coordinate and |delta| the amount |
| 49 // to increase by. |delta| comes from CalculateIncrement() and is applied | 53 // to increase by. |delta| comes from CalculateIncrement() and is applied |
| 50 // to |percent_index_|. | 54 // to |percent_index_|. |
| 51 void ChangeBounds(int x, int delta); | 55 void ChangeBounds(int x, int delta); |
| 52 | 56 |
| 53 // Returns the target bounds based on the edge and |percent_index_|. | 57 // Returns the target bounds based on the edge and |percent_index_|. |
| 54 gfx::Rect GetTargetBounds() const; | 58 gfx::Rect GetTargetBounds() const; |
| 55 | 59 |
| 60 gfx::Rect GetTargetBoundsForPercent(int percent_index) const; |
| 61 |
| 56 // Returns true if the specified point is along the edge of the screen. | 62 // Returns true if the specified point is along the edge of the screen. |
| 57 bool AlongEdge(int x) const; | 63 bool AlongEdge(int x) const; |
| 58 | 64 |
| 59 // Window being snapped. | 65 // Window being snapped. |
| 60 aura::Window* window_; | 66 aura::Window* window_; |
| 61 | 67 |
| 62 const Edge edge_; | 68 const Edge edge_; |
| 63 const int grid_size_; | 69 const int grid_size_; |
| 64 | 70 |
| 65 // Current target bounds for the snap. | 71 // Current target bounds for the snap. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 81 // X-coordinate last supplied to Update(). | 87 // X-coordinate last supplied to Update(). |
| 82 int last_update_x_; | 88 int last_update_x_; |
| 83 | 89 |
| 84 DISALLOW_COPY_AND_ASSIGN(SnapSizer); | 90 DISALLOW_COPY_AND_ASSIGN(SnapSizer); |
| 85 }; | 91 }; |
| 86 | 92 |
| 87 } // namespace internal | 93 } // namespace internal |
| 88 } // namespace ash | 94 } // namespace ash |
| 89 | 95 |
| 90 #endif // ASH_WM_WORKSPACE_SNAP_SIZER_H_ | 96 #endif // ASH_WM_WORKSPACE_SNAP_SIZER_H_ |
| OLD | NEW |