From: Christoph Egger Date: Sat, 29 Nov 2014 00:22:34 +0000 (+0100) Subject: Add horizontal space between BasicBlockWidgets X-Git-Tag: v0.1~160 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=31a4c0d5267f2c482ad4d8d4d0f7b86584cf58f2;p=frida%2Ffrida.git Add horizontal space between BasicBlockWidgets --- 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()); + } } } }