Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: ui/gfx/vector2d.h

Issue 14367021: Rename ClampToMin and ClampToMax (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/size_unittest.cc ('k') | ui/gfx/vector2d_f.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Defines a simple integer vector class. This class is used to indicate a 5 // Defines a simple integer vector class. This class is used to indicate a
6 // distance in two dimensions between two points. Subtracting two points should 6 // distance in two dimensions between two points. Subtracting two points should
7 // produce a vector, and adding a vector to a point produces the point at the 7 // produce a vector, and adding a vector to a point produces the point at the
8 // vector's distance from the original point. 8 // vector's distance from the original point.
9 9
10 #ifndef UI_GFX_VECTOR2D_H_ 10 #ifndef UI_GFX_VECTOR2D_H_
(...skipping 22 matching lines...) Expand all
33 bool IsZero() const; 33 bool IsZero() const;
34 34
35 // Add the components of the |other| vector to the current vector. 35 // Add the components of the |other| vector to the current vector.
36 void Add(const Vector2d& other); 36 void Add(const Vector2d& other);
37 // Subtract the components of the |other| vector from the current vector. 37 // Subtract the components of the |other| vector from the current vector.
38 void Subtract(const Vector2d& other); 38 void Subtract(const Vector2d& other);
39 39
40 void operator+=(const Vector2d& other) { Add(other); } 40 void operator+=(const Vector2d& other) { Add(other); }
41 void operator-=(const Vector2d& other) { Subtract(other); } 41 void operator-=(const Vector2d& other) { Subtract(other); }
42 42
43 void ClampToMax(const Vector2d& max) { 43 void SetToMin(const Vector2d& other) {
44 x_ = x_ <= max.x_ ? x_ : max.x_; 44 x_ = x_ <= other.x_ ? x_ : other.x_;
45 y_ = y_ <= max.y_ ? y_ : max.y_; 45 y_ = y_ <= other.y_ ? y_ : other.y_;
46 } 46 }
47 47
48 void ClampToMin(const Vector2d& min) { 48 void SetToMax(const Vector2d& other) {
49 x_ = x_ >= min.x_ ? x_ : min.x_; 49 x_ = x_ >= other.x_ ? x_ : other.x_;
50 y_ = y_ >= min.y_ ? y_ : min.y_; 50 y_ = y_ >= other.y_ ? y_ : other.y_;
51 } 51 }
52 52
53 // Gives the square of the diagonal length of the vector. Since this is 53 // Gives the square of the diagonal length of the vector. Since this is
54 // cheaper to compute than Length(), it is useful when you want to compare 54 // cheaper to compute than Length(), it is useful when you want to compare
55 // relative lengths of different vectors without needing the actual lengths. 55 // relative lengths of different vectors without needing the actual lengths.
56 int64 LengthSquared() const; 56 int64 LengthSquared() const;
57 // Gives the diagonal length of the vector. 57 // Gives the diagonal length of the vector.
58 float Length() const; 58 float Length() const;
59 59
60 std::string ToString() const; 60 std::string ToString() const;
(...skipping 21 matching lines...) Expand all
82 82
83 inline Vector2d operator-(const Vector2d& lhs, const Vector2d& rhs) { 83 inline Vector2d operator-(const Vector2d& lhs, const Vector2d& rhs) {
84 Vector2d result = lhs; 84 Vector2d result = lhs;
85 result.Add(-rhs); 85 result.Add(-rhs);
86 return result; 86 return result;
87 } 87 }
88 88
89 } // namespace gfx 89 } // namespace gfx
90 90
91 #endif // UI_GFX_VECTOR2D_H_ 91 #endif // UI_GFX_VECTOR2D_H_
OLDNEW
« no previous file with comments | « ui/gfx/size_unittest.cc ('k') | ui/gfx/vector2d_f.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698