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

Unified Diff: ui/gfx/point_base.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: varnames 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/point_base.h
diff --git a/ui/gfx/point_base.h b/ui/gfx/point_base.h
index 2eed6142d6c3b1a3999d88bf6b7e720118624966..870b2644e4f986bc1d99fbad30e80bbc094eae80 100644
--- a/ui/gfx/point_base.h
+++ b/ui/gfx/point_base.h
@@ -41,6 +41,16 @@ class UI_EXPORT PointBase {
Offset(-vector.x(), -vector.y());
}
+ void ClampToMax(const Class& max) {
+ x_ = x_ <= max.x_ ? x_ : max.x_;
+ y_ = y_ <= max.y_ ? y_ : max.y_;
+ }
+
+ void ClampToMin(const Class& min) {
+ x_ = x_ >= min.x_ ? x_ : min.x_;
+ y_ = y_ >= min.y_ ? y_ : min.y_;
+ }
+
Class Middle(const Class& other) const WARN_UNUSED_RESULT {
return Class((x_ + other.x_) / 2, (y_ + other.y_) / 2);
}
« no previous file with comments | « cc/tiled_layer.cc ('k') | ui/gfx/point_unittest.cc » ('j') | ui/gfx/vector3d_f.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698