From 7bbc475bda71ea8d87ca63933c3d8c0c21dc2841 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 26 Sep 2015 18:01:49 +0200 Subject: [PATCH] apply button mapping --- apps/opencs/view/render/worldspacewidget.cpp | 37 +++++++++++++++----- apps/opencs/view/render/worldspacewidget.hpp | 2 ++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 15978e0e1..5b5219184 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -394,6 +395,20 @@ osg::ref_ptr CSVRender::WorldspaceWidget::mousePick (QMouseE return osg::ref_ptr(); } +std::string CSVRender::WorldspaceWidget::mapButton (QMouseEvent *event) +{ + std::pair phyiscal ( + event->button(), QApplication::keyboardModifiers() & Qt::ControlModifier); + + std::map, std::string>::const_iterator iter = + mButtonMapping.find (phyiscal); + + if (iter!=mButtonMapping.end()) + return iter->second; + + return ""; +} + void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event) { const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); @@ -480,18 +495,24 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) void CSVRender::WorldspaceWidget::mousePressEvent (QMouseEvent *event) { - if (event->button() != Qt::RightButton) - return; + std::string button = mapButton (event); - osg::ref_ptr tag = mousePick (event); + if (button=="p-navi" || button=="s-navi") + { - if (tag) + } + else if (button=="p-edit" || button=="s-edit" || button=="select") { - if (CSVRender::ObjectTag *objectTag = dynamic_cast (tag.get())) + osg::ref_ptr tag = mousePick (event); + + if (tag) { - // hit an Object, toggle its selection state - CSVRender::Object* object = objectTag->mObject; - object->setSelected (!object->getSelected()); + if (CSVRender::ObjectTag *objectTag = dynamic_cast (tag.get())) + { + // hit an Object, toggle its selection state + CSVRender::Object* object = objectTag->mObject; + object->setSelected (!object->getSelected()); + } } } } diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 90a85006f..ed5c5bcc8 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -130,6 +130,8 @@ namespace CSVRender osg::ref_ptr mousePick (QMouseEvent *event); + std::string mapButton (QMouseEvent *event); + virtual std::string getStartupInstruction() = 0; private slots: