From ac3b441cba9570279d0d67fd6ac4354e393d4c83 Mon Sep 17 00:00:00 2001 From: Bas Ruigrok Date: Sat, 9 Aug 2025 18:54:51 +0200 Subject: [PATCH] Gui: Reset navigation flags when the new mode is not IDLE or when the mouse buttons are released --- src/Gui/Navigation/BlenderNavigationStyle.cpp | 7 +++++++ src/Gui/Navigation/CADNavigationStyle.cpp | 7 +++++++ src/Gui/Navigation/InventorNavigationStyle.cpp | 7 +++++++ src/Gui/Navigation/NavigationStyle.cpp | 14 ++++++++------ src/Gui/Navigation/OpenCascadeNavigationStyle.cpp | 7 +++++++ src/Gui/Navigation/OpenSCADNavigationStyle.cpp | 7 +++++++ src/Gui/Navigation/RevitNavigationStyle.cpp | 7 +++++++ src/Gui/Navigation/SolidWorksNavigationStyle.cpp | 7 +++++++ src/Gui/Navigation/TinkerCADNavigationStyle.cpp | 7 +++++++ src/Gui/Navigation/TouchpadNavigationStyle.cpp | 7 +++++++ 10 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/Gui/Navigation/BlenderNavigationStyle.cpp b/src/Gui/Navigation/BlenderNavigationStyle.cpp index d18513f8f1..e44b79f738 100644 --- a/src/Gui/Navigation/BlenderNavigationStyle.cpp +++ b/src/Gui/Navigation/BlenderNavigationStyle.cpp @@ -299,6 +299,13 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) processed = false; } + // Reset flags when newmode is IDLE and the buttons are released + if (newmode == IDLE && !button1down && !button2down && !button3down) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode != curmode) { this->setViewingMode(newmode); } diff --git a/src/Gui/Navigation/CADNavigationStyle.cpp b/src/Gui/Navigation/CADNavigationStyle.cpp index 2c242436f0..09c519a25e 100644 --- a/src/Gui/Navigation/CADNavigationStyle.cpp +++ b/src/Gui/Navigation/CADNavigationStyle.cpp @@ -315,6 +315,13 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) processed = false; } + // Reset flags when newmode is IDLE and the buttons are released + if (newmode == IDLE && !button1down && !button2down && !button3down) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode != curmode) { this->setViewingMode(newmode); } diff --git a/src/Gui/Navigation/InventorNavigationStyle.cpp b/src/Gui/Navigation/InventorNavigationStyle.cpp index 2f09ead1f6..b8d4ceb91a 100644 --- a/src/Gui/Navigation/InventorNavigationStyle.cpp +++ b/src/Gui/Navigation/InventorNavigationStyle.cpp @@ -297,6 +297,13 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) processed = false; } + // Reset flags when newmode is IDLE and the buttons are released + if (newmode == IDLE && !button1down && !button2down && !button3down) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode != curmode) { this->setViewingMode(newmode); } diff --git a/src/Gui/Navigation/NavigationStyle.cpp b/src/Gui/Navigation/NavigationStyle.cpp index ba02def974..9a5761bb82 100644 --- a/src/Gui/Navigation/NavigationStyle.cpp +++ b/src/Gui/Navigation/NavigationStyle.cpp @@ -1591,6 +1591,14 @@ void NavigationStyle::syncModifierKeys(const SoEvent * const ev) void NavigationStyle::setViewingMode(const ViewerMode newmode) { const ViewerMode oldmode = this->currentmode; + + // Reset flags when changing from IDLE to another mode or if the mode is IDLE and the buttons are released + if ((oldmode == IDLE && newmode != IDLE) || (newmode == IDLE && !button1down && !button2down && !button3down)) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode == oldmode) { // The rotation center could have been changed even if the mode has not changed @@ -1601,12 +1609,6 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode) return; } - if (newmode == NavigationStyle::IDLE) { - hasPanned = false; - hasDragged = false; - hasZoomed = false; - } - switch (newmode) { case DRAGGING: // Set up initial projection point for the projector object when diff --git a/src/Gui/Navigation/OpenCascadeNavigationStyle.cpp b/src/Gui/Navigation/OpenCascadeNavigationStyle.cpp index 7af1705f5a..f6d8b1bad3 100644 --- a/src/Gui/Navigation/OpenCascadeNavigationStyle.cpp +++ b/src/Gui/Navigation/OpenCascadeNavigationStyle.cpp @@ -273,6 +273,13 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) processed = false; } + // Reset flags when newmode is IDLE and the buttons are released + if (newmode == IDLE && !button1down && !button2down && !button3down) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode != curmode) { this->setViewingMode(newmode); } diff --git a/src/Gui/Navigation/OpenSCADNavigationStyle.cpp b/src/Gui/Navigation/OpenSCADNavigationStyle.cpp index 3603df95a6..68eec6efc5 100644 --- a/src/Gui/Navigation/OpenSCADNavigationStyle.cpp +++ b/src/Gui/Navigation/OpenSCADNavigationStyle.cpp @@ -268,6 +268,13 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) processed = false; } + // Reset flags when newmode is IDLE and the buttons are released + if (newmode == IDLE && !button1down && !button2down && !button3down) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode != curmode) { this->setViewingMode(newmode); } diff --git a/src/Gui/Navigation/RevitNavigationStyle.cpp b/src/Gui/Navigation/RevitNavigationStyle.cpp index e22d0b4119..b5c4c570e6 100644 --- a/src/Gui/Navigation/RevitNavigationStyle.cpp +++ b/src/Gui/Navigation/RevitNavigationStyle.cpp @@ -296,6 +296,13 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev) processed = false; } + // Reset flags when newmode is IDLE and the buttons are released + if (newmode == IDLE && !button1down && !button2down && !button3down) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode != curmode) { this->setViewingMode(newmode); } diff --git a/src/Gui/Navigation/SolidWorksNavigationStyle.cpp b/src/Gui/Navigation/SolidWorksNavigationStyle.cpp index 50ba26e1ac..f8c4db5a45 100644 --- a/src/Gui/Navigation/SolidWorksNavigationStyle.cpp +++ b/src/Gui/Navigation/SolidWorksNavigationStyle.cpp @@ -295,6 +295,13 @@ SbBool SolidWorksNavigationStyle::processSoEvent(const SoEvent * const ev) processed = false; } + // Reset flags when newmode is IDLE and the buttons are released + if (newmode == IDLE && !button1down && !button2down && !button3down) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode != curmode) { this->setViewingMode(newmode); } diff --git a/src/Gui/Navigation/TinkerCADNavigationStyle.cpp b/src/Gui/Navigation/TinkerCADNavigationStyle.cpp index 0a4c3516a1..1874f46878 100644 --- a/src/Gui/Navigation/TinkerCADNavigationStyle.cpp +++ b/src/Gui/Navigation/TinkerCADNavigationStyle.cpp @@ -245,6 +245,13 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) processed = false; } + // Reset flags when newmode is IDLE and the buttons are released + if (newmode == IDLE && !button1down && !button2down && !button3down) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode != curmode) { this->setViewingMode(newmode); } diff --git a/src/Gui/Navigation/TouchpadNavigationStyle.cpp b/src/Gui/Navigation/TouchpadNavigationStyle.cpp index 1f8837511f..957652e8a0 100644 --- a/src/Gui/Navigation/TouchpadNavigationStyle.cpp +++ b/src/Gui/Navigation/TouchpadNavigationStyle.cpp @@ -272,6 +272,13 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev) processed = false; } + // Reset flags when newmode is IDLE and the buttons are released + if (newmode == IDLE && !button1down && !button2down && !button3down) { + hasPanned = false; + hasDragged = false; + hasZoomed = false; + } + if (newmode != curmode) { this->setViewingMode(newmode); }