]> git.mxchange.org Git - simgear.git/commitdiff
Standardise location (in XML) of hovered elements.
authorJames Turner <zakalawe@mac.com>
Mon, 11 Mar 2013 18:07:27 +0000 (18:07 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 11 Mar 2013 18:07:27 +0000 (18:07 +0000)
Hovered bindings are always direction children of the pick animation, since having different hovered behaviours per-action makes no sense.

simgear/scene/model/SGPickAnimation.cxx

index abdeec8229a4e515fc6c67784527ef73bf8e9de8..68da16fbd13847520c911c0d8a8c2372560081b4 100644 (file)
@@ -85,13 +85,19 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter* ea)
 
      _bindingsDown = readBindingList(configNode->getChildren("binding"), modelRoot);
      readOptionalBindingList(configNode, modelRoot, "mod-up", _bindingsUp);
-     readOptionalBindingList(configNode, modelRoot, "hovered", _hover);
+     
      
      if (configNode->hasChild("cursor")) {
        _cursorName = configNode->getStringValue("cursor");
      }
    }
-   
+     
+     void addHoverBindings(const SGPropertyNode* hoverNode,
+                             SGPropertyNode* modelRoot)
+     {
+         _hover = readBindingList(hoverNode->getChildren("binding"), modelRoot);
+     }
+     
    virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info&)
    {
        if (_buttons.find(button) == _buttons.end()) {
@@ -367,11 +373,26 @@ SGPickAnimation::innerSetupPickGroup(osg::Group* commonGroup, osg::Group& parent
      innerSetupPickGroup(commonGroup, parent);
      SGSceneUserData* ud = SGSceneUserData::getOrCreateSceneUserData(commonGroup);
 
+     PickCallback* pickCb = NULL;
+     
    // add actions that become macro and command invocations
    std::vector<SGPropertyNode_ptr> actions;
    actions = getConfig()->getChildren("action");
-   for (unsigned int i = 0; i < actions.size(); ++i)
-     ud->addPickCallback(new PickCallback(actions[i], getModelRoot()));
+   for (unsigned int i = 0; i < actions.size(); ++i) {
+     pickCb = new PickCallback(actions[i], getModelRoot());
+     ud->addPickCallback(pickCb);
+   }
+     
+   if (getConfig()->hasChild("hovered")) {
+     if (!pickCb) {
+       // make a trivial PickCallback to hang the hovered off of
+       SGPropertyNode_ptr dummyNode(new SGPropertyNode);
+       pickCb = new PickCallback(dummyNode.ptr(), getModelRoot());
+     }
+       
+     pickCb->addHoverBindings(getConfig()->getNode("hovered"), getModelRoot());
+   }
+     
    // Look for the VNC sessions that want raw mouse input
    actions = getConfig()->getChildren("vncaction");
    for (unsigned int i = 0; i < actions.size(); ++i)