Example #1
0
void FilterComponent::mouseUp (const MouseEvent& e)
{
  if (e.mouseWasClicked() && e.getNumberOfClicks() == 2)
  {
    if (const AudioProcessorGraph::Node::Ptr f = audioEngine.getDoc().getNodeForId (nodeId))
    {
      AudioProcessor* const processor = f->getProcessor();
      if(!InternalPluginFormat::isInternalFormat(processor->getName()))
      {
        if (PluginWindow* const w = PluginWindow::getWindowFor (f, PluginWindow::Generic/*Normal*/))
          w->toFront (true);
      }
    }
  }
  else if (! e.mouseWasClicked())
  {
    audioEngine.getDoc().setChangedFlag (true);
    
    if (moving)
    {
      moving = false;
      audioEngine.getDoc().beginTransaction();
      audioEngine.getDoc().perform(new MoveFilterAction(audioEngine, *getGraphPanel(), nodeId, startPos, endPos), "move node");
    }
  }
}
Example #2
0
 void mouseDown (const MouseEvent& e)
 {
     getGraphPanel()->beginConnectorDrag (isInput ? 0 : filterID,
                                          index,
                                          isInput ? filterID : 0,
                                          index,
                                          e);
 }
Example #3
0
void PinComponent::mouseDown (const MouseEvent& e)
{
  getGraphPanel()->beginConnectorDrag (isInput ? 0 : nodeId,
                                       index,
                                       isInput ? nodeId : 0,
                                       index,
                                       e);
}
Example #4
0
    void mouseDrag (const MouseEvent& e)
    {
        if ((! dragging) && ! e.mouseWasClicked())
        {
            dragging = true;

            graph.removeConnection (sourceFilterID, sourceFilterChannel, destFilterID, destFilterChannel);

            double distanceFromStart, distanceFromEnd;
            getDistancesFromEnds (e.x, e.y, distanceFromStart, distanceFromEnd);
            const bool isNearerSource = (distanceFromStart < distanceFromEnd);

            getGraphPanel()->beginConnectorDrag (isNearerSource ? 0 : sourceFilterID,
                                                 sourceFilterChannel,
                                                 isNearerSource ? destFilterID : 0,
                                                 destFilterChannel,
                                                 e);
        }
        else if (dragging)
        {
            getGraphPanel()->dragConnector (e);
        }
    }
Example #5
0
    void mouseDrag (const MouseEvent& e)
    {
        if (! e.mods.isPopupMenu())
        {
            Point<int> pos (originalPos + Point<int> (e.getDistanceFromDragStartX(), e.getDistanceFromDragStartY()));

            if (getParentComponent() != nullptr)
                pos = getParentComponent()->getLocalPoint (nullptr, pos);

            graph.setNodePosition (filterID,
                                   (pos.getX() + getWidth() / 2) / (double) getParentWidth(),
                                   (pos.getY() + getHeight() / 2) / (double) getParentHeight());

            getGraphPanel()->updateComponents();
        }
    }
Example #6
0
void ConnectorComponent::getPoints (float& x1, float& y1, float& x2, float& y2) const
{
  x1 = lastInputX;
  y1 = lastInputY;
  x2 = lastOutputX;
  y2 = lastOutputY;
  
  if (GraphEditor* const hostPanel = getGraphPanel())
  {
    if (FilterComponent* srcFilterComp = hostPanel->getComponentForFilter (sourceFilterID))
      srcFilterComp->getPinPos (sourceFilterChannel, false, x1, y1);
    
    if (FilterComponent* dstFilterComp = hostPanel->getComponentForFilter (destFilterID))
      dstFilterComp->getPinPos (destFilterChannel, true, x2, y2);
  }
}
Example #7
0
void FilterComponent::mouseDrag (const MouseEvent& e)
{
  if (! e.mods.isPopupMenu())
  {
    Point<int> pos (originalPos + Point<int> (e.getDistanceFromDragStartX(), e.getDistanceFromDragStartY()));
    
    if (getParentComponent() != nullptr)
      pos = getParentComponent()->getLocalPoint (nullptr, pos);
    
    endPos.x = (pos.getX() + getWidth() / 2) / (double) getParentWidth();
    endPos.y = (pos.getY() + getHeight() / 2) / (double) getParentHeight();
    
    audioEngine.getDoc().setNodePosition (nodeId, endPos.x, endPos.y);
    
    getGraphPanel()->updateComponents();
  }
}
Example #8
0
    void getPoints (float& x1, float& y1, float& x2, float& y2) const
    {
        x1 = lastInputX;
        y1 = lastInputY;
        x2 = lastOutputX;
        y2 = lastOutputY;

        GraphEditorPanel* const hostPanel = getGraphPanel();

        if (hostPanel != nullptr)
        {
            FilterComponent* srcFilterComp = hostPanel->getComponentForFilter (sourceFilterID);

            if (srcFilterComp != nullptr)
                srcFilterComp->getPinPos (sourceFilterChannel, false, x1, y1);

            FilterComponent* dstFilterComp = hostPanel->getComponentForFilter (destFilterID);

            if (dstFilterComp != nullptr)
                dstFilterComp->getPinPos (destFilterChannel, true, x2, y2);
        }
    }
