From 9d2a8d9deb9018198e01dcc72ef7decf6c2f6370 Mon Sep 17 00:00:00 2001 From: karliss Date: Sun, 13 Oct 2019 17:22:55 +0300 Subject: [PATCH] Fix graph zoom reset and use same font size as everything else. (#1835) --- src/widgets/DisassemblerGraphView.cpp | 16 ++++++++++------ src/widgets/DisassemblerGraphView.h | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index 42903806..f54178e5 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -401,7 +401,7 @@ void DisassemblerGraphView::cleanupEdges() void DisassemblerGraphView::initFont() { - setFont(Config()->getBaseFont()); + setFont(Config()->getFont()); QFontMetricsF metrics(font()); baseline = int(metrics.ascent()); charWidth = metrics.width('X'); @@ -418,7 +418,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block, p.setPen(Qt::black); p.setBrush(Qt::gray); - p.setFont(Config()->getBaseFont()); + p.setFont(Config()->getFont()); p.drawRect(blockRect); breakpoints = Core()->getBreakpointsAddresses(); @@ -775,6 +775,12 @@ void DisassemblerGraphView::onSeekChanged(RVA addr) } 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.ry() *= size().height(); @@ -782,7 +788,7 @@ void DisassemblerGraphView::zoom(QPointF mouseRelativePos, double velocity) auto globalMouse = mouseRelativePos + getViewOffset(); mouseRelativePos *= getViewScale(); - qreal newScale = getViewScale() * std::pow(1.25, velocity); + qreal newScale = scale; newScale = std::max(newScale, 0.05); mouseRelativePos /= newScale; setViewScale(newScale); @@ -806,9 +812,7 @@ void DisassemblerGraphView::zoomOut() void DisassemblerGraphView::zoomReset() { - setViewScale(1.0); - viewport()->update(); - emit viewZoomed(); + setZoom(QPointF(0.5, 0.5), 1); } void DisassemblerGraphView::takeTrue() diff --git a/src/widgets/DisassemblerGraphView.h b/src/widgets/DisassemblerGraphView.h index 2951640d..e51655fd 100644 --- a/src/widgets/DisassemblerGraphView.h +++ b/src/widgets/DisassemblerGraphView.h @@ -131,6 +131,7 @@ public slots: void fontsUpdatedSlot(); void onSeekChanged(RVA addr); void zoom(QPointF mouseRelativePos, double velocity); + void setZoom(QPointF mouseRelativePos, double scale); void zoomIn(); void zoomOut(); void zoomReset();