mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-22 06:33:46 +00:00
parent
14c64e01f3
commit
3e645980fc
@ -133,6 +133,15 @@ QPolygonF GraphView::recalculatePolygon(QPolygonF polygon)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::beginMouseDrag(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
scroll_base_x = event->x();
|
||||||
|
scroll_base_y = event->y();
|
||||||
|
scroll_mode = true;
|
||||||
|
setCursor(Qt::ClosedHandCursor);
|
||||||
|
viewport()->grabMouse();
|
||||||
|
}
|
||||||
|
|
||||||
void GraphView::paintEvent(QPaintEvent *)
|
void GraphView::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
@ -352,6 +361,11 @@ bool GraphView::checkPointClicked(QPointF &point, int x, int y, bool above_y)
|
|||||||
// Mouse events
|
// Mouse events
|
||||||
void GraphView::mousePressEvent(QMouseEvent *event)
|
void GraphView::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if (event->button() == Qt::MiddleButton) {
|
||||||
|
beginMouseDrag(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int x = event->pos().x() / current_scale + offset.x();
|
int x = event->pos().x() / current_scale + offset.x();
|
||||||
int y = event->pos().y() / current_scale + offset.y();
|
int y = event->pos().y() / current_scale + offset.y();
|
||||||
|
|
||||||
@ -396,11 +410,7 @@ void GraphView::mousePressEvent(QMouseEvent *event)
|
|||||||
// No block was clicked
|
// No block was clicked
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
//Left click outside any block, enter scrolling mode
|
//Left click outside any block, enter scrolling mode
|
||||||
scroll_base_x = event->x();
|
beginMouseDrag(event);
|
||||||
scroll_base_y = event->y();
|
|
||||||
scroll_mode = true;
|
|
||||||
setCursor(Qt::ClosedHandCursor);
|
|
||||||
viewport()->grabMouse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -442,10 +452,7 @@ void GraphView::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
// else if(event->button() == Qt::BackButton)
|
// else if(event->button() == Qt::BackButton)
|
||||||
// gotoPreviousSlot();
|
// gotoPreviousSlot();
|
||||||
|
|
||||||
if (event->button() != Qt::LeftButton)
|
if (scroll_mode && (event->buttons() & (Qt::LeftButton | Qt::MiddleButton)) == 0) {
|
||||||
return;
|
|
||||||
|
|
||||||
if (scroll_mode) {
|
|
||||||
scroll_mode = false;
|
scroll_mode = false;
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
viewport()->releaseMouse();
|
viewport()->releaseMouse();
|
||||||
@ -454,6 +461,11 @@ void GraphView::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
void GraphView::wheelEvent(QWheelEvent *event)
|
void GraphView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
|
if (scroll_mode) {
|
||||||
|
// With some mice it's easy to hit sideway scroll button while holding middle mouse.
|
||||||
|
// That would result in unwanted scrolling while panning.
|
||||||
|
return;
|
||||||
|
}
|
||||||
QPoint delta = -event->angleDelta();
|
QPoint delta = -event->angleDelta();
|
||||||
|
|
||||||
delta /= current_scale;
|
delta /= current_scale;
|
||||||
|
@ -133,6 +133,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
QPolygonF recalculatePolygon(QPolygonF polygon);
|
QPolygonF recalculatePolygon(QPolygonF polygon);
|
||||||
|
void beginMouseDrag(QMouseEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHVIEW_H
|
#endif // GRAPHVIEW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user