Gui: Add navigation modes to distinguish which nav mode requires CTRL
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user