Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Defines a simple integer vector class. This class is used to indicate a | |
| 6 // distance in two dimentions between two points. Subtracting two points should | |
| 7 // produce a vector, and adding a vector to a point produces the point at the | |
| 8 // vector's distance from the original point. | |
| 9 | |
| 10 #ifndef UI_GFX_VECTOR2D_H_ | |
| 11 #define UI_GFX_VECTOR2D_H_ | |
| 12 | |
| 13 #include <string> | |
| 14 | |
| 15 #include "ui/base/ui_export.h" | |
| 16 #include "ui/gfx/vector2d_f.h" | |
| 17 | |
| 18 namespace gfx { | |
| 19 | |
| 20 class UI_EXPORT Vector2d { | |
| 21 public: | |
| 22 Vector2d(); | |
| 23 Vector2d(int x, int y); | |
| 24 | |
| 25 int x() const { return m_x; } | |
| 26 void set_x(int x) { m_x = x; } | |
| 27 | |
| 28 int y() const { return m_y; } | |
| 29 void set_y(int y) { m_y = y; } | |
| 30 | |
| 31 void Grow(int x, int y) { | |
| 32 m_x += x; | |
| 33 m_y += y; | |
| 34 } | |
| 35 | |
| 36 void Add(const Vector2d& other) { | |
| 37 m_x += other.m_x; | |
| 38 m_y += other.m_y; | |
| 39 } | |
| 40 | |
| 41 std::string ToString() const; | |
| 42 | |
| 43 operator Vector2dF() const { return Vector2dF(m_x, m_y); } | |
| 44 | |
| 45 private: | |
| 46 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.
| |
| 47 int m_y; | |
| 48 }; | |
| 49 | |
| 50 inline Vector2d operator-(const Vector2d& v) { | |
| 51 return Vector2d(-v.x(), -v.y()); | |
| 52 } | |
| 53 | |
| 54 } // namespace gfx | |
| 55 | |
| 56 #endif // UI_GFX_VECTOR2D_H_ | |
| OLD | NEW |