MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / Rect

Class Rect

src/Engine/include/OpenLoco/Engine/Ui/Rect.hpp:11–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace OpenLoco::Ui
10{
11 class Rect
12 {
13 public:
14 Ui::Size size;
15 Ui::Point origin;
16 Rect(int32_t x, int32_t y, int32_t width, int32_t height)
17 : size{ width, height }
18 , origin{ x, y }
19 {
20 }
21
22 static Rect fromLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
23 {
24 return Rect(left, top, right - left, bottom - top);
25 }
26
27 bool intersects(const Rect& r2) const
28 {
29 if (origin.x + size.width <= r2.origin.x)
30 {
31 return false;
32 }
33 if (origin.y + size.height <= r2.origin.y)
34 {
35 return false;
36 }
37 if (origin.x >= r2.origin.x + r2.size.width)
38 {
39 return false;
40 }
41 if (origin.y >= r2.origin.y + r2.size.height)
42 {
43 return false;
44 }
45 return true;
46 }
47
48 Rect intersection(const Rect r2) const
49 {
50 int left = std::max(this->origin.x, r2.origin.x);
51 int top = std::max(this->origin.y, r2.origin.y);
52 int right = std::min(this->origin.x + this->size.width, r2.origin.x + r2.size.width);
53 int bottom = std::min(this->origin.y + this->size.height, r2.origin.y + r2.size.height);
54
55 return Rect(left, top, right - left, bottom - top);
56 }
57
58 int32_t width() const
59 {
60 return this->size.width;
61 }
62
63 int32_t height() const
64 {
65 return this->size.height;
66 }
67
68 int32_t left() const

Callers 15

fromLTRBMethod · 0.85
intersectionMethod · 0.85
viewportMoveFunction · 0.85
drawBackgroundMethod · 0.85
drawFunction · 0.85
drawScrollFunction · 0.85
drawPreviewImageFunction · 0.85
drawDescriptionFunction · 0.85
drawDatDetailsFunction · 0.85
drawSearchBoxFunction · 0.85
drawScrollFunction · 0.85
drawSearchBoxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected