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

Function SnapRight

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

Source from the content-addressed store, hash-verified

806 }
807
808 static void SnapRight(WindowBase& w, int32_t proximity)
809 {
810 const auto* mainWindow = WindowGetMain();
811 auto wRight = w.windowPos.x + w.width;
812 auto wBottom = w.windowPos.y + w.height;
813 auto wLeftProximity = wRight - (proximity * 2);
814 auto wRightProximity = wRight + (proximity * 2);
815 auto leftMost = INT32_MAX;
816
817 WindowVisitEach([&](WindowBase* w2) {
818 if (w2 == &w || w2 == mainWindow)
819 return;
820
821 if (wBottom < w2->windowPos.y || w.windowPos.y > w2->windowPos.y + w2->height)
822 return;
823
824 if (w2->windowPos.x < wLeftProximity || w2->windowPos.x > wRightProximity)
825 return;
826
827 leftMost = std::min<int32_t>(leftMost, w2->windowPos.x);
828 });
829
830 auto screenWidth = ContextGetWidth();
831 if (screenWidth >= wLeftProximity && screenWidth <= wRightProximity)
832 leftMost = std::min(leftMost, screenWidth);
833
834 if (leftMost != INT32_MAX)
835 w.windowPos.x = leftMost - w.width;
836 }
837
838 static void SnapBottom(WindowBase& w, int32_t proximity)
839 {

Callers 1

WindowMoveAndSnapFunction · 0.85

Calls 3

WindowGetMainFunction · 0.85
WindowVisitEachFunction · 0.85
ContextGetWidthFunction · 0.85

Tested by

no test coverage detected