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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/tiled_layer.cc ('k') | ui/gfx/point_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bool IsOrigin() const { 54 bool IsOrigin() const {
45 return x_ == 0 && y_ == 0; 55 return x_ == 0 && y_ == 0;
46 } 56 }
47 57
48 VectorClass OffsetFromOrigin() const { 58 VectorClass OffsetFromOrigin() const {
49 return VectorClass(x_, y_); 59 return VectorClass(x_, y_);
50 } 60 }
51 61
52 VectorClass OffsetFrom(const Class& other) const { 62 VectorClass OffsetFrom(const Class& other) const {
53 return VectorClass(x_ - other.x_, y_ - other.y_); 63 return VectorClass(x_ - other.x_, y_ - other.y_);
(...skipping 16 matching lines...) Expand all
70 ~PointBase() {} 80 ~PointBase() {}
71 81
72 private: 82 private:
73 Type x_; 83 Type x_;
74 Type y_; 84 Type y_;
75 }; 85 };
76 86
77 } // namespace gfx 87 } // namespace gfx
78 88
79 #endif // UI_GFX_POINT_BASE_H_ 89 #endif // UI_GFX_POINT_BASE_H_
OLDNEW
« 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