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

Method capSize

src/OpenLoco/src/Ui/Window.cpp:46–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45
46 void Window::capSize(int32_t newMinWidth, int32_t newMinHeight, int32_t newMaxWidth, int32_t newMaxHeight)
47 {
48 auto w = this->width;
49 auto h = this->height;
50 auto shouldInvalidateBefore = false;
51 auto shouldInvalidateAfter = false;
52 if (w < newMinWidth)
53 {
54 w = newMinWidth;
55 shouldInvalidateAfter = true;
56 }
57 if (h < newMinHeight)
58 {
59 h = newMinHeight;
60 shouldInvalidateAfter = true;
61 }
62 if (w > newMaxWidth)
63 {
64 shouldInvalidateBefore = true;
65 w = newMaxWidth;
66 }
67 if (h > newMaxHeight)
68 {
69 shouldInvalidateBefore = true;
70 h = newMaxHeight;
71 }
72
73 if (shouldInvalidateBefore)
74 {
75 invalidate();
76 }
77 this->width = w;
78 this->height = h;
79 this->minWidth = newMinWidth;
80 this->minHeight = newMinHeight;
81 this->maxWidth = newMaxWidth;
82 this->maxHeight = newMaxHeight;
83 if (shouldInvalidateAfter)
84 {
85 invalidate();
86 }
87 }
88
89 bool Window::isVisible()
90 {

Callers 1

onResizeFunction · 0.80

Calls 1

invalidateFunction · 0.70

Tested by

no test coverage detected