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

Unified Diff: ui/gfx/size_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 | « ui/gfx/point_unittest.cc ('k') | ui/gfx/size_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/size_base.h
diff --git a/ui/gfx/size_base.h b/ui/gfx/size_base.h
index cd7221c345ec701349fbfec0bd317fdc8020fa64..0dbfabddfcf15e4a50cae207abde488e2178479c 100644
--- a/ui/gfx/size_base.h
+++ b/ui/gfx/size_base.h
@@ -35,6 +35,16 @@ class UI_EXPORT SizeBase {
void set_width(Type width) { width_ = width; }
void set_height(Type height) { height_ = height; }
+ void ClampToMax(const Class& max) {
+ width_ = width_ <= max.width_ ? width_ : max.width_;
+ height_ = height_ <= max.height_ ? height_ : max.height_;
+ }
+
+ void ClampToMin(const Class& min) {
+ width_ = width_ >= min.width_ ? width_ : min.width_;
+ height_ = height_ >= min.height_ ? height_ : min.height_;
+ }
+
bool IsEmpty() const {
return (width_ <= 0) || (height_ <= 0);
}
« no previous file with comments | « ui/gfx/point_unittest.cc ('k') | ui/gfx/size_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698