10 #ifndef GEOMETRY_TYPE_HPP
11 #define GEOMETRY_TYPE_HPP
13 #if defined(__APPLE__)
15 # define Rect OTTD_Rect
16 # define Point OTTD_Point
31 Dimension(uint w = 0, uint h = 0) : width(w), height(h) {};
33 bool operator< (
const Dimension &other)
const
35 int x = (*this).width - other.width;
36 if (x != 0)
return x < 0;
37 return (*this).height < other.height;
40 bool operator== (
const Dimension &other)
const
42 return (*this).width == other.width && (*this).height == other.height;
59 inline uint
Horizontal()
const {
return this->left + this->right; }
65 inline uint
Vertical()
const {
return this->top + this->bottom; }
79 inline int Width()
const {
return this->right - this->left + 1; }
85 inline int Height()
const {
return this->bottom - this->top + 1; }
94 return {this->left + s, this->top + s, this->right - s, this->bottom - s};
105 return {this->left + h, this->top + v, this->right - h, this->bottom - v};
116 [[nodiscard]]
inline Rect Shrink(
int left,
int top,
int right,
int bottom)
const
118 return {this->left + left, this->top + top, this->right - right, this->bottom - bottom};
128 return {this->left + other.left, this->top + other.top, this->right - other.right, this->bottom - other.bottom};
139 return {this->left + horz.left, this->top + vert.top, this->right - horz.right, this->bottom - vert.bottom};
159 return {this->left - other.left, this->top - other.top, this->right + other.right, this->bottom + other.bottom};
170 return {this->left + x, this->top + y, this->right + x, this->bottom + y};
182 ?
Rect {this->right - width + 1, this->top, this->right, this->bottom}
183 :
Rect {this->left, this->top, this->left + width - 1, this->bottom};
195 ?
Rect {this->left, this->top, this->right - indent, this->bottom}
196 :
Rect {this->left + indent, this->top, this->right, this->bottom};
208 ?
Rect {this->left, this->bottom - height + 1, this->right, this->bottom}
209 :
Rect {this->left, this->top, this->right, this->top + height - 1};
220 return (uint)(pt.x - this->left) < (uint)(this->right - this->left) && (uint)(pt.y - this->top) < (uint)(this->bottom - this->top);