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

Unified Diff: ui/gfx/vector2d_f.h

Issue 11361186: ui: Add methods to clamp Sizes, Points, and Vectors from above or below. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: BottomRight Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/vector2d_f.h
diff --git a/ui/gfx/vector2d_f.h b/ui/gfx/vector2d_f.h
index e78c68821b7f2f18d85decfccc30a7ba61a9bddd..6f5bb2294b37a85ce7343fbfd73980d590e0b3fe 100644
--- a/ui/gfx/vector2d_f.h
+++ b/ui/gfx/vector2d_f.h
@@ -38,6 +38,16 @@ class UI_EXPORT Vector2dF {
void operator+=(const Vector2dF& other) { Add(other); }
void operator-=(const Vector2dF& other) { Subtract(other); }
+ void ClampFromAbove(const Vector2dF& other) {
+ x_ = x_ <= other.x_ ? x_ : other.x_;
+ y_ = y_ <= other.y_ ? y_ : other.y_;
+ }
+
+ void ClampFromBelow(const Vector2dF& other) {
+ x_ = x_ >= other.x_ ? x_ : other.x_;
+ y_ = y_ >= other.y_ ? y_ : other.y_;
+ }
+
// Gives the square of the diagonal length of the vector.
double LengthSquared() const;
// Gives the diagonal length of the vector.
« ui/gfx/size_base.h ('K') | « ui/gfx/vector2d.h ('k') | ui/gfx/vector2d_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698