From 31a4c0d5267f2c482ad4d8d4d0f7b86584cf58f2 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Sat, 29 Nov 2014 01:22:34 +0100 Subject: [PATCH] Add horizontal space between BasicBlockWidgets --- src/gui/widgets/CFGScene.cxx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/CFGScene.cxx b/src/gui/widgets/CFGScene.cxx index a297c85..81c9735 100644 --- a/src/gui/widgets/CFGScene.cxx +++ b/src/gui/widgets/CFGScene.cxx @@ -61,12 +61,21 @@ void CFGScene::spaceWidgets() { } while (changed); for (BasicBlockWidget * widget : widgets) { - for (QGraphicsItem * item : widget->collidingItems()) { - while (widget->collidesWithItem(item)) { - if (widget->scenePos().x() > item->scenePos().x()) + QRectF relevantRect = widget->boundingRect(); + relevantRect.moveTo(widget->scenePos()); + relevantRect.adjust(-20, -20, 20, 20); + for (QGraphicsItem * item : items(relevantRect)) { + if (item == widget) continue; + QRectF itemrect = item->boundingRect(); + itemrect.moveTo(item->scenePos()); + while (relevantRect.intersects(itemrect)) { + if (widget->scenePos().x() > item->scenePos().x()) { widget->moveBy(1, 0); - else + relevantRect.moveTo(widget->scenePos()); + } else { item->moveBy(1, 0); + itemrect.moveTo(item->scenePos()); + } } } } -- 2.39.5