From: Christoph Egger Date: Fri, 28 Nov 2014 23:19:58 +0000 (+0100) Subject: Horizontally distribute BasicBlockWidgets X-Git-Tag: v0.1~161 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=fae0fc8f1d90f5f36cfc336a92aa9d488471332d;p=frida%2Ffrida.git Horizontally distribute BasicBlockWidgets We still need to add a bit of space between them but the currently used QT API doesn't trivially allow that --- diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index 9a8310c..f98cd60 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -102,10 +102,13 @@ namespace { BasicBlockWidget *tmp, *nextl(NULL), *nextr(NULL); BasicBlock * tmpblock; if (block->getNextBlock(0) != 0) { + int xshift = 0; + if (block->getNextBlock(1) != 0) + xshift = 1; tmpblock = dis->getBasicBlock(block->getNextBlock(0)); tmp = local__add_basic_block(tmpblock, dis, known_blocks, - scene, starty, startx+1); + scene, starty, startx+xshift); nextl = tmp; tmp->addPrevious(widget); } diff --git a/src/gui/widgets/CFGScene.cxx b/src/gui/widgets/CFGScene.cxx index 7bed8f1..a297c85 100644 --- a/src/gui/widgets/CFGScene.cxx +++ b/src/gui/widgets/CFGScene.cxx @@ -59,4 +59,15 @@ 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()) + widget->moveBy(1, 0); + else + item->moveBy(1, 0); + } + } + } }