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 UI_GFX_POINT_BASE_H_ | 5 #ifndef UI_GFX_POINT_BASE_H_ |
6 #define UI_GFX_POINT_BASE_H_ | 6 #define UI_GFX_POINT_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 } | 34 } |
35 | 35 |
36 void operator+=(const VectorClass& other) { | 36 void operator+=(const VectorClass& other) { |
37 Offset(other.x(), other.y()); | 37 Offset(other.x(), other.y()); |
38 } | 38 } |
39 | 39 |
40 void operator-=(const VectorClass& other) { | 40 void operator-=(const VectorClass& other) { |
41 Offset(-other.x(), -other.y()); | 41 Offset(-other.x(), -other.y()); |
42 } | 42 } |
43 | 43 |
44 void ClampFromAbove(const Class& other) { | |
sky
2012/11/09 18:23:12
Is there some other name we could use for these th
| |
45 x_ = x_ <= other.x_ ? x_ : other.x_; | |
46 y_ = y_ <= other.y_ ? y_ : other.y_; | |
47 } | |
48 | |
49 void ClampFromBelow(const Class& other) { | |
50 x_ = x_ >= other.x_ ? x_ : other.x_; | |
51 y_ = y_ >= other.y_ ? y_ : other.y_; | |
52 } | |
53 | |
44 Class Add(const VectorClass& other) const WARN_UNUSED_RESULT { | 54 Class Add(const VectorClass& other) const WARN_UNUSED_RESULT { |
45 const Class* orig = static_cast<const Class*>(this); | 55 const Class* orig = static_cast<const Class*>(this); |
46 Class copy = *orig; | 56 Class copy = *orig; |
47 copy.Offset(other.x(), other.y()); | 57 copy.Offset(other.x(), other.y()); |
48 return copy; | 58 return copy; |
49 } | 59 } |
50 | 60 |
51 Class Subtract(const VectorClass& other) const WARN_UNUSED_RESULT { | 61 Class Subtract(const VectorClass& other) const WARN_UNUSED_RESULT { |
52 const Class* orig = static_cast<const Class*>(this); | 62 const Class* orig = static_cast<const Class*>(this); |
53 Class copy = *orig; | 63 Class copy = *orig; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 ~PointBase() {} | 98 ~PointBase() {} |
89 | 99 |
90 private: | 100 private: |
91 Type x_; | 101 Type x_; |
92 Type y_; | 102 Type y_; |
93 }; | 103 }; |
94 | 104 |
95 } // namespace gfx | 105 } // namespace gfx |
96 | 106 |
97 #endif // UI_GFX_POINT_BASE_H_ | 107 #endif // UI_GFX_POINT_BASE_H_ |
OLD | NEW |