Fix graph zoom reset and use same font size as everything else. (#1835)

This commit is contained in:
karliss 2019-10-13 17:22:55 +03:00 committed by Itay Cohen
parent 4aa6927066
commit 9d2a8d9deb
2 changed files with 11 additions and 6 deletions

View File

@ -401,7 +401,7 @@ void DisassemblerGraphView::cleanupEdges()
void DisassemblerGraphView::initFont() void DisassemblerGraphView::initFont()
{ {
setFont(Config()->getBaseFont()); setFont(Config()->getFont());
QFontMetricsF metrics(font()); QFontMetricsF metrics(font());
baseline = int(metrics.ascent()); baseline = int(metrics.ascent());
charWidth = metrics.width('X'); charWidth = metrics.width('X');
@ -418,7 +418,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block,
p.setPen(Qt::black); p.setPen(Qt::black);
p.setBrush(Qt::gray); p.setBrush(Qt::gray);
p.setFont(Config()->getBaseFont()); p.setFont(Config()->getFont());
p.drawRect(blockRect); p.drawRect(blockRect);
breakpoints = Core()->getBreakpointsAddresses(); breakpoints = Core()->getBreakpointsAddresses();
@ -775,6 +775,12 @@ void DisassemblerGraphView::onSeekChanged(RVA addr)
} }
void DisassemblerGraphView::zoom(QPointF mouseRelativePos, double velocity) void DisassemblerGraphView::zoom(QPointF mouseRelativePos, double velocity)
{
qreal newScale = getViewScale() * std::pow(1.25, velocity);
setZoom(mouseRelativePos, newScale);
}
void DisassemblerGraphView::setZoom(QPointF mouseRelativePos, double scale)
{ {
mouseRelativePos.rx() *= size().width(); mouseRelativePos.rx() *= size().width();
mouseRelativePos.ry() *= size().height(); mouseRelativePos.ry() *= size().height();
@ -782,7 +788,7 @@ void DisassemblerGraphView::zoom(QPointF mouseRelativePos, double velocity)
auto globalMouse = mouseRelativePos + getViewOffset(); auto globalMouse = mouseRelativePos + getViewOffset();
mouseRelativePos *= getViewScale(); mouseRelativePos *= getViewScale();
qreal newScale = getViewScale() * std::pow(1.25, velocity); qreal newScale = scale;
newScale = std::max(newScale, 0.05); newScale = std::max(newScale, 0.05);
mouseRelativePos /= newScale; mouseRelativePos /= newScale;
setViewScale(newScale); setViewScale(newScale);
@ -806,9 +812,7 @@ void DisassemblerGraphView::zoomOut()
void DisassemblerGraphView::zoomReset() void DisassemblerGraphView::zoomReset()
{ {
setViewScale(1.0); setZoom(QPointF(0.5, 0.5), 1);
viewport()->update();
emit viewZoomed();
} }
void DisassemblerGraphView::takeTrue() void DisassemblerGraphView::takeTrue()

View File

@ -131,6 +131,7 @@ public slots:
void fontsUpdatedSlot(); void fontsUpdatedSlot();
void onSeekChanged(RVA addr); void onSeekChanged(RVA addr);
void zoom(QPointF mouseRelativePos, double velocity); void zoom(QPointF mouseRelativePos, double velocity);
void setZoom(QPointF mouseRelativePos, double scale);
void zoomIn(); void zoomIn();
void zoomOut(); void zoomOut();
void zoomReset(); void zoomReset();