Gui: Gesture: add option to disable tilt

On Qt5, using pinch will inevitably cause tilt. It's annoying, so it is disabled by default.

In the future, it's best to introduce some kind of threshold to overcome for the tilt to be triggered.
This commit is contained in:
DeepSOIC
2018-11-27 14:33:47 +03:00
committed by Yorik van Havre
parent 8ba6df2548
commit 47ae980fa2
6 changed files with 74 additions and 18 deletions

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>477</width>
<height>505</height>
<height>630</height>
</rect>
</property>
<property name="windowTitle">
@@ -323,6 +323,25 @@
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxDisableTilt">
<property name="toolTip">
<string>Prevents view tilting when pinch-zooming. Affects only Gesture nav. style. Mouse tilting is not disabled by this setting.</string>
</property>
<property name="text">
<string>Disable touchscreen tilt gesture</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>DisableTouchTilt</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxDragAtCursor">
<property name="text">
@@ -344,7 +363,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -423,6 +451,16 @@
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="backlightLayout">
<property name="leftMargin">
@@ -598,13 +636,8 @@
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSlider</class>
<extends>QSlider</extends>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
@@ -613,13 +646,18 @@
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<class>Gui::PrefComboBox</class>
<extends>QComboBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefComboBox</class>
<extends>QComboBox</extends>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSlider</class>
<extends>QSlider</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>

View File

@@ -88,6 +88,7 @@ void DlgSettings3DViewImp::saveSettings()
checkBoxZoomAtCursor->onSave();
checkBoxInvertZoom->onSave();
checkBoxDisableTilt->onSave();
spinBoxZoomStep->onSave();
checkBoxDragAtCursor->onSave();
CheckBox_CornerCoordSystem->onSave();
@@ -107,6 +108,7 @@ void DlgSettings3DViewImp::loadSettings()
{
checkBoxZoomAtCursor->onRestore();
checkBoxInvertZoom->onRestore();
checkBoxDisableTilt->onRestore();
spinBoxZoomStep->onRestore();
checkBoxDragAtCursor->onRestore();
CheckBox_CornerCoordSystem->onRestore();

View File

@@ -236,10 +236,13 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent * const ev)
if (evIsGesture) {
const SoGestureEvent* gesture = static_cast<const SoGestureEvent*>(ev);
switch(gesture->state) {
case SoGestureEvent::SbGSStart:
case SoGestureEvent::SbGSStart:{
//assert(!inGesture);//start of another gesture before the first finished? Happens all the time for Pan gesture... No idea why! --DeepSOIC
inGesture = true;
break;
enableGestureTilt = !(App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View")->GetBool("DisableTouchTilt",true));
}break;
case SoGestureEvent::SbGSUpdate:
assert(inGesture);//gesture update without start?
inGesture = true;
@@ -551,7 +554,7 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent * const ev)
NavigationStyle::panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, panDist, SbVec2f(0,0));
}
NavigationStyle::doZoom(viewer->getSoRenderManager()->getCamera(),-logf(event->deltaZoom),this->normalizePixelPos(event->curCenter));
if (event->deltaAngle != 0)
if (event->deltaAngle != 0 && enableGestureTilt)
NavigationStyle::doRotate(viewer->getSoRenderManager()->getCamera(),event->deltaAngle,this->normalizePixelPos(event->curCenter));
processed = true;
}

View File

@@ -412,6 +412,7 @@ protected:
bool thisClickIsComplex;//a flag that becomes set when a complex clicking pattern is detected (i.e., two or more mouse buttons were down at the same time).
bool inGesture; //a flag that is used to filter out mouse events during gestures.
bool enableGestureTilt = false; //fetched from settings
};
class GuiExport OpenCascadeNavigationStyle : public UserNavigationStyle {

View File

@@ -922,6 +922,8 @@ void View3DInventorViewer::setNavigationType(Base::Type t)
if (t.isBad())
return;
this->winGestureTuneState = View3DInventorViewer::ewgtsNeedTuning; //triggers enable/disable rotation gesture when preferences change
if (this->navigation && this->navigation->getTypeId() == t)
return; // nothing to do

View File

@@ -42,6 +42,8 @@
#include <qgesture.h>
#include <Base/Exception.h>
#include <App/Application.h>
#include <Base/Parameter.h>
QT_BEGIN_NAMESPACE
@@ -257,8 +259,16 @@ void WinNativeGestureRecognizerPinch::TuneWindowsGestures(QWidget* target)
cfgs[0].dwID = GID_PAN;
cfgs[0].dwWant = GC_PAN;
cfgs[0].dwBlock = GC_PAN_WITH_GUTTER;//disables stickiness to pure vertical/pure horizontal pans
cfgs[1].dwID = GID_ROTATE;
cfgs[1].dwWant = GC_ROTATE;
bool enableGestureTilt = !(App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View")->GetBool("DisableTouchTilt",true));
if(enableGestureTilt){
cfgs[1].dwID = GID_ROTATE;
cfgs[1].dwWant = GC_ROTATE;
} else {
cfgs[1].dwID = GID_ROTATE;
cfgs[1].dwBlock = GC_ROTATE;
}
//set the options
bool ret = dllSetGestureConfig(w, 0, nCfg, cfgs, sizeof(GESTURECONFIG));