mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-18 18:38:51 +00:00
Graph edge highlight (#1693)
* Highlight edges to and from current block in graph.
This commit is contained in:
parent
fe4206999a
commit
a5dc85c3c5
@ -152,6 +152,8 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent, CutterSeekable* se
|
||||
// Add header as widget to layout so it stretches to the layout width
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
|
||||
this->scale_thickness_multiplier = true;
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::connectSeekChanged(bool disconn)
|
||||
@ -601,6 +603,11 @@ GraphView::EdgeConfiguration DisassemblerGraphView::edgeConfiguration(GraphView:
|
||||
}
|
||||
ec.start_arrow = false;
|
||||
ec.end_arrow = true;
|
||||
if (from.entry == currentBlockAddress) {
|
||||
ec.width_scale = 2.0;
|
||||
} else if (to->entry == currentBlockAddress) {
|
||||
ec.width_scale = 2.0;
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
|
||||
@ -922,6 +929,8 @@ void DisassemblerGraphView::blockClicked(GraphView::GraphBlock &block, QMouseEve
|
||||
return;
|
||||
}
|
||||
|
||||
currentBlockAddress = block.entry;
|
||||
|
||||
highlight_token = getToken(instr, pos.x());
|
||||
|
||||
RVA addr = instr->addr;
|
||||
@ -983,6 +992,7 @@ bool DisassemblerGraphView::helpEvent(QHelpEvent *event)
|
||||
|
||||
void DisassemblerGraphView::blockTransitionedTo(GraphView::GraphBlock *to)
|
||||
{
|
||||
currentBlockAddress = to->entry;
|
||||
if (transition_dont_seek) {
|
||||
transition_dont_seek = false;
|
||||
return;
|
||||
|
@ -147,6 +147,7 @@ private:
|
||||
int charOffset;
|
||||
int baseline;
|
||||
bool emptyGraph;
|
||||
ut64 currentBlockAddress = RVA_INVALID;
|
||||
|
||||
DisassemblyContextMenu *blockMenu;
|
||||
QMenu *contextMenu;
|
||||
|
@ -918,9 +918,9 @@ void DisassemblyLeftPanel::paintEvent(QPaintEvent *event)
|
||||
|
||||
bool jumpDown = l.arrow > l.offset;
|
||||
p.setPen(jumpDown ? penDown : penUp);
|
||||
if (l.offset == currOffset) {
|
||||
if (l.offset == currOffset || l.arrow == currOffset) {
|
||||
QPen pen = p.pen();
|
||||
pen.setWidth((penSizePix * 3) / 2);
|
||||
pen.setWidthF((penSizePix * 3) / 2.0);
|
||||
p.setPen(pen);
|
||||
}
|
||||
bool endVisible = true;
|
||||
|
@ -336,8 +336,12 @@ void GraphView::paintGraphCache()
|
||||
QPolygonF polyline = recalculatePolygon(edge.polyline);
|
||||
EdgeConfiguration ec = edgeConfiguration(block, &blocks[edge.target]);
|
||||
QPen pen(ec.color);
|
||||
pen.setWidth(pen.width() / ec.width_scale);
|
||||
if (pen.width() * current_scale < 2) {
|
||||
pen.setStyle(ec.lineStyle);
|
||||
pen.setWidthF(pen.width() * ec.width_scale);
|
||||
if (scale_thickness_multiplier * ec.width_scale > 1.01 && pen.widthF() * current_scale < 2) {
|
||||
pen.setWidthF(ec.width_scale / current_scale);
|
||||
}
|
||||
if (pen.widthF() * current_scale < 2) {
|
||||
pen.setWidth(0);
|
||||
}
|
||||
p.setPen(pen);
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
bool start_arrow = false;
|
||||
bool end_arrow = true;
|
||||
qreal width_scale = 1.0;
|
||||
Qt::PenStyle lineStyle = Qt::PenStyle::SolidLine;
|
||||
};
|
||||
|
||||
explicit GraphView(QWidget *parent);
|
||||
@ -96,6 +97,7 @@ protected:
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
bool scale_thickness_multiplier = false;
|
||||
|
||||
void clampViewOffset();
|
||||
void setViewOffsetInternal(QPoint pos, bool emitSignal = true);
|
||||
@ -125,9 +127,6 @@ private:
|
||||
int scroll_base_y = 0;
|
||||
bool scroll_mode = false;
|
||||
|
||||
// Todo: remove charheight/charwidth cause it should be handled in child class
|
||||
qreal charWidth = 10.0;
|
||||
|
||||
bool useGL;
|
||||
|
||||
/**
|
||||
|
@ -137,7 +137,7 @@ GraphView::EdgeConfiguration OverviewView::edgeConfiguration(GraphView::GraphBlo
|
||||
auto baseEcIt = edgeConfigurations.find({from.entry, to->entry});
|
||||
if (baseEcIt != edgeConfigurations.end())
|
||||
ec = baseEcIt->second;
|
||||
ec.width_scale = getViewScale();
|
||||
ec.width_scale = 1.0 / getViewScale();
|
||||
return ec;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user