void mouseUp (const MouseEvent& e)
    {
        if (e.originalComponent != this)
        {
            if (mouseDragSource != nullptr)
                mouseDragSource->removeMouseListener (this);

            bool dropAccepted = false;
            DragAndDropTarget* ddt = nullptr;
            Point<int> relPos;

            if (isVisible())
            {
                setVisible (false);
                ddt = findTarget (e.getScreenPosition(), relPos);

                // fade this component and remove it - it'll be deleted later by the timer callback

                dropAccepted = ddt != nullptr;

                setVisible (true);

                if (dropAccepted || sourceDetails.sourceComponent == nullptr)
                {
                    Desktop::getInstance().getAnimator().fadeOut (this, 120);
                }
                else
                {
                    const Point<int> target (sourceDetails.sourceComponent->localPointToGlobal (sourceDetails.sourceComponent->getLocalBounds().getCentre()));
                    const Point<int> ourCentre (localPointToGlobal (getLocalBounds().getCentre()));

                    Desktop::getInstance().getAnimator().animateComponent (this,
                                                                           getBounds() + (target - ourCentre),
                                                                           0.0f, 120,
                                                                           true, 1.0, 1.0);
                }
            }

            if (getParentComponent() != nullptr)
                getParentComponent()->removeChildComponent (this);

            if (dropAccepted && ddt != nullptr)
            {
                // (note: use a local copy of this in case the callback runs
                // a modal loop and deletes this object before the method completes)
                DragAndDropTarget::SourceDetails details (sourceDetails);
                details.localPosition = relPos;

                currentlyOverComp = nullptr;

                ddt->itemDropped (details);
            }

            // careful - this object could now be deleted..
        }
    }
    void dismissWithAnimation (const bool shouldSnapBack)
    {
        setVisible (true);
        ComponentAnimator& animator = Desktop::getInstance().getAnimator();

        if (shouldSnapBack && sourceDetails.sourceComponent != nullptr)
        {
            const Point<int> target (sourceDetails.sourceComponent->localPointToGlobal (sourceDetails.sourceComponent->getLocalBounds().getCentre()));
            const Point<int> ourCentre (localPointToGlobal (getLocalBounds().getCentre()));

            animator.animateComponent (this,
                                       getBounds() + (target - ourCentre),
                                       0.0f, 120,
                                       true, 1.0, 1.0);
        }
        else
        {
            animator.fadeOut (this, 120);
        }
    }
Ejemplo n.º 3
0
    void mouseDown (const MouseEvent& e)
    {
        originalPos = localPointToGlobal (Point<int>());

        toFront (true);

        if (e.mods.isPopupMenu())
        {
            PopupMenu m;
            m.addItem (1, "Delete this filter");
            m.addItem (2, "Disconnect all pins");
            m.addSeparator();
            m.addItem (3, "Show plugin UI");
            m.addItem (4, "Show all parameters");

            const int r = m.show();

            if (r == 1)
            {
                graph.removeFilter (filterID);
                return;
            }
            else if (r == 2)
            {
                graph.disconnectFilter (filterID);
            }
            else if (r == 3 || r == 4)
            {
                AudioProcessorGraph::Node::Ptr f (graph.getNodeForId (filterID));

                if (f != nullptr)
                {
                    PluginWindow* const w = PluginWindow::getWindowFor (f, r == 4);

                    if (w != nullptr)
                        w->toFront (true);
                }
            }
        }
    }
Ejemplo n.º 4
0
void NodeComponent::mouseDown (const MouseEvent& e)
{
  originalPos = localPointToGlobal (Point<int>());
  
  toFront (true);
  
  if (e.mods.isPopupMenu())
  {
    PopupMenu m;
    m.addItem (1, TRANS("Delete this node"));
    m.addItem (2, TRANS("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, TRANS("Add a pMix Preset"), hasParams);
        m.addItem (4, TRANS("Set pMix Colour"), hasParams);
        m.addItem (5, TRANS("Interpolate all Parameters"), hasParams);
        m.addItem (6, TRANS("Clear all Parameters"), hasParams);
        m.addSeparator();
        
        int uiStatus = f->properties["uiStatus"];
        
        PopupMenu ui;
        ui.addItem (7, TRANS("Disabled"), true, uiStatus == kUIStatusNone);
        ui.addItem (8, TRANS("Embedded"), true, uiStatus == kUIStatusEmbed);
//        ui.addItem (9, TRANS("Floating"), true, uiStatus == kUIStatusFloating);

        m.addSubMenu (TRANS("Set UI Mode"), 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 RemoveNodeAction(audioEngine, *getGraphEditor(), nodeID), TRANS("remove node"));
          
          getGraphEditor()->clearSelection();
        }
      }
      return;
    }
    else if (r == 2)
    {
      audioEngine.getDoc().disconnectNode (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().getNodeColour(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 (r == 7)
    {
      audioEngine.getDoc().setNodeUIStatus(nodeID, kUIStatusNone);
      removeEditor();
      PluginWindow::closeCurrentlyOpenWindowsFor(nodeID);
      update();
    }
    else if (r == 8)
    {
      audioEngine.getDoc().setNodeUIStatus(nodeID, kUIStatusEmbed);
      PluginWindow::closeCurrentlyOpenWindowsFor(nodeID);
      update();
    }
//    else if (r == 9)
//    {
//      if (AudioProcessorGraph::Node::Ptr f = audioEngine.getDoc().getNodeForId (nodeID))
//      {
//        AudioProcessor* const processor = f->getProcessor();
//        jassert (processor != nullptr);
//        
//        String name = processor->getName();
//        
//        if (r > 0)
//        {
//          removeEditor();
//
//          PluginWindow::WindowFormatType type = processor->hasEditor() ? PluginWindow::Normal : PluginWindow::Generic;
//          
//          if (PluginWindow* const w = PluginWindow::getWindowFor (f, type))
//            w->toFront (true);
//          
//          audioEngine.getDoc().setNodeUIStatus(nodeID, kUIStatusFloating);
//          update();
//        };
//      }
//    }
  }
  else
  {
    moving = true;
    getGraphEditor()->getLassoSelection().selectOnly(this);
    audioEngine.getDoc().getNodePosition(nodeID, startPos.x, startPos.y);
  }
}
Ejemplo n.º 5
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);
  }
}