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

Side by Side Diff: ui/gfx/rect_base.h

Issue 11293194: ui: Prefer +/- operators to apply offsets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: floats 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 // A template for a simple rectangle class. The containment semantics 5 // A template for a simple rectangle class. The containment semantics
6 // are array-like; that is, the coordinate (x, y) is considered to be 6 // are array-like; that is, the coordinate (x, y) is considered to be
7 // contained by the rectangle, but the coordinate (x + width, y) is not. 7 // contained by the rectangle, but the coordinate (x + width, y) is not.
8 // The class will happily let you create malformed rectangles (that is, 8 // The class will happily let you create malformed rectangles (that is,
9 // rectangles with negative width and/or height), but there will be assertions 9 // rectangles with negative width and/or height), but there will be assertions
10 // in the operations (such as Contains()) to complain in this case. 10 // in the operations (such as Contains()) to complain in this case.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void Inset(const InsetsClass& insets); 62 void Inset(const InsetsClass& insets);
63 63
64 // Shrink the rectangle by the specified amount on each side. 64 // Shrink the rectangle by the specified amount on each side.
65 void Inset(Type left, Type top, Type right, Type bottom); 65 void Inset(Type left, Type top, Type right, Type bottom);
66 66
67 // Move the rectangle by a horizontal and vertical distance. 67 // Move the rectangle by a horizontal and vertical distance.
68 void Offset(Type horizontal, Type vertical); 68 void Offset(Type horizontal, Type vertical);
69 void Offset(const VectorClass& distance) { 69 void Offset(const VectorClass& distance) {
70 Offset(distance.x(), distance.y()); 70 Offset(distance.x(), distance.y());
71 } 71 }
72 void operator+=(const VectorClass& offset);
73 void operator-=(const VectorClass& offset);
72 74
73 InsetsClass InsetsFrom(const Class& inner) const { 75 InsetsClass InsetsFrom(const Class& inner) const {
74 return InsetsClass(inner.y() - y(), 76 return InsetsClass(inner.y() - y(),
75 inner.x() - x(), 77 inner.x() - x(),
76 bottom() - inner.bottom(), 78 bottom() - inner.bottom(),
77 right() - inner.right()); 79 right() - inner.right());
78 } 80 }
79 81
80 // Returns true if the area of the rectangle is zero. 82 // Returns true if the area of the rectangle is zero.
81 bool IsEmpty() const { return size_.IsEmpty(); } 83 bool IsEmpty() const { return size_.IsEmpty(); }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ~RectBase(); 149 ~RectBase();
148 150
149 private: 151 private:
150 PointClass origin_; 152 PointClass origin_;
151 SizeClass size_; 153 SizeClass size_;
152 }; 154 };
153 155
154 } // namespace gfx 156 } // namespace gfx
155 157
156 #endif // UI_GFX_RECT_BASE_H_ 158 #endif // UI_GFX_RECT_BASE_H_
OLDNEW
« .gitmodules ('K') | « ui/gfx/rect.cc ('k') | ui/gfx/rect_base_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698