Fixed a scaling issue of Graph (#1200)

* Fixed a scaling issue of Graph

* Thoroughly fixed for the scaling

* double click fixed
This commit is contained in:
Vanellope 2019-02-17 22:31:00 +09:00 committed by Itay Cohen
parent f8cebe0e30
commit cd96856959
2 changed files with 10 additions and 10 deletions

View File

@ -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;

View File

@ -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();
}