5#ifndef UI_GFX_GEOMETRY_POINT_H_
6#define UI_GFX_GEOMETRY_POINT_H_
18typedef unsigned long DWORD;
19typedef struct tagPOINT POINT;
20#elif defined(OS_APPLE)
21typedef struct CGPoint CGPoint;
29 constexpr Point() : x_(0), y_(0) {}
36 explicit Point(
const POINT& point);
37 Point& operator=(
const POINT& point);
38#elif defined(OS_APPLE)
39 explicit Point(
const CGPoint& point);
43 POINT ToPOINT()
const;
44#elif defined(OS_APPLE)
45 CGPoint ToCGPoint()
const;
48 constexpr int x()
const {
return x_; }
49 constexpr int y()
const {
return y_; }
58 void Offset(
int delta_x,
int delta_y) {
59 x_ = base::ClampAdd(x_, delta_x);
60 y_ = base::ClampAdd(y_, delta_y);
64 x_ = base::ClampAdd(x_, vector.
x());
65 y_ = base::ClampAdd(y_, vector.
y());
69 x_ = base::ClampSub(x_, vector.
x());
70 y_ = base::ClampSub(y_, vector.
y());
73 void SetToMin(
const Point& other);
74 void SetToMax(
const Point& other);
76 bool IsOrigin()
const {
return x_ == 0 && y_ == 0; }
86 bool operator<(
const Point& rhs)
const {
return std::tie(y_, x_) < std::tie(rhs.y_, rhs.x_); }
97 return lhs.
x() == rhs.
x() && lhs.
y() == rhs.
y();
101 return !(lhs == rhs);
117 return Vector2d(base::ClampSub(lhs.
x(), rhs.
x()), base::ClampSub(lhs.
y(), rhs.
y()));
121 return Point(offset_from_origin.
x(), offset_from_origin.
y());
bool operator<(const Point &rhs) const
void Offset(int delta_x, int delta_y)
void operator+=(const Vector2d &vector)
void SetPoint(int x, int y)
void operator-=(const Vector2d &vector)
Vector2d OffsetFromOrigin() const
constexpr Point(int x, int y)
Point ScaleToCeiledPoint(const Point &point, float x_scale, float y_scale)
Point PointAtOffsetFromOrigin(const Vector2d &offset_from_origin)
Insets operator+(Insets lhs, const Insets &rhs)
void PrintTo(const Point &point, ::std::ostream *os)
Point ScaleToFlooredPoint(const Point &point, float x_scale, float y_scale)
Insets operator-(Insets lhs, const Insets &rhs)
bool operator==(const Point &lhs, const Point &rhs)
Point ScaleToRoundedPoint(const Point &point, float x_scale, float y_scale)
bool operator!=(const Point &lhs, const Point &rhs)
static std::string ToString(CompilerBackend::Type type)