78 const int leftOverflow = std::max(0, edges.left - pt.x());
79 const int rightOverflow = std::max(0, pt.x() - edges.right);
80 const int topOverflow = std::max(0, edges.top - pt.y());
81 const int bottomOverflow = std::max(0, pt.y() - edges.bottom);
83 const int horizontalOverflow = std::max(leftOverflow, rightOverflow);
84 const int verticalOverflow = std::max(topOverflow, bottomOverflow);
85 if (horizontalOverflow > 0 || verticalOverflow > 0) {
86 if (horizontalOverflow >= verticalOverflow) {
90 return {side, QPoint(side ==
PortSide::LEFT ? edges.left : edges.right,
91 std::clamp(pt.y(), edges.top, edges.bottom))};
95 return {side, QPoint(std::clamp(pt.x(), edges.left, edges.right),
99 const int leftDistance = pt.x() - edges.left;
100 const int rightDistance = edges.right - pt.x();
101 const int topDistance = pt.y() - edges.top;
102 const int bottomDistance = edges.bottom - pt.y();
104 std::min({leftDistance, rightDistance, topDistance, bottomDistance});
106 if (nearest == leftDistance)
108 if (nearest == rightDistance)
110 if (nearest == topDistance)