X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fgui%2Fwidgets%2FBasicBlockWidget.hxx;h=e40ed840a759bf838d6a1cb5f14765dd0b9217a5;hp=bc579a90efaf7670dd5bfdd77a144145ae42a836;hb=d80925a9bd94f07a119acefc8b71d10f41ab81be;hpb=2c83a39c132aa0ea0ed0b771d160ada7691261f3 diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index bc579a9..e40ed84 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -5,6 +5,8 @@ #include "disassembler/BasicBlock.hxx" #include #include +#include +#include class BasicBlockWidget : public QGraphicsItem { @@ -15,62 +17,34 @@ public: QRectF boundingRect() const { qreal penWidth = 1; - - - if (next[0]) { - if (next[1]) { - result |= QRectF(QPointF(x + dx/3, y+dy), - mapFromScene(next[0]->getEntry())); - } else { - result |= QRectF(QPointF(x + dx/2, y+dy), - mapFromScene(next[0]->getEntry())); - } - } - if (next[1]) - result |= QRectF(QPointF(x + 2*dx/3, y+dy), - mapFromScene(next[1]->getEntry())); - QRectF result(- penWidth / 2, - penWidth / 2, width + penWidth, height + penWidth); return result; } - void mouseMoveEvent(QGraphicsSceneMouseEvent *event) { + + void mouseMoveEvent(QGraphicsSceneMouseEvent * event) { QGraphicsItem::mouseMoveEvent(event); - std::for_each(previous.begin(), previous.end(), - [&] (BasicBlockWidget * item) { - item->update(boundingRect() | item->boundingRect()); - }); + scene()->update(); } QPointF getEntry() const { return mapToScene(QPointF(width/2, 0)); } + std::array getExits() const { + return { { mapToScene(QPointF( width/3, height)), + mapToScene(QPointF( width/2, height)), + mapToScene(QPointF(2*width/3, height)) } }; + } + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->fillRect(0, 0, width, height, QColor(0xcc, 0xcc, 0xff, 0xff)); painter->setPen(QColor(0x00, 0x00, 0xff, 0xff)); painter->drawRect(0, 0, width, height); painter->drawText(5, 15, name); - if (_widget.rowCount() != 0) - _widget.render(painter); - - if (next[0]) { - if (next[1]) { - painter->setPen(QColor(0x00, 0xff, 0x00, 0xff)); - painter->drawLine(QPointF(x + dx/3, y+dy), - mapFromScene(next[0]->getEntry())); - } else { - painter->setPen(QColor(0x00, 0x00, 0x00, 0xff)); - painter->drawLine(QPointF(x + dx/2, y+dy), - mapFromScene(next[0]->getEntry())); - } - } - painter->setPen(QColor(0xff, 0x00, 0x00, 0xff)); - if (next[1]) - painter->drawLine(QPointF(x + 2*dx/3, y+dy), - mapFromScene(next[1]->getEntry())); - + if (_widget.text() != "") + _widget.render(painter, QPoint(5, 20)); } void addPrevious(BasicBlockWidget * widget) { @@ -82,9 +56,13 @@ public: next[1] = right; } + BasicBlockWidget ** getNext() { + return next; + } + private: uint32_t width, height; - QTableWidget _widget; + QLabel _widget; QString name; BasicBlock * block; std::vector previous;