From cd968569599b3fea549ba7a380cb7c2339a18c74 Mon Sep 17 00:00:00 2001 From: Vanellope Date: Sun, 17 Feb 2019 22:31:00 +0900 Subject: [PATCH] Fixed a scaling issue of Graph (#1200) * Fixed a scaling issue of Graph * Thoroughly fixed for the scaling * double click fixed --- src/widgets/DisassemblerGraphView.cpp | 4 ++-- src/widgets/GraphView.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index bf8f06cb..6455fcac 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -531,7 +531,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block) qreal lineHeightRender = charHeight; for (auto &line : db.header_text.lines) { qreal lineYRender = y; - + lineYRender *= current_scale; // Check if line does NOT intersects with view area if (0 > lineYRender + lineHeightRender || render_height < lineYRender) { @@ -557,7 +557,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block) } for (auto &line : instr.text.lines) { qreal lineYRender = y; - + lineYRender *= current_scale; if (0 > lineYRender + lineHeightRender || render_height < lineYRender) { y += charHeight; diff --git a/src/widgets/GraphView.cpp b/src/widgets/GraphView.cpp index 3fae7d04..536da0f4 100644 --- a/src/widgets/GraphView.cpp +++ b/src/widgets/GraphView.cpp @@ -750,8 +750,8 @@ bool GraphView::checkPointClicked(QPointF &point, int x, int y, bool above_y) // Mouse events void GraphView::mousePressEvent(QMouseEvent *event) { - int x = event->pos().x() + offset_x; - int y = event->pos().y() + offset_y; + int x = event->pos().x() / current_scale + offset_x; + int y = event->pos().y() / current_scale + offset_y; // Check if a block was clicked for (auto &blockIt : blocks) { @@ -806,8 +806,8 @@ void GraphView::mousePressEvent(QMouseEvent *event) void GraphView::mouseMoveEvent(QMouseEvent *event) { if (scroll_mode) { - offset_x += scroll_base_x - event->x(); - offset_y += scroll_base_y - event->y(); + offset_x += (scroll_base_x - event->x()) / current_scale; + offset_y += (scroll_base_y - event->y()) / current_scale; scroll_base_x = event->x(); scroll_base_y = event->y(); viewport()->update(); @@ -816,8 +816,8 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) void GraphView::mouseDoubleClickEvent(QMouseEvent *event) { - int x = event->pos().x() + offset_x; - int y = event->pos().y() + offset_y; + int x = event->pos().x() / current_scale + offset_x; + int y = event->pos().y() / current_scale + offset_y; // Check if a block was clicked for (auto &blockIt : blocks) { @@ -853,8 +853,8 @@ void GraphView::mouseReleaseEvent(QMouseEvent *event) void GraphView::wheelEvent(QWheelEvent *event) { const QPoint delta = -event->angleDelta(); - offset_x += delta.x() * current_scale; - offset_y += delta.y() * current_scale; + offset_x += delta.x() / current_scale; + offset_y += delta.y() / current_scale; viewport()->update(); event->accept(); }