Gui: Prevent showing the context menu after dragging, panning or zooming
This commit is contained in:
@@ -142,16 +142,17 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
// If we are in edit mode then simply ignore the RMB events
|
||||
// to pass the event to the base class.
|
||||
this->lockrecenter = true;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in zoom or pan mode ignore RMB events otherwise
|
||||
// the canvas doesn't get any release events
|
||||
|
||||
// Don't show the context menu after dragging, panning or zooming
|
||||
if (!press && (hasDragged || hasPanned || hasZoomed)) {
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && !viewer->isEditing()) {
|
||||
if (this->currentmode != NavigationStyle::ZOOMING &&
|
||||
this->currentmode != NavigationStyle::PANNING &&
|
||||
this->currentmode != NavigationStyle::DRAGGING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
if (!press) { // release right mouse button
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,16 +144,17 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
// If we are in edit mode then simply ignore the RMB events
|
||||
// to pass the event to the base class.
|
||||
this->lockrecenter = true;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in zoom or pan mode ignore RMB events otherwise
|
||||
// the canvas doesn't get any release events
|
||||
|
||||
// Don't show the context menu after dragging, panning or zooming
|
||||
if (!press && (hasDragged || hasPanned || hasZoomed)) {
|
||||
processed = true;
|
||||
}
|
||||
if (!press && !viewer->isEditing()) {
|
||||
if (this->currentmode != NavigationStyle::ZOOMING &&
|
||||
this->currentmode != NavigationStyle::PANNING &&
|
||||
this->currentmode != NavigationStyle::DRAGGING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
if (!press) { // release right mouse button
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,15 +172,17 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
// If we are in edit mode then simply ignore the RMB events
|
||||
// to pass the event to the base class.
|
||||
this->lockrecenter = true;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in zoom or pan mode ignore RMB events otherwise
|
||||
// the canvas doesn't get any release events
|
||||
|
||||
// Don't show the context menu after dragging, panning or zooming
|
||||
if (!press && (hasDragged || hasPanned || hasZoomed)) {
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && !viewer->isEditing()) {
|
||||
if (this->currentmode != NavigationStyle::ZOOMING &&
|
||||
this->currentmode != NavigationStyle::PANNING) {
|
||||
this->currentmode != NavigationStyle::PANNING &&
|
||||
this->currentmode != NavigationStyle::DRAGGING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
if (!press) { // release right mouse button
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,20 +291,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
newmode = NavigationStyle::ZOOMING;
|
||||
break;
|
||||
|
||||
// There are many cases we don't handle that just falls through to
|
||||
// the default case, like SHIFTDOWN, CTRLDOWN, CTRLDOWN|SHIFTDOWN,
|
||||
// SHIFTDOWN|BUTTON3DOWN, SHIFTDOWN|CTRLDOWN|BUTTON3DOWN, etc.
|
||||
// This is a feature, not a bug. :-)
|
||||
//
|
||||
// mortene.
|
||||
|
||||
default:
|
||||
// The default will make a spin stop and otherwise not do
|
||||
// anything.
|
||||
if ((curmode != NavigationStyle::SEEK_WAIT_MODE) &&
|
||||
(curmode != NavigationStyle::SEEK_MODE)) {
|
||||
newmode = NavigationStyle::IDLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,6 +260,7 @@ void NavigationStyle::initialize()
|
||||
|
||||
this->hasDragged = false;
|
||||
this->hasPanned = false;
|
||||
this->hasZoomed = false;
|
||||
}
|
||||
|
||||
void NavigationStyle::finalize()
|
||||
@@ -586,7 +587,10 @@ void NavigationStyle::panCamera(SoCamera * cam, float aspectratio, const SbPlane
|
||||
// Reposition camera according to the vector difference between the
|
||||
// projected points.
|
||||
cam->position = cam->position.getValue() - (current_planept - old_planept);
|
||||
hasPanned = true;
|
||||
|
||||
if (this->currentmode != NavigationStyle::IDLE) {
|
||||
hasPanned = true;
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationStyle::pan(SoCamera* camera)
|
||||
@@ -695,6 +699,10 @@ void NavigationStyle::zoom(SoCamera * cam, float diffvalue)
|
||||
cam->focalDistance = newfocaldist;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->currentmode != NavigationStyle::IDLE) {
|
||||
hasZoomed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate a zoom/dolly factor from the difference of the current
|
||||
@@ -900,7 +908,9 @@ void NavigationStyle::spin(const SbVec2f & pointerpos)
|
||||
// animation.
|
||||
if (this->spinsamplecounter > 3) this->spinsamplecounter = 3;
|
||||
|
||||
hasDragged = true;
|
||||
if (this->currentmode != NavigationStyle::IDLE) {
|
||||
hasDragged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1352,9 +1362,10 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode)
|
||||
return;
|
||||
}
|
||||
|
||||
if (newmode != NavigationStyle::IDLE) {
|
||||
if (newmode == NavigationStyle::IDLE) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
switch (newmode) {
|
||||
|
||||
@@ -261,6 +261,7 @@ protected:
|
||||
float zoomStep;
|
||||
SbBool hasDragged;
|
||||
SbBool hasPanned;
|
||||
SbBool hasZoomed;
|
||||
|
||||
/** @name Mouse model */
|
||||
//@{
|
||||
|
||||
@@ -139,16 +139,17 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
// If we are in edit mode then simply ignore the RMB events
|
||||
// to pass the event to the base class.
|
||||
this->lockrecenter = true;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in zoom or pan mode ignore RMB events otherwise
|
||||
// the canvas doesn't get any release events
|
||||
|
||||
// Don't show the context menu after dragging, panning or zooming
|
||||
if (!press && (hasDragged || hasPanned || hasZoomed)) {
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && !viewer->isEditing()) {
|
||||
if (this->currentmode != NavigationStyle::ZOOMING &&
|
||||
this->currentmode != NavigationStyle::PANNING &&
|
||||
this->currentmode != NavigationStyle::DRAGGING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
if (!press) { // release right mouse button
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,17 +140,16 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
// to pass the event to the base class.
|
||||
this->lockrecenter = true;
|
||||
this->button2down = press;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in zoom or pan mode ignore RMB events otherwise
|
||||
// the canvas doesn't get any release events
|
||||
if ((curmode != NavigationStyle::ZOOMING &&
|
||||
curmode != NavigationStyle::PANNING &&
|
||||
curmode != NavigationStyle::DRAGGING) ||
|
||||
(curmode == NavigationStyle::PANNING && !hasPanned)) {
|
||||
|
||||
// Don't show the context menu after dragging, panning or zooming
|
||||
if (!press && (hasDragged || hasPanned || hasZoomed)) {
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && !viewer->isEditing()) {
|
||||
if (this->currentmode != NavigationStyle::ZOOMING &&
|
||||
this->currentmode != NavigationStyle::DRAGGING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
if (!press) { // release right mouse button
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,9 +165,6 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
newmode = NavigationStyle::IDLE;
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && curmode == NavigationStyle::PANNING && hasPanned) {
|
||||
processed = true;
|
||||
}
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON3:
|
||||
this->button3down = press;
|
||||
|
||||
@@ -141,16 +141,17 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
// If we are in edit mode then simply ignore the RMB events
|
||||
// to pass the event to the base class.
|
||||
this->lockrecenter = true;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in zoom or pan mode ignore RMB events otherwise
|
||||
// the canvas doesn't get any release events
|
||||
|
||||
// Don't show the context menu after dragging, panning or zooming
|
||||
if (!press && (hasDragged || hasPanned || hasZoomed)) {
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && !viewer->isEditing()) {
|
||||
if (this->currentmode != NavigationStyle::ZOOMING &&
|
||||
this->currentmode != NavigationStyle::PANNING &&
|
||||
this->currentmode != NavigationStyle::DRAGGING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
if (!press) { // release right mouse button
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,15 +142,18 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
this->centerTime = ev->getTime();
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && curmode == NavigationStyle::DRAGGING && hasDragged) {
|
||||
// Don't show the context menu after dragging, panning or zooming
|
||||
else if (!press && (hasDragged || hasPanned || hasZoomed)) {
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && curmode == NavigationStyle::DRAGGING && !hasDragged) {
|
||||
else if (!press) {
|
||||
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());
|
||||
if (this->currentmode != NavigationStyle::ZOOMING &&
|
||||
this->currentmode != NavigationStyle::PANNING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
processed = true;
|
||||
}
|
||||
|
||||
@@ -138,16 +138,17 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
// If we are in edit mode then simply ignore the RMB events
|
||||
// to pass the event to the base class.
|
||||
this->lockrecenter = true;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in zoom or pan mode ignore RMB events otherwise
|
||||
// the canvas doesn't get any release events
|
||||
|
||||
// Don't show the context menu after dragging, panning or zooming
|
||||
if (!press && (hasDragged || hasPanned || hasZoomed)) {
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && !viewer->isEditing()) {
|
||||
if (this->currentmode != NavigationStyle::ZOOMING &&
|
||||
this->currentmode != NavigationStyle::PANNING &&
|
||||
this->currentmode != NavigationStyle::DRAGGING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
if (!press) { // release right mouse button
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user