From 58d319511a50c8e630b1ce4bc7d69915e24a1bc3 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Mon, 20 Oct 2025 20:17:04 +0200 Subject: [PATCH] Gui: Add navigation modes to distinguish which nav mode requires CTRL --- src/Gui/Navigation/GestureNavigationStyle.h | 1 + src/Gui/Navigation/NavigationStyle.h | 9 +++++++++ src/Gui/View3DInventorViewer.cpp | 18 ++++-------------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Gui/Navigation/GestureNavigationStyle.h b/src/Gui/Navigation/GestureNavigationStyle.h index 92e5c6874e..dc86f50a64 100644 --- a/src/Gui/Navigation/GestureNavigationStyle.h +++ b/src/Gui/Navigation/GestureNavigationStyle.h @@ -42,6 +42,7 @@ public: GestureNavigationStyle(); ~GestureNavigationStyle() override; const char* mouseButtons(ViewerMode) override; + ClarifySelectionMode clarifySelectionMode() const override { return ClarifySelectionMode::Ctrl; } protected: SbBool processSoEvent(const SoEvent* const ev) override; diff --git a/src/Gui/Navigation/NavigationStyle.h b/src/Gui/Navigation/NavigationStyle.h index 270a1706b8..246471ce08 100644 --- a/src/Gui/Navigation/NavigationStyle.h +++ b/src/Gui/Navigation/NavigationStyle.h @@ -105,6 +105,11 @@ public: Clip = 4, /**< Clip objects using a lasso. */ }; + enum class ClarifySelectionMode { + Default, /**< Long press with LMB to trigger clarify selection */ + Ctrl /**< Long press with Ctrl+LMB to trigger clarify selection */ + }; + enum OrbitStyle { Turntable, Trackball, @@ -192,6 +197,8 @@ public: bool isDraggerUnderCursor(const SbVec2s pos) const; + virtual ClarifySelectionMode clarifySelectionMode() const { return ClarifySelectionMode::Default; } + void setOrbitStyle(OrbitStyle style); OrbitStyle getOrbitStyle() const; @@ -353,6 +360,7 @@ public: ~InventorNavigationStyle() override; const char* mouseButtons(ViewerMode) override; std::string userFriendlyName() const override; + ClarifySelectionMode clarifySelectionMode() const override { return ClarifySelectionMode::Ctrl; } protected: SbBool processSoEvent(const SoEvent * const ev) override; @@ -492,6 +500,7 @@ public: OpenSCADNavigationStyle(); ~OpenSCADNavigationStyle() override; const char* mouseButtons(ViewerMode) override; + ClarifySelectionMode clarifySelectionMode() const override { return ClarifySelectionMode::Ctrl; } protected: SbBool processSoEvent(const SoEvent * const ev) override; diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 0ca79ddc8e..5523d6e9ba 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -186,25 +186,15 @@ private: return false; } - // for navigation styles that use primarily LMB for rotation, we require - // to get CTRL+LMB combo to toggle long press auto* navStyle = viewer->navigationStyle(); if (navStyle) { - Base::Type navType = navStyle->getTypeId(); - if (navType == InventorNavigationStyle::getClassTypeId() || - navType == GestureNavigationStyle::getClassTypeId() || - navType == OpenSCADNavigationStyle::getClassTypeId()) { - if (!ctrlPressed) { - return false; - } + // reject if navigation style requires ctrl and it's not pressed or we're under a dragger + if ((navStyle->clarifySelectionMode() == NavigationStyle::ClarifySelectionMode::Ctrl && !ctrlPressed) || + navStyle->isDraggerUnderCursor(SbVec2s(pos.x(), pos.y()))) { + return false; } } - // finally, discard long press if we are under a dragger - if (navStyle && navStyle->isDraggerUnderCursor(SbVec2s(pos.x(), pos.y()))) { - return false; - } - return true; }