]> git.mxchange.org Git - simgear.git/commitdiff
Improve pick-callback enabled testing.
authorJames Turner <zakalawe@mac.com>
Sun, 31 Jul 2016 21:13:19 +0000 (22:13 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 13 Aug 2016 08:21:16 +0000 (10:21 +0200)
simgear/scene/model/SGPickAnimation.cxx
simgear/structure/SGBinding.cxx
simgear/structure/SGBinding.hxx

index 3c6a2da0e38c1e67c2915fbab5dc26e4685bedc9..f4ba22f53567b54835ffae190cae2e2b3417d9bb 100644 (file)
@@ -107,7 +107,11 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter& ea)
        if (_buttons.find(button) == _buttons.end()) {
            return false;
        }
-       
+
+       if (!anyBindingEnabled(_bindingsDown)) {
+           return false;
+       }
+
      fireBindingList(_bindingsDown);
      _repeatTime = -_repeatInterval;    // anti-bobble: delay start of repeat
      return true;
@@ -136,7 +140,7 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter& ea)
    virtual bool hover( const osg::Vec2d& windowPos,
                        const Info& )
    {
-       if (_hover.empty()) {
+       if (!anyBindingEnabled(_hover)) {
            return false;
        }
        
index 28e6f8169d5f4ae2332fb3c2e5a2d4a8d143413b..86420be15c6ad6c7d478dd72b9bc6407fd78745b 100644 (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;
+}
+
index ef573a014b01e36b9732ed72b6a0900a29bdd558..6ec2bc68ad64ad6aedfb6f5c4eb92f727e74074c 100644 (file)
@@ -171,4 +171,10 @@ SGBindingList readBindingList(const simgear::PropertyList& aNodes, SGPropertyNod
  */
 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