Improve pick-callback enabled testing.

This commit is contained in:
James Turner
2016-07-31 22:21:03 +01:00
parent 8b8dbeb00d
commit 5ea01039f9
3 changed files with 27 additions and 2 deletions
+5 -1
View File
@@ -108,6 +108,10 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter& ea)
return false; return false;
} }
if (!anyBindingEnabled(_bindingsDown)) {
return false;
}
fireBindingList(_bindingsDown); fireBindingList(_bindingsDown);
_repeatTime = -_repeatInterval; // anti-bobble: delay start of repeat _repeatTime = -_repeatInterval; // anti-bobble: delay start of repeat
return true; return true;
@@ -136,7 +140,7 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter& ea)
virtual bool hover( const osg::Vec2d& windowPos, virtual bool hover( const osg::Vec2d& windowPos,
const Info& ) const Info& )
{ {
if (_hover.empty()) { if (!anyBindingEnabled(_hover)) {
return false; return false;
} }
+15
View File
@@ -165,3 +165,18 @@ void clearBindingList(const SGBindingList& aBindings)
} }
} }
bool anyBindingEnabled(const SGBindingList& aBindings)
{
if (aBindings.empty()) {
return false;
}
BOOST_FOREACH(SGBinding_ptr b, aBindings) {
if (!b->test()) {
return false;
}
}
return true;
}
+6
View File
@@ -171,4 +171,10 @@ SGBindingList readBindingList(const simgear::PropertyList& aNodes, SGPropertyNod
*/ */
void clearBindingList(const SGBindingList& aBindings); void clearBindingList(const SGBindingList& aBindings);
/**
* check if at least one binding in the list is enabled. Returns false if bindings
* list is empty, or all bindings are conditinally disabled.
*/
bool anyBindingEnabled(const SGBindingList& bindings);
#endif #endif