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

Unified Diff: ui/gfx/rect_base.h

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more vector use fixes Created 8 years, 2 months 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/rect_base.h
diff --git a/ui/gfx/rect_base.h b/ui/gfx/rect_base.h
index a9ddda4b43f1e0cfddd41ec16c19fc758fba64fd..51a396adad726d3ebadcfc0661bca31704691bd5 100644
--- a/ui/gfx/rect_base.h
+++ b/ui/gfx/rect_base.h
@@ -22,6 +22,7 @@ template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
+ typename VectorClass,
typename Type>
class UI_EXPORT RectBase {
public:
@@ -46,6 +47,10 @@ class UI_EXPORT RectBase {
Type right() const { return x() + width(); }
Type bottom() const { return y() + height(); }
+ VectorClass OffsetFromOrigin() const {
+ return VectorClass(x(), y());
+ }
+
void SetRect(Type x, Type y, Type width, Type height);
// Shrink the rectangle by a horizontal and vertical distance on all sides.
@@ -61,8 +66,8 @@ class UI_EXPORT RectBase {
// Move the rectangle by a horizontal and vertical distance.
void Offset(Type horizontal, Type vertical);
- void Offset(const PointClass& point) {
- Offset(point.x(), point.y());
+ void Offset(const VectorClass& distance) {
+ Offset(distance.x(), distance.y());
}
InsetsClass InsetsFrom(const Class& inner) const {
@@ -122,6 +127,11 @@ class UI_EXPORT RectBase {
// Returns the center of this rectangle.
PointClass CenterPoint() const;
+ // Returns the offset to the center of this rectangle from its origin.
+ VectorClass CenterOffset() const {
Peter Kasting 2012/10/30 01:14:14 I'm not convinced of the utility of this and the r
danakj 2012/10/30 19:21:21 k
+ return CenterPoint().OffsetFromOrigin();
+ }
+
// Becomes a rectangle that has the same center point but with a size capped
// at given |size|.
void ClampToCenteredSize(const SizeClass& size);

Powered by Google App Engine
This is Rietveld 408576698