mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 16:47:26 +00:00
Graph improvements (#500)
* Add antialiasing to graphview * Make panning speed up/slow down with current zoom * Made scrolling proportional to zoom level
This commit is contained in:
parent
8ac598f992
commit
55be4efb8c
@ -411,6 +411,9 @@ void GraphView::paintEvent(QPaintEvent *event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
QPainter p(viewport());
|
QPainter p(viewport());
|
||||||
|
|
||||||
|
p.setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
int render_offset_x = -horizontalScrollBar()->value() * current_scale;
|
int render_offset_x = -horizontalScrollBar()->value() * current_scale;
|
||||||
int render_offset_y = -verticalScrollBar()->value() * current_scale;
|
int render_offset_y = -verticalScrollBar()->value() * current_scale;
|
||||||
int render_width = viewport()->size().width() / current_scale;
|
int render_width = viewport()->size().width() / current_scale;
|
||||||
@ -861,8 +864,8 @@ void GraphView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
int y_delta = scroll_base_y - event->y();
|
int y_delta = scroll_base_y - event->y();
|
||||||
scroll_base_x = event->x();
|
scroll_base_x = event->x();
|
||||||
scroll_base_y = event->y();
|
scroll_base_y = event->y();
|
||||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + x_delta);
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + x_delta * (1/current_scale));
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->value() + y_delta);
|
verticalScrollBar()->setValue(verticalScrollBar()->value() + y_delta * (1/current_scale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,3 +906,13 @@ void GraphView::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
viewport()->releaseMouse();
|
viewport()->releaseMouse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
const QPoint delta = -event->angleDelta();
|
||||||
|
int x_delta = delta.x();
|
||||||
|
int y_delta = delta.y();
|
||||||
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + x_delta * (1/current_scale));
|
||||||
|
verticalScrollBar()->setValue(verticalScrollBar()->value() + y_delta * (1/current_scale));
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
@ -121,6 +121,7 @@ protected:
|
|||||||
virtual void blockHelpEvent(GraphView::GraphBlock &block, QHelpEvent *event, QPoint pos);
|
virtual void blockHelpEvent(GraphView::GraphBlock &block, QHelpEvent *event, QPoint pos);
|
||||||
virtual bool helpEvent(QHelpEvent *event);
|
virtual bool helpEvent(QHelpEvent *event);
|
||||||
virtual void blockTransitionedTo(GraphView::GraphBlock *to);
|
virtual void blockTransitionedTo(GraphView::GraphBlock *to);
|
||||||
|
virtual void wheelEvent(QWheelEvent *event) override;
|
||||||
virtual EdgeConfiguration edgeConfiguration(GraphView::GraphBlock &from, GraphView::GraphBlock *to);
|
virtual EdgeConfiguration edgeConfiguration(GraphView::GraphBlock &from, GraphView::GraphBlock *to);
|
||||||
|
|
||||||
void adjustSize(int new_width, int new_height, QPoint mouse = QPoint(0, 0));
|
void adjustSize(int new_width, int new_height, QPoint mouse = QPoint(0, 0));
|
||||||
|
Loading…
Reference in New Issue
Block a user