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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_POINT_BASE_H_ 5 #ifndef UI_GFX_POINT_BASE_H_
6 #define UI_GFX_POINT_BASE_H_ 6 #define UI_GFX_POINT_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 void operator+=(const VectorClass& vector) { 36 void operator+=(const VectorClass& vector) {
37 Offset(vector.x(), vector.y()); 37 Offset(vector.x(), vector.y());
38 } 38 }
39 39
40 void operator-=(const VectorClass& vector) { 40 void operator-=(const VectorClass& vector) {
41 Offset(-vector.x(), -vector.y()); 41 Offset(-vector.x(), -vector.y());
42 } 42 }
43 43
44 void ClampToMax(const Class& max) {
45 x_ = x_ <= max.x_ ? x_ : max.x_;
46 y_ = y_ <= max.y_ ? y_ : max.y_;
47 }
48
49 void ClampToMin(const Class& min) {
50 x_ = x_ >= min.x_ ? x_ : min.x_;
51 y_ = y_ >= min.y_ ? y_ : min.y_;
52 }
53
44 Class Middle(const Class& other) const WARN_UNUSED_RESULT { 54 Class Middle(const Class& other) const WARN_UNUSED_RESULT {
45 return Class((x_ + other.x_) / 2, (y_ + other.y_) / 2); 55 return Class((x_ + other.x_) / 2, (y_ + other.y_) / 2);
46 } 56 }
47 57
48 bool IsOrigin() const { 58 bool IsOrigin() const {
49 return x_ == 0 && y_ == 0; 59 return x_ == 0 && y_ == 0;
50 } 60 }
51 61
52 VectorClass OffsetFromOrigin() const { 62 VectorClass OffsetFromOrigin() const {
53 return VectorClass(x_, y_); 63 return VectorClass(x_, y_);
(...skipping 20 matching lines...) Expand all
74 ~PointBase() {} 84 ~PointBase() {}
75 85
76 private: 86 private:
77 Type x_; 87 Type x_;
78 Type y_; 88 Type y_;
79 }; 89 };
80 90
81 } // namespace gfx 91 } // namespace gfx
82 92
83 #endif // UI_GFX_POINT_BASE_H_ 93 #endif // UI_GFX_POINT_BASE_H_
OLDNEW
« 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