diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 3e5ab24d1..e8568cac1 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -399,9 +399,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() secondaryEditing->setDeclaredValues (values); secondaryEditing->setDefaultValue (cRight); - Setting *selection = createSetting (Type_ComboBox, "select", "Selection Button"); - selection->setDeclaredValues (values); - selection->setDefaultValue (middle); + Setting *primarySelection = createSetting (Type_ComboBox, "p-select", "Selection Button"); + primarySelection->setDeclaredValues (values); + primarySelection->setDefaultValue (middle); + + Setting *secondarySelection = createSetting (Type_ComboBox, "s-select", "Selection Button"); + secondarySelection->setDeclaredValues (values); + secondarySelection->setDefaultValue (cMiddle); Setting *contextSensitive = createSetting (Type_CheckBox, "context-select", "Context Sensitive Selection"); contextSensitive->setDefaultValue ("false"); diff --git a/apps/opencs/view/render/editmode.cpp b/apps/opencs/view/render/editmode.cpp index 4235faf76..4c6f2bd43 100644 --- a/apps/opencs/view/render/editmode.cpp +++ b/apps/opencs/view/render/editmode.cpp @@ -38,7 +38,9 @@ void CSVRender::EditMode::primaryEditPressed (osg::ref_ptr tag) {} void CSVRender::EditMode::secondaryEditPressed (osg::ref_ptr tag) {} -void CSVRender::EditMode::selectPressed (osg::ref_ptr tag) {} +void CSVRender::EditMode::primarySelectPressed (osg::ref_ptr tag) {} + +void CSVRender::EditMode::secondarySelectPressed (osg::ref_ptr tag) {} bool CSVRender::EditMode::primaryEditStartDrag (osg::ref_ptr tag) { @@ -50,7 +52,12 @@ bool CSVRender::EditMode::secondaryEditStartDrag (osg::ref_ptr tag) return false; } -bool CSVRender::EditMode::selectStartDrag (osg::ref_ptr tag) +bool CSVRender::EditMode::primarySelectStartDrag (osg::ref_ptr tag) +{ + return false; +} + +bool CSVRender::EditMode::secondarySelectStartDrag (osg::ref_ptr tag) { return false; } diff --git a/apps/opencs/view/render/editmode.hpp b/apps/opencs/view/render/editmode.hpp index 77676d6a3..c17616b56 100644 --- a/apps/opencs/view/render/editmode.hpp +++ b/apps/opencs/view/render/editmode.hpp @@ -43,7 +43,10 @@ namespace CSVRender virtual void secondaryEditPressed (osg::ref_ptr tag); /// Default-implementation: Ignored. - virtual void selectPressed (osg::ref_ptr tag); + virtual void primarySelectPressed (osg::ref_ptr tag); + + /// Default-implementation: Ignored. + virtual void secondarySelectPressed (osg::ref_ptr tag); /// Default-implementation: ignore and return false /// @@ -58,7 +61,12 @@ namespace CSVRender /// Default-implementation: ignore and return false /// /// \return Drag accepted? - virtual bool selectStartDrag (osg::ref_ptr tag); + virtual bool primarySelectStartDrag (osg::ref_ptr tag); + + /// Default-implementation: ignore and return false + /// + /// \return Drag accepted? + virtual bool secondarySelectStartDrag (osg::ref_ptr tag); /// Default-implementation: ignored virtual void drag (int diffX, int diffY, double speedFactor); diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 333d91656..fdd031ad4 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -30,16 +30,32 @@ void CSVRender::InstanceMode::updateUserSetting (const QString& name, const QStr void CSVRender::InstanceMode::primaryEditPressed (osg::ref_ptr tag) { if (mContextSelect) - selectPressed (tag); + primarySelectPressed (tag); } void CSVRender::InstanceMode::secondaryEditPressed (osg::ref_ptr tag) { if (mContextSelect) - selectPressed (tag); + secondarySelectPressed (tag); } -void CSVRender::InstanceMode::selectPressed (osg::ref_ptr tag) +void CSVRender::InstanceMode::primarySelectPressed (osg::ref_ptr tag) +{ + if (tag) + { + if (CSVRender::ObjectTag *objectTag = dynamic_cast (tag.get())) + { + // hit an Object, toggle its selection state + CSVRender::Object* object = objectTag->mObject; + object->setSelected (!object->getSelected()); + return; + } + } + + getWorldspaceWidget().clearSelection (Element_Reference); +} + +void CSVRender::InstanceMode::secondarySelectPressed (osg::ref_ptr tag) { if (tag) { diff --git a/apps/opencs/view/render/instancemode.hpp b/apps/opencs/view/render/instancemode.hpp index cc4fd5434..50bd8243d 100644 --- a/apps/opencs/view/render/instancemode.hpp +++ b/apps/opencs/view/render/instancemode.hpp @@ -23,7 +23,9 @@ namespace CSVRender virtual void secondaryEditPressed (osg::ref_ptr tag); - virtual void selectPressed (osg::ref_ptr tag); + virtual void primarySelectPressed (osg::ref_ptr tag); + + virtual void secondarySelectPressed (osg::ref_ptr tag); }; } diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 46c5867eb..e76582b94 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -36,7 +36,7 @@ namespace { "p-navi", "s-navi", "p-edit", "s-edit", - "select", + "p-select", "s-select", 0 }; } @@ -513,7 +513,7 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) { } - else if (mDragMode=="p-edit" || mDragMode=="s-edit" || mDragMode=="select") + else if (mDragMode=="p-edit" || mDragMode=="s-edit" || mDragMode=="p-select" || mDragMode=="s-select") { osg::ref_ptr tag = mousePick (event); @@ -523,8 +523,10 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) mDragging = editMode.primaryEditStartDrag (tag); else if (mDragMode=="s-edit") mDragging = editMode.secondaryEditStartDrag (tag); - else if (mDragMode=="select") - mDragging = editMode.selectStartDrag (tag); + else if (mDragMode=="p-select") + mDragging = editMode.primarySelectStartDrag (tag); + else if (mDragMode=="s-select") + mDragging = editMode.secondarySelectStartDrag (tag); if (mDragging) { @@ -575,7 +577,8 @@ void CSVRender::WorldspaceWidget::mouseReleaseEvent (QMouseEvent *event) { } - else if (mDragMode=="p-edit" || mDragMode=="s-edit" || mDragMode=="select") + else if (mDragMode=="p-edit" || mDragMode=="s-edit" || + mDragMode=="p-select" || mDragMode=="s-select") { EditMode& editMode = dynamic_cast (*mEditMode->getCurrent()); @@ -589,7 +592,8 @@ void CSVRender::WorldspaceWidget::mouseReleaseEvent (QMouseEvent *event) { } - else if (button=="p-edit" || button=="s-edit" || button=="select") + else if (button=="p-edit" || button=="s-edit" || + button=="p-select" || button=="s-select") { osg::ref_ptr tag = mousePick (event); @@ -647,6 +651,8 @@ void CSVRender::WorldspaceWidget::handleMouseClick (osg::ref_ptr tag, c editMode.primaryEditPressed (tag); else if (button=="s-edit") editMode.secondaryEditPressed (tag); - else if (button=="select") - editMode.selectPressed (tag); + else if (button=="p-select") + editMode.primarySelectPressed (tag); + else if (button=="s-select") + editMode.secondarySelectPressed (tag); }