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

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: 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/size_base.h
diff --git a/ui/gfx/size_base.h b/ui/gfx/size_base.h
index cd7221c345ec701349fbfec0bd317fdc8020fa64..63820b220ef53db12ffe883af492378088c8baab 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 ClampFromAbove(const Class& other) {
sky 2012/11/09 18:23:12 The name here is even more confusing. Sizes genera
danakj 2012/11/09 18:24:25 Oh, hm. I hadn't thought of it in terms of directi
+ width_ = width_ <= other.width_ ? width_ : other.width_;
+ height_ = height_ <= other.height_ ? height_ : other.height_;
+ }
+
+ void ClampFromBelow(const Class& other) {
+ width_ = width_ >= other.width_ ? width_ : other.width_;
+ height_ = height_ >= other.height_ ? height_ : other.height_;
+ }
+
bool IsEmpty() const {
return (width_ <= 0) || (height_ <= 0);
}
« ui/gfx/point_base.h ('K') | « 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