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

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

Issue 11358240: ui: Add methods to Rect classes to get points at each of the rect's corners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/rect_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 // 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 29 matching lines...) Expand all
40 40
41 const PointClass& origin() const { return origin_; } 41 const PointClass& origin() const { return origin_; }
42 void set_origin(const PointClass& origin) { origin_ = origin; } 42 void set_origin(const PointClass& origin) { origin_ = origin; }
43 43
44 const SizeClass& size() const { return size_; } 44 const SizeClass& size() const { return size_; }
45 void set_size(const SizeClass& size) { size_ = size; } 45 void set_size(const SizeClass& size) { size_ = size; }
46 46
47 Type right() const { return x() + width(); } 47 Type right() const { return x() + width(); }
48 Type bottom() const { return y() + height(); } 48 Type bottom() const { return y() + height(); }
49 49
50 PointClass TopLeft() const { return PointClass(x(), y()); }
sky 2012/11/14 22:23:43 This is the same as origin(), do we really need it
danakj 2012/11/14 22:36:34 It's true, we don't. I liked having consistency so
51 PointClass TopRight() const { return PointClass(right(), y()); }
sky 2012/11/14 22:23:43 Can these be named unix_hacker style?
danakj 2012/11/14 22:36:34 Done.
52 PointClass BottomLeft() const { return PointClass(x(), bottom()); }
53 PointClass BottomRight() const { return PointClass(right(), bottom()); }
54
50 VectorClass OffsetFromOrigin() const { 55 VectorClass OffsetFromOrigin() const {
51 return VectorClass(x(), y()); 56 return VectorClass(x(), y());
52 } 57 }
53 58
54 void SetRect(Type x, Type y, Type width, Type height); 59 void SetRect(Type x, Type y, Type width, Type height);
55 60
56 // Shrink the rectangle by a horizontal and vertical distance on all sides. 61 // Shrink the rectangle by a horizontal and vertical distance on all sides.
57 void Inset(Type horizontal, Type vertical) { 62 void Inset(Type horizontal, Type vertical) {
58 Inset(horizontal, vertical, horizontal, vertical); 63 Inset(horizontal, vertical, horizontal, vertical);
59 } 64 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 ~RectBase(); 154 ~RectBase();
150 155
151 private: 156 private:
152 PointClass origin_; 157 PointClass origin_;
153 SizeClass size_; 158 SizeClass size_;
154 }; 159 };
155 160
156 } // namespace gfx 161 } // namespace gfx
157 162
158 #endif // UI_GFX_RECT_BASE_H_ 163 #endif // UI_GFX_RECT_BASE_H_
OLDNEW
« no previous file with comments | « cc/tiled_layer.cc ('k') | ui/gfx/rect_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698