MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / SnapBottom

Function SnapBottom

src/openrct2-ui/interface/Window.cpp:838–866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

836 }
837
838 static void SnapBottom(WindowBase& w, int32_t proximity)
839 {
840 const auto* mainWindow = WindowGetMain();
841 auto wRight = w.windowPos.x + w.width;
842 auto wBottom = w.windowPos.y + w.height;
843 auto wTopProximity = wBottom - (proximity * 2);
844 auto wBottomProximity = wBottom + (proximity * 2);
845 auto topMost = INT32_MAX;
846
847 WindowVisitEach([&](WindowBase* w2) {
848 if (w2 == &w || w2 == mainWindow)
849 return;
850
851 if (wRight < w2->windowPos.x || w.windowPos.x > w2->windowPos.x + w2->width)
852 return;
853
854 if (w2->windowPos.y < wTopProximity || w2->windowPos.y > wBottomProximity)
855 return;
856
857 topMost = std::min<int32_t>(topMost, w2->windowPos.y);
858 });
859
860 auto screenHeight = ContextGetHeight();
861 if (screenHeight >= wTopProximity && screenHeight <= wBottomProximity)
862 topMost = std::min(topMost, screenHeight);
863
864 if (topMost != INT32_MAX)
865 w.windowPos.y = topMost - w.height;
866 }
867
868 void WindowMoveAndSnap(WindowBase& w, ScreenCoordsXY newWindowCoords, int32_t snapProximity)
869 {

Callers 1

WindowMoveAndSnapFunction · 0.85

Calls 3

WindowGetMainFunction · 0.85
WindowVisitEachFunction · 0.85
ContextGetHeightFunction · 0.85

Tested by

no test coverage detected