Gui: Only show context menu if not dragged in TinkerCAD navigation style
This commit is contained in:
@@ -258,6 +258,7 @@ void NavigationStyle::initialize()
|
||||
NavigationStyle::RotationCenterMode::BoundingBoxCenter);
|
||||
}
|
||||
|
||||
this->hasDragged = false;
|
||||
this->hasPanned = false;
|
||||
}
|
||||
|
||||
@@ -898,6 +899,8 @@ void NavigationStyle::spin(const SbVec2f & pointerpos)
|
||||
// when the user quickly trigger (as in "click-drag-release") a spin
|
||||
// animation.
|
||||
if (this->spinsamplecounter > 3) this->spinsamplecounter = 3;
|
||||
|
||||
hasDragged = true;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -932,6 +935,7 @@ void NavigationStyle::spin_simplified(SoCamera* cam, SbVec2f curpos, SbVec2f pre
|
||||
r.invert();
|
||||
this->reorientCamera(cam, r);
|
||||
|
||||
hasDragged = true;
|
||||
}
|
||||
|
||||
SbBool NavigationStyle::doSpin()
|
||||
@@ -1348,6 +1352,11 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode)
|
||||
return;
|
||||
}
|
||||
|
||||
if (newmode != NavigationStyle::IDLE) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
}
|
||||
|
||||
switch (newmode) {
|
||||
case DRAGGING:
|
||||
// Set up initial projection point for the projector object when
|
||||
@@ -1368,7 +1377,6 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode)
|
||||
case PANNING:
|
||||
animator->stop();
|
||||
pan(viewer->getSoRenderManager()->getCamera());
|
||||
hasPanned = false;
|
||||
this->interactiveCountInc();
|
||||
break;
|
||||
|
||||
@@ -1390,12 +1398,8 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode)
|
||||
case SPINNING:
|
||||
case DRAGGING:
|
||||
viewer->showRotationCenter(false);
|
||||
this->interactiveCountDec();
|
||||
break;
|
||||
[[fallthrough]];
|
||||
case PANNING:
|
||||
hasPanned = false;
|
||||
this->interactiveCountDec();
|
||||
break;
|
||||
case ZOOMING:
|
||||
case BOXZOOM:
|
||||
this->interactiveCountDec();
|
||||
|
||||
@@ -259,6 +259,7 @@ protected:
|
||||
SbBool invertZoom;
|
||||
SbBool zoomAtCursor;
|
||||
float zoomStep;
|
||||
SbBool hasDragged;
|
||||
SbBool hasPanned;
|
||||
|
||||
/** @name Mouse model */
|
||||
|
||||
@@ -110,7 +110,6 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
const auto event = (const SoMouseButtonEvent *) ev;
|
||||
const int button = event->getButton();
|
||||
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
|
||||
SbBool shortRMBclick = false;
|
||||
|
||||
switch (button) {
|
||||
case SoMouseButtonEvent::BUTTON1:
|
||||
@@ -135,14 +134,6 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
mouseDownConsumedEvent = *event;
|
||||
mouseDownConsumedEvent.setTime(ev->getTime());
|
||||
}
|
||||
else if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON2) {
|
||||
SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime());
|
||||
float dci = float(QApplication::doubleClickInterval())/1000.0f;
|
||||
// time between press and release event
|
||||
if (tmp.getValue() < dci) {
|
||||
shortRMBclick = true;
|
||||
}
|
||||
}
|
||||
|
||||
// About to start rotating
|
||||
if (press && (curmode == NavigationStyle::IDLE)) {
|
||||
@@ -151,16 +142,14 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
this->centerTime = ev->getTime();
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && (curmode == NavigationStyle::DRAGGING)) {
|
||||
if (shortRMBclick) {
|
||||
newmode = NavigationStyle::IDLE;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in drag mode but mouse hasn't been moved open the context-menu
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
processed = true;
|
||||
else if (!press && curmode == NavigationStyle::DRAGGING && !hasDragged) {
|
||||
newmode = NavigationStyle::IDLE;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in drag mode but mouse hasn't been moved open the context-menu
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user