Skip to content

Commit

Permalink
fix some possible loops because of anti-box-overlap when box are deal…
Browse files Browse the repository at this point in the history
…ing around 0x or 0y values
  • Loading branch information
Houston4444 committed Dec 17, 2021
1 parent 134d4f4 commit cdd82f0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/gui/patchcanvas/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,17 @@ def repulse(direction: int, fixed, moving,
or moving_port_mode & PORT_MODE_OUTPUT):
spacing = box_spacing_hor
x = fixed_rect.left() - spacing - rect.width()
if x < 0:
x -= 1.0
x = float(int(x))
else:
if (fixed_port_mode & PORT_MODE_OUTPUT
or moving_port_mode & PORT_MODE_INPUT):
spacing = box_spacing_hor
x = fixed_rect.right() + spacing
if x < 0:
x -= 1.0
x = float(int(x + 0.99))

top_diff = abs(fixed_rect.top() - rect.top())
bottom_diff = abs(fixed_rect.bottom() - rect.bottom())
Expand All @@ -353,8 +359,14 @@ def repulse(direction: int, fixed, moving,
elif direction in (DIRECTION_UP, DIRECTION_DOWN):
if direction == DIRECTION_UP:
y = fixed_rect.top() - box_spacing - rect.height()
if y < 0:
y -= 1.0
y = float(int(y))
else:
y = fixed_rect.bottom() + box_spacing
if y < 0:
y -= 1.0
y = float(int(y + 0.99))

left_diff = abs(fixed_rect.left() - rect.left())
right_diff = abs(fixed_rect.right() - rect.right())
Expand Down

0 comments on commit cdd82f0

Please sign in to comment.