From 323f8bb29f04b7b48f0cbe4e5a04ac6a3f880e6e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 1 Oct 2015 13:42:21 +0200 Subject: [PATCH] sensitivity settings --- apps/opencs/model/settings/usersettings.cpp | 15 +++++++++++ apps/opencs/view/render/editmode.cpp | 4 +-- apps/opencs/view/render/editmode.hpp | 4 +-- apps/opencs/view/render/worldspacewidget.cpp | 27 +++++++++++++++++--- apps/opencs/view/render/worldspacewidget.hpp | 3 +++ 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 5cc60c318..3e5ab24d1 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -405,6 +405,21 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *contextSensitive = createSetting (Type_CheckBox, "context-select", "Context Sensitive Selection"); contextSensitive->setDefaultValue ("false"); + + Setting *dragMouseSensitivity = createSetting (Type_DoubleSpinBox, "drag-factor", + "Mouse sensitivity during drag operations"); + dragMouseSensitivity->setDefaultValue (1.0); + dragMouseSensitivity->setRange (0.001, 100.0); + + Setting *dragWheelSensitivity = createSetting (Type_DoubleSpinBox, "drag-wheel-factor", + "Mouse wheel sensitivity during drag operations"); + dragWheelSensitivity->setDefaultValue (1.0); + dragWheelSensitivity->setRange (0.001, 100.0); + + Setting *dragShiftFactor = createSetting (Type_DoubleSpinBox, "drag-shift-factor", + "Acceleration factor during drag operations while holding down shift"); + dragShiftFactor->setDefaultValue (4.0); + dragShiftFactor->setRange (0.001, 100.0); } { diff --git a/apps/opencs/view/render/editmode.cpp b/apps/opencs/view/render/editmode.cpp index cc76e3362..c35b4f354 100644 --- a/apps/opencs/view/render/editmode.cpp +++ b/apps/opencs/view/render/editmode.cpp @@ -54,10 +54,10 @@ bool CSVRender::EditMode::selectStartDrag (osg::ref_ptr tag) return false; } -void CSVRender::EditMode::drag (int diffX, int diffY) {} +void CSVRender::EditMode::drag (int diffX, int diffY, double speedFactor) {} void CSVRender::EditMode::dragCompleted() {} void CSVRender::EditMode::dragAborted() {} -void CSVRender::EditMode::dragWheel (int diff) {} +void CSVRender::EditMode::dragWheel (int diff, double speedFactor) {} diff --git a/apps/opencs/view/render/editmode.hpp b/apps/opencs/view/render/editmode.hpp index 0a4bdf9b8..77676d6a3 100644 --- a/apps/opencs/view/render/editmode.hpp +++ b/apps/opencs/view/render/editmode.hpp @@ -61,7 +61,7 @@ namespace CSVRender virtual bool selectStartDrag (osg::ref_ptr tag); /// Default-implementation: ignored - virtual void drag (int diffX, int diffY); + virtual void drag (int diffX, int diffY, double speedFactor); /// Default-implementation: ignored virtual void dragCompleted(); @@ -73,7 +73,7 @@ namespace CSVRender virtual void dragAborted(); /// Default-implementation: ignored - virtual void dragWheel (int diff); + virtual void dragWheel (int diff, double speedFactor); }; } diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 3971f76fa..2789cd9d5 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -81,6 +81,10 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg key += sMappingSettings[i]; storeMappingSetting (key, CSMSettings::UserSettings::instance().settingValue (key)); } + + mDragFactor = CSMSettings::UserSettings::instance().settingValue ("scene-input/drag-factor").toDouble(); + mDragWheelFactor = CSMSettings::UserSettings::instance().settingValue ("scene-input/drag-wheel-factor").toDouble(); + mDragShiftFactor = CSMSettings::UserSettings::instance().settingValue ("scene-input/drag-shift-factor").toDouble(); } CSVRender::WorldspaceWidget::~WorldspaceWidget () @@ -284,7 +288,14 @@ void CSVRender::WorldspaceWidget::updateUserSetting (const QString& name, const if (!value.isEmpty() && storeMappingSetting (name, value.first())) return; - dynamic_cast (*mEditMode->getCurrent()).updateUserSetting (name, value); + if (name=="scene-input/drag-factor") + mDragFactor = value.at (0).toDouble(); + else if (name=="scene-input/drag-wheel-factor") + mDragWheelFactor = value.at (0).toDouble(); + else if (name=="scene-input/drag-shift-factor") + mDragShiftFactor = value.at (0).toDouble(); + else + dynamic_cast (*mEditMode->getCurrent()).updateUserSetting (name, value); } void CSVRender::WorldspaceWidget::setEditLock (bool locked) @@ -530,9 +541,14 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) mDragX = event->x(); mDragY = height() - event->y(); + double factor = mDragFactor; + + if (QApplication::keyboardModifiers() & Qt::ShiftModifier) + factor *= mDragShiftFactor; + EditMode& editMode = dynamic_cast (*mEditMode->getCurrent()); - editMode.drag (diffX, diffY); + editMode.drag (diffX, diffY, factor); } RenderWidget::mouseMoveEvent(event); @@ -601,9 +617,14 @@ void CSVRender::WorldspaceWidget::wheelEvent (QWheelEvent *event) { if (mDragging) { + double factor = mDragWheelFactor; + + if (QApplication::keyboardModifiers() & Qt::ShiftModifier) + factor *= mDragShiftFactor; + EditMode& editMode = dynamic_cast (*mEditMode->getCurrent()); - editMode.dragWheel (event->delta()); + editMode.dragWheel (event->delta(), factor); } RenderWidget::wheelEvent(event); diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index f51ce047e..338ebcc97 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -43,6 +43,9 @@ namespace CSVRender bool mDragging; int mDragX; int mDragY; + double mDragFactor; + double mDragWheelFactor; + double mDragShiftFactor; public: