mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
added scene tooltips system (tag based)
This commit is contained in:
parent
655b40267b
commit
01f4b8a182
@ -426,6 +426,20 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||||||
dragShiftFactor->setRange (0.001, 100.0);
|
dragShiftFactor->setRange (0.001, 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declareSection ("tooltips", "Tooltips");
|
||||||
|
{
|
||||||
|
Setting *scene = createSetting (Type_CheckBox, "scene", "Show Tooltips in 3D scenes");
|
||||||
|
scene->setDefaultValue ("true");
|
||||||
|
|
||||||
|
Setting *sceneHideBasic = createSetting (Type_CheckBox, "scene-hide-basic", "Hide basic 3D scenes tooltips");
|
||||||
|
sceneHideBasic->setDefaultValue ("false");
|
||||||
|
|
||||||
|
Setting *sceneDelay = createSetting (Type_SpinBox, "scene-delay",
|
||||||
|
"Tooltip delay in milliseconds");
|
||||||
|
sceneDelay->setDefaultValue (500);
|
||||||
|
sceneDelay->setRange (1, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* There are three types of values:
|
* There are three types of values:
|
||||||
|
@ -7,3 +7,8 @@ CSVRender::Elements CSVRender::TagBase::getElement() const
|
|||||||
{
|
{
|
||||||
return mElement;
|
return mElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CSVRender::TagBase::getToolTip (bool hideBasics) const
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <osg/Referenced>
|
#include <osg/Referenced>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include "elements.hpp"
|
#include "elements.hpp"
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
@ -16,6 +18,9 @@ namespace CSVRender
|
|||||||
TagBase (Elements element);
|
TagBase (Elements element);
|
||||||
|
|
||||||
Elements getElement() const;
|
Elements getElement() const;
|
||||||
|
|
||||||
|
virtual QString getToolTip (bool hideBasics) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QToolTip>
|
||||||
|
|
||||||
#include <osgGA/TrackballManipulator>
|
#include <osgGA/TrackballManipulator>
|
||||||
#include <osgGA/FirstPersonManipulator>
|
#include <osgGA/FirstPersonManipulator>
|
||||||
@ -43,7 +44,8 @@ namespace
|
|||||||
|
|
||||||
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
||||||
: SceneWidget (document.getData().getResourceSystem(), parent), mSceneElements(0), mRun(0), mDocument(document),
|
: SceneWidget (document.getData().getResourceSystem(), parent), mSceneElements(0), mRun(0), mDocument(document),
|
||||||
mInteractionMask (0), mEditMode (0), mLocked (false), mDragging (false)
|
mInteractionMask (0), mEditMode (0), mLocked (false), mDragging (false),
|
||||||
|
mToolTipPos (-1, -1)
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
@ -85,6 +87,12 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
|
|||||||
mDragFactor = CSMSettings::UserSettings::instance().settingValue ("scene-input/drag-factor").toDouble();
|
mDragFactor = CSMSettings::UserSettings::instance().settingValue ("scene-input/drag-factor").toDouble();
|
||||||
mDragWheelFactor = CSMSettings::UserSettings::instance().settingValue ("scene-input/drag-wheel-factor").toDouble();
|
mDragWheelFactor = CSMSettings::UserSettings::instance().settingValue ("scene-input/drag-wheel-factor").toDouble();
|
||||||
mDragShiftFactor = CSMSettings::UserSettings::instance().settingValue ("scene-input/drag-shift-factor").toDouble();
|
mDragShiftFactor = CSMSettings::UserSettings::instance().settingValue ("scene-input/drag-shift-factor").toDouble();
|
||||||
|
|
||||||
|
mShowToolTips = CSMSettings::UserSettings::instance().settingValue ("tooltips/scene") == "true";
|
||||||
|
mToolTipDelay = CSMSettings::UserSettings::instance().settingValue ("tooltips/scene-delay").toInt();
|
||||||
|
|
||||||
|
mToolTipDelayTimer.setSingleShot (true);
|
||||||
|
connect (&mToolTipDelayTimer, SIGNAL (timeout()), this, SLOT (showToolTip()));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::~WorldspaceWidget ()
|
CSVRender::WorldspaceWidget::~WorldspaceWidget ()
|
||||||
@ -294,6 +302,10 @@ void CSVRender::WorldspaceWidget::updateUserSetting (const QString& name, const
|
|||||||
mDragWheelFactor = value.at (0).toDouble();
|
mDragWheelFactor = value.at (0).toDouble();
|
||||||
else if (name=="scene-input/drag-shift-factor")
|
else if (name=="scene-input/drag-shift-factor")
|
||||||
mDragShiftFactor = value.at (0).toDouble();
|
mDragShiftFactor = value.at (0).toDouble();
|
||||||
|
else if (name=="tooltips/scene-delay")
|
||||||
|
mToolTipDelay = value.at (0).toInt();
|
||||||
|
else if (name=="tooltips/scene")
|
||||||
|
mShowToolTips = value.at (0)=="true";
|
||||||
else
|
else
|
||||||
dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent()).updateUserSetting (name, value);
|
dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent()).updateUserSetting (name, value);
|
||||||
}
|
}
|
||||||
@ -368,11 +380,11 @@ bool CSVRender::WorldspaceWidget::storeMappingSetting (const QString& key, const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<CSVRender::TagBase> CSVRender::WorldspaceWidget::mousePick (QMouseEvent *event)
|
osg::ref_ptr<CSVRender::TagBase> CSVRender::WorldspaceWidget::mousePick (const QPoint& localPos)
|
||||||
{
|
{
|
||||||
// (0,0) is considered the lower left corner of an OpenGL window
|
// (0,0) is considered the lower left corner of an OpenGL window
|
||||||
int x = event->x();
|
int x = localPos.x();
|
||||||
int y = height() - event->y();
|
int y = height() - localPos.y();
|
||||||
|
|
||||||
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector (new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y));
|
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector (new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y));
|
||||||
|
|
||||||
@ -494,6 +506,21 @@ void CSVRender::WorldspaceWidget::editModeChanged (const std::string& id)
|
|||||||
mDragging = false;
|
mDragging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::WorldspaceWidget::showToolTip()
|
||||||
|
{
|
||||||
|
if (mShowToolTips)
|
||||||
|
{
|
||||||
|
QPoint pos = QCursor::pos();
|
||||||
|
|
||||||
|
if (osg::ref_ptr<TagBase> tag = mousePick (mapFromGlobal (pos)))
|
||||||
|
{
|
||||||
|
bool hideBasics =
|
||||||
|
CSMSettings::UserSettings::instance().settingValue ("tooltips/scene-hide-basic")=="true";
|
||||||
|
QToolTip::showText (pos, tag->getToolTip (hideBasics), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::elementSelectionChanged()
|
void CSVRender::WorldspaceWidget::elementSelectionChanged()
|
||||||
{
|
{
|
||||||
setVisibilityMask (getVisibilityMask());
|
setVisibilityMask (getVisibilityMask());
|
||||||
@ -509,13 +536,23 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
if (!mDragging)
|
if (!mDragging)
|
||||||
{
|
{
|
||||||
if (mDragMode=="p-navi" || mDragMode=="s-navi")
|
if (mDragMode.empty())
|
||||||
|
{
|
||||||
|
if (event->globalPos()!=mToolTipPos)
|
||||||
|
{
|
||||||
|
mToolTipPos = event->globalPos();
|
||||||
|
|
||||||
|
if (mShowToolTips)
|
||||||
|
mToolTipDelayTimer.start (mToolTipDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mDragMode=="p-navi" || mDragMode=="s-navi")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mDragMode=="p-edit" || mDragMode=="s-edit" || mDragMode=="p-select" || mDragMode=="s-select")
|
else if (mDragMode=="p-edit" || mDragMode=="s-edit" || mDragMode=="p-select" || mDragMode=="s-select")
|
||||||
{
|
{
|
||||||
osg::ref_ptr<TagBase> tag = mousePick (event);
|
osg::ref_ptr<TagBase> tag = mousePick (event->pos());
|
||||||
|
|
||||||
EditMode& editMode = dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent());
|
EditMode& editMode = dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent());
|
||||||
|
|
||||||
@ -595,7 +632,7 @@ void CSVRender::WorldspaceWidget::mouseReleaseEvent (QMouseEvent *event)
|
|||||||
else if (button=="p-edit" || button=="s-edit" ||
|
else if (button=="p-edit" || button=="s-edit" ||
|
||||||
button=="p-select" || button=="s-select")
|
button=="p-select" || button=="s-select")
|
||||||
{
|
{
|
||||||
osg::ref_ptr<TagBase> tag = mousePick (event);
|
osg::ref_ptr<TagBase> tag = mousePick (event->pos());
|
||||||
|
|
||||||
handleMouseClick (tag, button, event->modifiers() & Qt::ShiftModifier);
|
handleMouseClick (tag, button, event->modifiers() & Qt::ShiftModifier);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
#include "../../model/world/tablemimedata.hpp"
|
#include "../../model/world/tablemimedata.hpp"
|
||||||
|
|
||||||
@ -47,6 +49,10 @@ namespace CSVRender
|
|||||||
double mDragFactor;
|
double mDragFactor;
|
||||||
double mDragWheelFactor;
|
double mDragWheelFactor;
|
||||||
double mDragShiftFactor;
|
double mDragShiftFactor;
|
||||||
|
QTimer mToolTipDelayTimer;
|
||||||
|
QPoint mToolTipPos;
|
||||||
|
bool mShowToolTips;
|
||||||
|
int mToolTipDelay;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -147,7 +153,7 @@ namespace CSVRender
|
|||||||
/// \return Is \a key a button mapping setting? (ignored otherwise)
|
/// \return Is \a key a button mapping setting? (ignored otherwise)
|
||||||
bool storeMappingSetting (const QString& key, const QString& value);
|
bool storeMappingSetting (const QString& key, const QString& value);
|
||||||
|
|
||||||
osg::ref_ptr<TagBase> mousePick (QMouseEvent *event);
|
osg::ref_ptr<TagBase> mousePick (const QPoint& localPos);
|
||||||
|
|
||||||
std::string mapButton (QMouseEvent *event);
|
std::string mapButton (QMouseEvent *event);
|
||||||
|
|
||||||
@ -179,6 +185,8 @@ namespace CSVRender
|
|||||||
|
|
||||||
void editModeChanged (const std::string& id);
|
void editModeChanged (const std::string& id);
|
||||||
|
|
||||||
|
void showToolTip();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
void elementSelectionChanged();
|
void elementSelectionChanged();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user