Gui: Add navigation modes to distinguish which nav mode requires CTRL

This commit is contained in:
tetektoza
2025-10-20 20:17:04 +02:00
parent 6a597a9277
commit 58d319511a
3 changed files with 14 additions and 14 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}