aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerge Bazanski <sergiusz@q3k.org>2019-02-28 15:26:48 +0100
committerGitHub <noreply@github.com>2019-02-28 15:26:48 +0100
commit9aadfef8c124127f6c9292e34cb4d3b6b61ff0fd (patch)
treec27e858341c874f37e9269da57aa10a9d5684765
parenta2d906a3fdd38b594b4a99d0909ac98301596a05 (diff)
parent9539f57c74717f98a1235dbe8db82906cc7f9d84 (diff)
downloadnextpnr-9aadfef8c124127f6c9292e34cb4d3b6b61ff0fd.tar.gz
nextpnr-9aadfef8c124127f6c9292e34cb4d3b6b61ff0fd.tar.bz2
nextpnr-9aadfef8c124127f6c9292e34cb4d3b6b61ff0fd.zip
Merge pull request #212 from smunaut/gui_shift_move
gui: Allow shift+drag to move around the view
-rw-r--r--gui/fpgaviewwidget.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index 0ad90527..ac6cd969 100644
--- a/gui/fpgaviewwidget.cc
+++ b/gui/fpgaviewwidget.cc
@@ -644,12 +644,16 @@ void FPGAViewWidget::mousePressEvent(QMouseEvent *event)
if (io.WantCaptureMouse)
return;
- if (event->buttons() & Qt::RightButton || event->buttons() & Qt::MidButton) {
+ bool shift = QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
+ bool ctrl = QApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
+ bool btn_right = event->buttons() & Qt::RightButton;
+ bool btn_mid = event->buttons() & Qt::MidButton;
+ bool btn_left = event->buttons() & Qt::LeftButton;
+
+ if (btn_right || btn_mid || (btn_left && shift)) {
lastDragPos_ = event->pos();
}
- if (event->buttons() & Qt::LeftButton) {
- bool ctrl = QApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
-
+ if (btn_left && !shift) {
auto world = mouseToWorldCoordinates(event->x(), event->y());
auto closestOr = pickElement(world.x(), world.y());
if (!closestOr) {
@@ -681,7 +685,12 @@ void FPGAViewWidget::mouseMoveEvent(QMouseEvent *event)
if (io.WantCaptureMouse)
return;
- if (event->buttons() & Qt::RightButton || event->buttons() & Qt::MidButton) {
+ bool shift = QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
+ bool btn_right = event->buttons() & Qt::RightButton;
+ bool btn_mid = event->buttons() & Qt::MidButton;
+ bool btn_left = event->buttons() & Qt::LeftButton;
+
+ if (btn_right || btn_mid || (btn_left && shift)) {
const int dx = event->x() - lastDragPos_.x();
const int dy = event->y() - lastDragPos_.y();
lastDragPos_ = event->pos();