Chromium Code Reviews| Index: ui/gfx/vector2d.h |
| diff --git a/ui/gfx/vector2d.h b/ui/gfx/vector2d.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cd61438bef81850f27cd18a92a765bebec0c1268 |
| --- /dev/null |
| +++ b/ui/gfx/vector2d.h |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Defines a simple integer vector class. This class is used to indicate a |
| +// distance in two dimentions between two points. Subtracting two points should |
| +// produce a vector, and adding a vector to a point produces the point at the |
| +// vector's distance from the original point. |
| + |
| +#ifndef UI_GFX_VECTOR2D_H_ |
| +#define UI_GFX_VECTOR2D_H_ |
| + |
| +#include <string> |
| + |
| +#include "ui/base/ui_export.h" |
| +#include "ui/gfx/vector2d_f.h" |
| + |
| +namespace gfx { |
| + |
| +class UI_EXPORT Vector2d { |
| + public: |
| + Vector2d(); |
| + Vector2d(int x, int y); |
| + |
| + int x() const { return m_x; } |
| + void set_x(int x) { m_x = x; } |
| + |
| + int y() const { return m_y; } |
| + void set_y(int y) { m_y = y; } |
| + |
| + void Grow(int x, int y) { |
| + m_x += x; |
| + m_y += y; |
| + } |
| + |
| + void Add(const Vector2d& other) { |
| + m_x += other.m_x; |
| + m_y += other.m_y; |
| + } |
| + |
| + std::string ToString() const; |
| + |
| + operator Vector2dF() const { return Vector2dF(m_x, m_y); } |
| + |
| + private: |
| + int m_x; |
|
tfarina
2012/10/25 00:40:20
nit: please remember that we are in chromium code,
danakj
2012/10/25 00:59:09
oh, shoot. thanks.
|
| + int m_y; |
| +}; |
| + |
| +inline Vector2d operator-(const Vector2d& v) { |
| + return Vector2d(-v.x(), -v.y()); |
| +} |
| + |
| +} // namespace gfx |
| + |
| +#endif // UI_GFX_VECTOR2D_H_ |