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

Unified Diff: ui/gfx/vector3d_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/vector3d_f.h
diff --git a/ui/gfx/vector3d_f.h b/ui/gfx/vector3d_f.h
index a2845f89267880e28b4634df450471e30c520402..49ec90872d9a1f45f9222c944345705642c0baf1 100644
--- a/ui/gfx/vector3d_f.h
+++ b/ui/gfx/vector3d_f.h
@@ -44,6 +44,18 @@ class UI_EXPORT Vector3dF {
void operator+=(const Vector3dF& other) { Add(other); }
void operator-=(const Vector3dF& other) { Subtract(other); }
+ void ClampFromAbove(const Vector3dF& other) {
+ x_ = x_ <= other.x_ ? x_ : other.x_;
+ y_ = y_ <= other.y_ ? y_ : other.y_;
+ z_ = z_ <= other.z_ ? z_ : other.z_;
+ }
+
+ void ClampFromBelow(const Vector3dF& other) {
+ x_ = x_ >= other.x_ ? x_ : other.x_;
+ y_ = y_ >= other.y_ ? y_ : other.y_;
+ z_ = z_ >= other.z_ ? z_ : other.z_;
+ }
+
// Gives the square of the diagonal length of the vector.
double LengthSquared() const;
// Gives the diagonal length of the vector.

Powered by Google App Engine
This is Rietveld 408576698