Tweaks for pick callback cursors.
This commit is contained in:
@@ -86,6 +86,10 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter* ea)
|
|||||||
_bindingsDown = readBindingList(configNode->getChildren("binding"), modelRoot);
|
_bindingsDown = readBindingList(configNode->getChildren("binding"), modelRoot);
|
||||||
readOptionalBindingList(configNode, modelRoot, "mod-up", _bindingsUp);
|
readOptionalBindingList(configNode, modelRoot, "mod-up", _bindingsUp);
|
||||||
readOptionalBindingList(configNode, modelRoot, "hovered", _hover);
|
readOptionalBindingList(configNode, modelRoot, "hovered", _hover);
|
||||||
|
|
||||||
|
if (configNode->hasChild("cursor")) {
|
||||||
|
_cursorName = configNode->getStringValue("cursor");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info&)
|
virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info&)
|
||||||
@@ -129,6 +133,9 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter* ea)
|
|||||||
fireBindingList(_hover, params.ptr());
|
fireBindingList(_hover, params.ptr());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getCursor() const
|
||||||
|
{ return _cursorName; }
|
||||||
private:
|
private:
|
||||||
SGBindingList _bindingsDown;
|
SGBindingList _bindingsDown;
|
||||||
SGBindingList _bindingsUp;
|
SGBindingList _bindingsUp;
|
||||||
@@ -137,6 +144,7 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter* ea)
|
|||||||
bool _repeatable;
|
bool _repeatable;
|
||||||
double _repeatInterval;
|
double _repeatInterval;
|
||||||
double _repeatTime;
|
double _repeatTime;
|
||||||
|
std::string _cursorName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VncVisitor : public osg::NodeVisitor {
|
class VncVisitor : public osg::NodeVisitor {
|
||||||
@@ -443,6 +451,17 @@ public:
|
|||||||
} else if (dragDir == "horizontal") {
|
} else if (dragDir == "horizontal") {
|
||||||
_dragDirection = DRAG_HORIZONTAL;
|
_dragDirection = DRAG_HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configNode->hasChild("cursor")) {
|
||||||
|
_cursorName = configNode->getStringValue("cursor");
|
||||||
|
} else {
|
||||||
|
DragDirection dir = effectiveDragDirection();
|
||||||
|
if (dir == DRAG_VERTICAL) {
|
||||||
|
_cursorName = "drag-vertical";
|
||||||
|
} else if (dir == DRAG_HORIZONTAL) {
|
||||||
|
_cursorName = "drag-horizontal";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info&)
|
virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info&)
|
||||||
@@ -482,6 +501,17 @@ public:
|
|||||||
fireBindingList(_releaseAction);
|
fireBindingList(_releaseAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DragDirection effectiveDragDirection() const
|
||||||
|
{
|
||||||
|
if (_dragDirection == DRAG_DEFAULT) {
|
||||||
|
// respect the current default settings - this allows runtime
|
||||||
|
// setting of the default drag direction.
|
||||||
|
return static_knobDragAlternateAxis ? DRAG_VERTICAL : DRAG_HORIZONTAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _dragDirection;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void mouseMoved(const osgGA::GUIEventAdapter* ea)
|
virtual void mouseMoved(const osgGA::GUIEventAdapter* ea)
|
||||||
{
|
{
|
||||||
_mousePos = eventToWindowCoords(ea);
|
_mousePos = eventToWindowCoords(ea);
|
||||||
@@ -499,14 +529,7 @@ public:
|
|||||||
_hasDragged = true;
|
_hasDragged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DragDirection dragDir = _dragDirection;
|
double delta = (effectiveDragDirection() == DRAG_VERTICAL) ? deltaMouse.y() : deltaMouse.x();
|
||||||
if (dragDir == DRAG_DEFAULT) {
|
|
||||||
// respect the current default settings - this allows runtime
|
|
||||||
// setting of the default drag direction.
|
|
||||||
dragDir = static_knobDragAlternateAxis ? DRAG_VERTICAL : DRAG_HORIZONTAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
double delta = (dragDir == DRAG_VERTICAL) ? deltaMouse.y() : deltaMouse.x();
|
|
||||||
// per-animation scale factor lets the aircraft author tune for expectations,
|
// per-animation scale factor lets the aircraft author tune for expectations,
|
||||||
// eg heading setting vs 5-state switch.
|
// eg heading setting vs 5-state switch.
|
||||||
// then we scale by a global sensitivity, which the user can set.
|
// then we scale by a global sensitivity, which the user can set.
|
||||||
@@ -545,6 +568,15 @@ public:
|
|||||||
fireBindingList(_hover, params.ptr());
|
fireBindingList(_hover, params.ptr());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setCursor(const std::string& aName)
|
||||||
|
{
|
||||||
|
_cursorName = aName;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::string getCursor() const
|
||||||
|
{ return _cursorName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fire(bool isShifted, Direction dir)
|
void fire(bool isShifted, Direction dir)
|
||||||
{
|
{
|
||||||
@@ -581,6 +613,8 @@ private:
|
|||||||
osg::Vec2d _mousePos, ///< current window coords location of the mouse
|
osg::Vec2d _mousePos, ///< current window coords location of the mouse
|
||||||
_lastFirePos; ///< mouse location where we last fired the bindings
|
_lastFirePos; ///< mouse location where we last fired the bindings
|
||||||
double _dragScale;
|
double _dragScale;
|
||||||
|
|
||||||
|
std::string _cursorName;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -66,9 +66,16 @@ public:
|
|||||||
virtual bool hover(const osg::Vec2d& windowPos, const Info& info)
|
virtual bool hover(const osg::Vec2d& windowPos, const Info& info)
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
Priority getPriority() const
|
virtual Priority getPriority() const
|
||||||
{ return _priority; }
|
{ return _priority; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retrieve the name of the cursor to user when hovering this pickable
|
||||||
|
* object. Mapping is undefined, since SimGear doesn't know about cursors.
|
||||||
|
*/
|
||||||
|
virtual std::string getCursor() const
|
||||||
|
{ return std::string(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Priority _priority;
|
Priority _priority;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user