Skip to content
Snippets Groups Projects
Commit 76f65fad authored by Philipp Erhardt's avatar Philipp Erhardt
Browse files

Implement infinite dragging/wrap around

parent 6e775cd0
Branches master
No related tags found
No related merge requests found
......@@ -264,6 +264,33 @@ void Canvas::mouseMoveEvent(QMouseEvent *event) {
cur_layout->scroll_smooth(event->x() - mx, event->y() - my);
mx = event->x();
my = event->y();
// wrap mouse around when dragging at the border
if (mx <= 0) {
mx = width() - 2;
QCursor c = cursor();
c.setPos(mapToGlobal(QPoint(mx, my)));
setCursor(c);
}
if (mx >= width() - 1) {
mx = 1;
QCursor c = cursor();
c.setPos(mapToGlobal(QPoint(mx, my)));
setCursor(c);
}
if (my <= 0) {
my = height() - 2;
QCursor c = cursor();
c.setPos(mapToGlobal(QPoint(mx, my)));
setCursor(c);
}
if (my >= height() - 1) {
my = 1;
QCursor c = cursor();
c.setPos(mapToGlobal(QPoint(mx, my)));
setCursor(c);
}
}
if (select_text_button != Qt::NoButton && event->buttons() & select_text_button) {
cur_layout->select(event->x(), event->y(), Selection::End);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment