2018-10-10 20:06:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-12 01:00:24 +01:00
|
|
|
class Rect;
|
2019-01-14 14:21:51 +01:00
|
|
|
struct GUI_Point;
|
2019-01-12 01:00:24 +01:00
|
|
|
|
2018-10-10 20:06:58 +02:00
|
|
|
class Point {
|
|
|
|
public:
|
|
|
|
Point() { }
|
|
|
|
Point(int x, int y) : m_x(x) , m_y(y) { }
|
2019-01-14 14:21:51 +01:00
|
|
|
Point(const GUI_Point&);
|
2018-10-10 20:06:58 +02:00
|
|
|
|
|
|
|
int x() const { return m_x; }
|
|
|
|
int y() const { return m_y; }
|
|
|
|
|
2019-01-16 17:54:06 +01:00
|
|
|
void set_x(int x) { m_x = x; }
|
|
|
|
void set_y(int y) { m_y = y; }
|
2018-10-10 20:06:58 +02:00
|
|
|
|
2019-01-16 17:54:06 +01:00
|
|
|
void move_by(int dx, int dy)
|
2018-10-10 20:06:58 +02:00
|
|
|
{
|
|
|
|
m_x += dx;
|
|
|
|
m_y += dy;
|
|
|
|
}
|
|
|
|
|
2019-01-16 17:54:06 +01:00
|
|
|
void move_by(const Point& delta)
|
2018-10-12 02:41:27 +02:00
|
|
|
{
|
2019-01-16 17:54:06 +01:00
|
|
|
move_by(delta.x(), delta.y());
|
2018-10-12 02:41:27 +02:00
|
|
|
}
|
|
|
|
|
2019-02-07 23:13:47 +01:00
|
|
|
Point translated(int dx, int dy)
|
|
|
|
{
|
|
|
|
Point point = *this;
|
|
|
|
point.move_by(dx, dy);
|
|
|
|
return point;
|
|
|
|
}
|
|
|
|
|
2019-01-12 01:00:24 +01:00
|
|
|
void constrain(const Rect&);
|
|
|
|
|
2018-10-12 01:03:22 +02:00
|
|
|
bool operator==(const Point& other) const
|
|
|
|
{
|
|
|
|
return m_x == other.m_x
|
|
|
|
&& m_y == other.m_y;
|
|
|
|
}
|
|
|
|
|
2019-01-11 03:52:09 +01:00
|
|
|
bool operator!=(const Point& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
2019-01-14 14:21:51 +01:00
|
|
|
operator GUI_Point() const;
|
|
|
|
|
2018-10-10 20:06:58 +02:00
|
|
|
private:
|
|
|
|
int m_x { 0 };
|
|
|
|
int m_y { 0 };
|
|
|
|
};
|