Example #9
0
void FilterComponent::paint (Graphics& g)
{
  g.setColour (Colours::lightgrey);
  
  if (highlight)
    g.setColour (Colours::white);

  const int x = 4;
  const int y = pinSize;
  const int w = getWidth() - x * 2;
  const int h = getHeight() - pinSize * 2;
  
  g.fillRect(x, y, w, h);

  g.setColour (Colours::black);
  
  if (getGraphPanel()->getLassoSelection().isSelected(this))
    g.setColour (Colours::black);
  else
    g.setColour (Colours::grey);
  
  g.drawRoundedRectangle(x, y, w, h, 2, 1);
}
Example #10
0
 void mouseUp (const MouseEvent& e)
 {
     if (dragging)
         getGraphPanel()->endDraggingConnector (e);
 }
Example #11
0
 void mouseDrag (const MouseEvent& e)
 {
     getGraphPanel()->dragConnector (e);
 }
Example #12
0
void PinComponent::mouseUp (const MouseEvent& e)
{
  getGraphPanel()->endDraggingConnector (e);
}
Example #13
0
void PinComponent::mouseDrag (const MouseEvent& e)
{
  getGraphPanel()->dragConnector (e);
}
Example #14
0
void FilterComponent::mouseDown (const MouseEvent& e)
{
  originalPos = localPointToGlobal (Point<int>());
  
  toFront (true);
  
  if (e.mods.isPopupMenu())
  {
    PopupMenu m;
    m.addItem (1, "Delete this node");
    m.addItem (2, "Disconnect all pins");
    
    if (AudioProcessorGraph::Node::Ptr f = audioEngine.getDoc().getNodeForId (nodeId))
    {
      AudioProcessor* const processor = f->getProcessor();
      jassert (processor != nullptr);
      
      if(!InternalPluginFormat::isInternalFormat(processor->getName()))
      {
        bool hasParams = (processor->getNumParameters() > 0);
        
        m.addItem (3, "Add a pMix Preset", hasParams);
        m.addItem (4, "Set pMix Colour", hasParams);
        m.addItem (5, "Interpolate all Parameters", hasParams);
        m.addItem (6, "Clear all Parameters", hasParams);
        m.addSeparator();
        m.addItem (7, "Show plugin UI");
      }
    }
    
    const int r = m.show();
    
    if (r == 1)
    {
      if (AudioProcessorGraph::Node::Ptr f = audioEngine.getDoc().getNodeForId (nodeId))
      {
        AudioPluginInstance* const instance = dynamic_cast<AudioPluginInstance*>(f->getProcessor());
      
        if (instance)
        {
          removeEditor();
          
          audioEngine.getDoc().beginTransaction();
          audioEngine.getDoc().perform(new RemoveFilterAction(audioEngine, *getGraphPanel(), nodeId), TRANS("remove node"));
        }
      }
      return;
    }
    else if (r == 2)
    {
      audioEngine.getDoc().disconnectFilter (nodeId);
    }
    else if (r == 3)
    {
      Random rand;
      audioEngine.getDoc().addPreset(nodeId, rand.nextFloat(), rand.nextFloat());
    }
    else if (r == 4)
    {
      ColourSelector* colourSelector = new ColourSelector(ColourSelector::showSliders|ColourSelector::showColourAtTop|ColourSelector::showColourspace);
      colourSelector->setName ("background");
      colourSelector->setCurrentColour (audioEngine.getDoc().getFilterColour(nodeId));
      colourSelector->addChangeListener (this);
      colourSelector->setColour (ColourSelector::backgroundColourId, Colours::lightgrey);
      colourSelector->setSize (300, 400);
      
      CallOutBox::launchAsynchronously (colourSelector, getScreenBounds(), nullptr);
    }
    else if (r == 5 || r == 6)
    {
      if (AudioProcessorGraph::Node::Ptr f = audioEngine.getDoc().getNodeForId (nodeId))

      {
        for (int p=0; p < f->getProcessor()->getNumParameters(); p++)
        {
          audioEngine.getDoc().setParameterToInterpolate(nodeId, p, r==5);
        }
        
        repaint();
      }
    }
    else
    {
      if (AudioProcessorGraph::Node::Ptr f = audioEngine.getDoc().getNodeForId (nodeId))
      {
        AudioProcessor* const processor = f->getProcessor();
        jassert (processor != nullptr);
        
        String name = processor->getName();
        
        if (r > 0)
        {
          PluginWindow::WindowFormatType type = processor->hasEditor() ? PluginWindow::Normal : PluginWindow::Generic;
          
          if (PluginWindow* const w = PluginWindow::getWindowFor (f, type))
            w->toFront (true);
        }
      }
    }
  }
  else
  {
    moving = true;
    getGraphPanel()->getLassoSelection().selectOnly(this);
    audioEngine.getDoc().getNodePosition(nodeId, startPos.x, startPos.y);
  }
}