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

Function SnapLeft

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

Source from the content-addressed store, hash-verified

746 }
747
748 static void SnapLeft(WindowBase& w, int32_t proximity)
749 {
750 const auto* mainWindow = WindowGetMain();
751 auto wBottom = w.windowPos.y + w.height;
752 auto wLeftProximity = w.windowPos.x - (proximity * 2);
753 auto wRightProximity = w.windowPos.x + (proximity * 2);
754 auto rightMost = INT32_MIN;
755
756 WindowVisitEach([&](WindowBase* w2) {
757 if (w2 == &w || w2 == mainWindow)
758 return;
759
760 auto right = w2->windowPos.x + w2->width;
761
762 if (wBottom < w2->windowPos.y || w.windowPos.y > w2->windowPos.y + w2->height)
763 return;
764
765 if (right < wLeftProximity || right > wRightProximity)
766 return;
767
768 rightMost = std::max(rightMost, right);
769 });
770
771 if (0 >= wLeftProximity && 0 <= wRightProximity)
772 rightMost = std::max(rightMost, 0);
773
774 if (rightMost != INT32_MIN)
775 w.windowPos.x = rightMost;
776 }
777
778 static void SnapTop(WindowBase& w, int32_t proximity)
779 {

Callers 1

WindowMoveAndSnapFunction · 0.85

Calls 2

WindowGetMainFunction · 0.85
WindowVisitEachFunction · 0.85

Tested by

no test coverage detected