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

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: rebase 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
« no previous file with comments | « cc/tiled_layer.cc ('k') | ui/gfx/point_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/point_base.h
diff --git a/ui/gfx/point_base.h b/ui/gfx/point_base.h
index ae3342c4dcf1706fc2a9b6b71aab202437d89167..b29c5abfd5364ad37565b6d4b6d5ea33dac2e027 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_;
+ }
+
bool IsOrigin() const {
return x_ == 0 && y_ == 0;
}
« no previous file with comments | « cc/tiled_layer.cc ('k') | ui/gfx/point_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698