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

Function SnapTop

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

Source from the content-addressed store, hash-verified

776 }
777
778 static void SnapTop(WindowBase& w, int32_t proximity)
779 {
780 const auto* mainWindow = WindowGetMain();
781 auto wRight = w.windowPos.x + w.width;
782 auto wTopProximity = w.windowPos.y - (proximity * 2);
783 auto wBottomProximity = w.windowPos.y + (proximity * 2);
784 auto bottomMost = INT32_MIN;
785
786 WindowVisitEach([&](WindowBase* w2) {
787 if (w2 == &w || w2 == mainWindow)
788 return;
789
790 auto bottom = w2->windowPos.y + w2->height;
791
792 if (wRight < w2->windowPos.x || w.windowPos.x > w2->windowPos.x + w2->width)
793 return;
794
795 if (bottom < wTopProximity || bottom > wBottomProximity)
796 return;
797
798 bottomMost = std::max(bottomMost, bottom);
799 });
800
801 if (0 >= wTopProximity && 0 <= wBottomProximity)
802 bottomMost = std::max(bottomMost, 0);
803
804 if (bottomMost != INT32_MIN)
805 w.windowPos.y = bottomMost;
806 }
807
808 static void SnapRight(WindowBase& w, int32_t proximity)
809 {

Callers 1

WindowMoveAndSnapFunction · 0.85

Calls 2

WindowGetMainFunction · 0.85
WindowVisitEachFunction · 0.85

Tested by

no test coverage detected