Skip to content

Commit

Permalink
dag: smoothly add/remove margin when fitting to selection
Browse files Browse the repository at this point in the history
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Feb 6, 2017
1 parent aa0260d commit 6a24163
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cola/widgets/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,11 +1403,13 @@ def fit_view_to_items(self, items):
x_adjust = abs(GraphView.x_adjust)
y_adjust = abs(GraphView.y_adjust)

count = max(2, 10 - len(items)//2)
rect.setX(rect.x() - x_adjust)
rect.setY(rect.y() - y_adjust)
rect.setHeight(rect.height() + y_adjust*count)
rect.setWidth(rect.width() + x_adjust*count)
count = max(2.0, 10.0 - len(items)/2.0)
y_offset = int(y_adjust * count)
x_offset = int(x_adjust * count)
rect.setX(rect.x() - x_offset//2)
rect.setY(rect.y() - y_adjust//2)
rect.setHeight(rect.height() + y_offset)
rect.setWidth(rect.width() + x_offset)

self.fitInView(rect, Qt.KeepAspectRatio)
self.scene().invalidate()
Expand Down

0 comments on commit 6a24163

Please sign in to comment.