10 #ifndef GEOMETRY_TYPE_HPP
11 #define GEOMETRY_TYPE_HPP
13 #if defined(__APPLE__)
15 # define Rect OTTD_Rect
16 # define Point OTTD_Point
25 constexpr
Point() : x(0), y(0) {}
26 constexpr
Point(
int x,
int y) : x(x), y(y) {}
34 constexpr
Dimension() : width(0), height(0) {}
35 constexpr
Dimension(uint w, uint h) : width(w), height(h) {}
37 bool operator< (
const Dimension &other)
const
39 int x = (*this).width - other.width;
40 if (x != 0)
return x < 0;
41 return (*this).height < other.height;
44 bool operator== (
const Dimension &other)
const
46 return (*this).width == other.width && (*this).height == other.height;
63 constexpr uint
Horizontal()
const {
return this->left + this->right; }
69 constexpr uint
Vertical()
const {
return this->top + this->bottom; }
85 inline int Width()
const {
return this->right - this->left + 1; }
91 inline int Height()
const {
return this->bottom - this->top + 1; }
100 return {this->left + s, this->top + s, this->right - s, this->bottom - s};
111 return {this->left + h, this->top + v, this->right - h, this->bottom - v};
122 [[nodiscard]]
inline Rect Shrink(
int left,
int top,
int right,
int bottom)
const
124 return {this->left + left, this->top + top, this->right - right, this->bottom - bottom};
134 return {this->left + other.left, this->top + other.top, this->right - other.right, this->bottom - other.bottom};
145 return {this->left + horz.left, this->top + vert.top, this->right - horz.right, this->bottom - vert.bottom};
165 return {this->left - other.left, this->top - other.top, this->right + other.right, this->bottom + other.bottom};
176 return {this->left + x, this->top + y, this->right + x, this->bottom + y};
188 ?
Rect {this->right - width + 1, this->top, this->right, this->bottom}
189 :
Rect {this->left, this->top, this->left + width - 1, this->bottom};
201 ?
Rect {this->left, this->top, this->right - indent, this->bottom}
202 :
Rect {this->left + indent, this->top, this->right, this->bottom};
214 ?
Rect {this->left, this->bottom - height + 1, this->right, this->bottom}
215 :
Rect {this->left, this->top, this->right, this->top + height - 1};
226 return (uint)(pt.x - this->left) < (uint)(this->right - this->left) && (uint)(pt.y - this->top) < (uint)(this->bottom - this->top);