Exemplo n.º 1
0
bool GraphComponent::closeSelectedPlugins ()
{
    DBG ("GraphComponent::closeSelectedPlugins");

    jassert (host != 0);

    if (selectedNodes.getNumSelected () > 0)
    {
        for (int i = 0; i < selectedNodes.getNumSelected (); i++)
        {
            GraphNodeComponent* selected = selectedNodes.getSelectedItem (i);

            BasePlugin* plugin = (BasePlugin*) selected->getUserData ();
            if (plugin)
            {
                if (owner->isPluginEditorWindowOpen (plugin))
                    owner->closePluginEditorWindow (plugin);

                host->closePlugin (plugin);

                selectedNodes.deselect (selected);
                deletePluginNode (selected);
            }
        }

        selectedNodes.deselectAll ();

        graphChanged ();
        
        return true;
    }
    
    return false;
}
Exemplo n.º 2
0
GraphNodeComponent* GraphComponent::findNodeByUserData (void* data)
{
    for (int i = nodes.size(); --i >= 0;)
    {
        GraphNodeComponent* node = nodes.getUnchecked (i);
        if (node->getUserData () == data)
            return node;
    }
    return 0;
}
Exemplo n.º 3
0
void GraphComponent::nodeSelected (GraphNodeComponent* node)
{
    DBG ("GraphComponent::nodeSelected");

    jassert (node != 0)

    switch (selectedNodes.getNumSelected ())
    {
    case 0: // no items selected
        {
            BasePlugin* plugin = (BasePlugin*) node->getUserData ();
            if (plugin)
                plugin->setValue (PROP_GRAPHSELECTED, 1);

            selectedNodes.addToSelection (node);

            node->repaint ();
        }
        break;
    default: // one or more items selected
        {
            if (! selectedNodes.isSelected (node))
            {
                for (int i = 0; i < selectedNodes.getNumSelected (); i++)
                {
                    GraphNodeComponent* selected = selectedNodes.getSelectedItem (i);

                    BasePlugin* plugin = (BasePlugin*) selected->getUserData ();
                    if (plugin)
                        plugin->setValue (PROP_GRAPHSELECTED, 0);

                    selected->repaint ();
                }

                selectedNodes.deselectAll ();

                BasePlugin* plugin = (BasePlugin*) node->getUserData ();
                if (plugin)
                    plugin->setValue (PROP_GRAPHSELECTED, 1);

                selectedNodes.addToSelection (node);

                node->repaint ();
            }
        }
        break;
    }
}
Exemplo n.º 4
0
void GraphComponent::nodeMoved (GraphNodeComponent* node, const int deltaX, const int deltaY)
{
//    DBG ("GraphComponent::nodeMoved " + String (deltaX) + " " + String (deltaY));

    jassert (node != 0);

    for (int i = 0; i < selectedNodes.getNumSelected (); i++)
    {
        GraphNodeComponent* selected = selectedNodes.getSelectedItem (i);
        if (selected
            && selected != node
            && ! selected->isLocked ())
        {
            BasePlugin* plugin = (BasePlugin*) selected->getUserData ();
            if (plugin)
            {
                int x = selected->getX() + deltaX;
                int y = selected->getY() + deltaY;

                x = jmax (0, jmin (getWidth () - selected->getWidth(), x));
                y = jmax (0, jmin (getHeight () - selected->getHeight(), y));
            
                plugin->setValue (PROP_GRAPHXPOS, x);
                plugin->setValue (PROP_GRAPHYPOS, y);
                
                selected->setTopLeftPosition (x, y);
            }
        }
    }

    BasePlugin* plugin = (BasePlugin*) node->getUserData ();
    if (plugin)
    {
        plugin->setValue (PROP_GRAPHXPOS, node->getX());
        plugin->setValue (PROP_GRAPHYPOS, node->getY());
    }

    Viewport* parent = findParentComponentOfClass ((Viewport*) 0);
    if (parent)
    {
        parent->notifyComponentChanged ();
    }
}
Exemplo n.º 5
0
//==============================================================================
void GraphComponent::recalculateConnectionsRecursive (GraphNodeComponent* node,
                                                      ProcessingGraph* graph,
                                                      const int insertIndex,
//                                                      const int connectorType,
                                                      const bool createConnection)
{
    BasePlugin* source = (BasePlugin*) node->getUserData ();

    if (source != 0 && ! graph->contains (source))
    {
        graph->insertNode (insertIndex, source);
        int currentIndex = insertIndex + 1;

        for (int i = 0; i < node->getOutputConnectorCount (); i++)
        {
            int sourceOutputMidiOffset = node->getFirstOutputOfType (JOST_LINKTYPE_MIDI);
            int destOutputMidiOffset = 0;

            GraphConnectorComponent* connector = node->getOutputConnector (i);
//            if (connector->getType () == connectorType)
            {
                // we are the same type, get linked connectors
                Array <GraphConnectorComponent*> linked;
                connector->getLinkedConnectors (linked);

                for (int j = 0; j < linked.size (); j++)
                {
                    GraphConnectorComponent* other = linked.getUnchecked (j);
                    GraphNodeComponent* otherNode = other->getParentGraphComponent();

                    // breath first
                    recalculateConnectionsRecursive (otherNode,
                                                     graph,
                                                     currentIndex,
//                                                     connectorType,
                                                     createConnection);

                    // create link here !
                    if (createConnection)
                    {
                        BasePlugin* destination = (BasePlugin*) otherNode->getUserData ();
                        if (destination != 0)
                        {
                            if (connector->getType () == JOST_LINKTYPE_AUDIO)
                            {
                                graph->connectTo (source,
                                                  connector->getConnectorID(),
                                                  destination,
                                                  other->getConnectorID(),
                                                  JOST_LINKTYPE_AUDIO);
                            }
                            else if (connector->getType () == JOST_LINKTYPE_MIDI)
                            {
                                destOutputMidiOffset = otherNode->getFirstInputOfType (JOST_LINKTYPE_MIDI);

                                graph->connectTo (source,
                                                  connector->getConnectorID() - sourceOutputMidiOffset,
                                                  destination,
                                                  other->getConnectorID() - destOutputMidiOffset,
                                                  JOST_LINKTYPE_MIDI);
                            }
                        }
                    }
                    // end create link !
                }
          }
        }
    }

}