Remove canvas from port.constraint()

This commit is contained in:
Arjan Molenaar 2020-10-23 18:22:30 +02:00
parent 88ce9f5f6c
commit 1709cebee5
4 changed files with 7 additions and 7 deletions

View File

@ -265,7 +265,7 @@ class ItemConnector:
handle = self.handle
item = self.item
constraint = sink.port.constraint(canvas, item, handle, sink.item)
constraint = sink.port.constraint(item, handle, sink.item)
canvas.connect_item(
item, handle, sink.item, sink.port, constraint, callback=callback

View File

@ -87,7 +87,7 @@ class Port:
"""Get glue point on the port and distance to the port."""
raise NotImplementedError("Glue method not implemented")
def constraint(self, canvas, item, handle, glue_item):
def constraint(self, item, handle, glue_item):
"""Create connection constraint between item's handle and glue item."""
raise NotImplementedError("Constraint method not implemented")
@ -114,7 +114,7 @@ class LinePort(Port):
d, pl = distance_line_point(self.start, self.end, pos)
return pl, d
def constraint(self, canvas, item, handle, glue_item):
def constraint(self, item, handle, glue_item):
"""Create connection line constraint between item's handle and the
port."""
start = MatrixProjection(self.start, glue_item.matrix_i2c)
@ -142,7 +142,7 @@ class PointPort(Port):
d = distance_point_point(self.point, pos)
return self.point, d
def constraint(self, canvas, item, handle, glue_item):
def constraint(self, item, handle, glue_item):
"""Return connection position constraint between item's handle and the
port."""
origin = MatrixProjection(self.point, glue_item.matrix_i2c)

View File

@ -168,7 +168,7 @@ class LineSegment:
item, handle = cinfo.item, cinfo.handle
port = find_port(item, handle, connected)
constraint = port.constraint(canvas, item, handle, connected)
constraint = port.constraint(item, handle, connected)
cinfo = canvas.get_connection(handle)
canvas.reconnect_item(item, handle, port, constraint=constraint)

View File

@ -86,7 +86,7 @@ def test_disconnect_item_with_constraint():
c.add(b2)
c.add(line)
cons = b1.ports()[0].constraint(c, line, line.handles()[0], b1)
cons = b1.ports()[0].constraint(line, line.handles()[0], b1)
c.connect_item(line, line.handles()[0], b1, b1.ports()[0], constraint=cons)
assert count(c.get_connections(handle=line.handles()[0])) == 1
@ -131,7 +131,7 @@ def test_disconnect_item_with_constraint_by_deleting_element():
c.add(b2)
c.add(line)
cons = b1.ports()[0].constraint(c, line, line.handles()[0], b1)
cons = b1.ports()[0].constraint(line, line.handles()[0], b1)
c.connect_item(line, line.handles()[0], b1, b1.ports()[0], constraint=cons)
assert count(c.get_connections(handle=line.handles()[0])) == 1