void buttonClicked(Button* button) { if (button == &colourButton) { ColourSelector colourSelector (ColourSelector::showColourAtTop | ColourSelector::showColourspace); colourSelector.setSize (200, 200); CallOutBox callOut (colourSelector, colourButton, nullptr); callOut.runModalLoop(); setProperties(startTime, endTime, colourSelector.getCurrentColour().getARGB()); } else if (button == &timeButton) { // ownerListBoxModel->filePlayer->setActiveLoopPoint (startTime, endTime, loopIndex, timeButton.getToggleState()); ownerListBoxModel->filePlayer->setLoopTimes (startTime, endTime); ownerListBoxModel->filePlayer->setLoopBetweenTimes (timeButton.getToggleState()); } else if (button == &removeButton) { ownerListBoxModel->dataList.removeProperty(propertyName, nullptr); ownerListBoxModel->getNumRows(); ownerListBoxModel->reorderLoopPoints(); } }
void ProcessorList::changeListenerCallback(ChangeBroadcaster* source) { ColourSelector* cs = dynamic_cast <ColourSelector*>(source); setColour(currentColor, cs->getCurrentColour()); repaint(); }
//============================================================================== void CpuRamEditor::changeListenerCallback (ChangeBroadcaster* source) { if (source==getFilter()) { updateParametersFromFilter(); } else { ColourSelector* cs = (ColourSelector*) source; getFilter()->bgcolor=(cs->getCurrentColour()); infoLabel->setColour(Label::textColourId,getFilter()->bgcolor.contrasting(0.8f)); memLabel2->setColour(Label::textColourId,getFilter()->bgcolor.contrasting(0.8f)); slider->setColour(Slider::textBoxTextColourId,getFilter()->bgcolor.contrasting(0.8f)); repaint(); } }
void BigClockEditor::changeListenerCallback (ChangeBroadcaster* source) { if (source==getFilter()) { updateParametersFromFilter(); } else { ColourSelector* cs = 0; cs = (ColourSelector*) source; if (cs) { getFilter()->bgcolor=(cs->getCurrentColour()); infoLabel->textcolor = cs->getCurrentColour().contrasting(getFilter()->getParameter(kLook)); repaint(); } } }
//============================================================================== void GraphComponent::changeListenerCallback (void* source) { ColourSelector* cs = (ColourSelector*) source; if (currentClickedNode) { Colour currentColour = cs->getCurrentColour(); BasePlugin* plugin = (BasePlugin*) currentClickedNode->getUserData (); if (plugin) plugin->setValue (PROP_GRAPHCOLOUR, currentColour.toString ()); currentClickedNode->setNodeColour (currentColour); currentClickedNode->repaint (); Viewport* parent = findParentComponentOfClass ((Viewport*) 0); if (parent) { parent->notifyComponentChanged (); } } }
void mouseDown (const MouseEvent&) override { ColourSelector* colourSelector = new ColourSelector(); colourSelector->setName ("Colour"); colourSelector->setCurrentColour (getColour()); colourSelector->addChangeListener (this); colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack); colourSelector->setSize (300, 400); CallOutBox::launchAsynchronously (colourSelector, getScreenBounds(), nullptr); }
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); } }
void GraphComponent::nodePopupMenuSelected (GraphNodeComponent* node) { DBG ("GraphComponent::nodePopupMenuSelected"); jassert (node != 0); currentClickedNode = node; bool addFirstSeparator = false; PopupMenu menu, subMenu; BasePlugin* plugin = (BasePlugin*) node->getUserData (); if (plugin->hasEditor () || plugin->wantsEditor () || plugin->isEditorInternal ()) { menu.addItem (1, "Open editor"); addFirstSeparator = true; } if (node != inputs && node != outputs) { menu.addItem (2, "Remove " + plugin->getName()); addFirstSeparator = true; } if (addFirstSeparator) menu.addSeparator (); menu.addItem (3, "Lock", true, node->isLocked ()); // node colour.. ColourSelector colourSelector; colourSelector.setName (T("background")); colourSelector.setCurrentColour (node->getNodeColour ()); colourSelector.addChangeListener (this); subMenu.addCustomItem (1234, &colourSelector, 300, 300, false); menu.addSubMenu (T("Colour"), subMenu); menu.addSeparator (); menu.addItem (4, "Mute", true, plugin->isMuted ()); menu.addItem (5, "Bypass", true, plugin->isBypass ()); menu.addItem (6, "Solo", false, false); menu.addSeparator (); int inputLinks = node->getInputLinksCount (); int outputLinks = node->getOutputLinksCount (); if (inputLinks > 0 && outputLinks > 0) menu.addItem (7, "Disconnect all"); if (inputLinks > 0) menu.addItem (8, "Disconnect inputs"); if (outputLinks > 0) menu.addItem (9, "Disconnect outputs"); const int result = menu.show(); switch (result) { case 1: // Open editor { owner->openPluginEditorWindow (plugin); break; } case 2: // Close { if (owner->isPluginEditorWindowOpen (plugin)) owner->closePluginEditorWindow (plugin); if (plugin) { host->closePlugin (plugin); selectedNodes.deselect (node); deletePluginNode (node); graphChanged (); } break; } case 3: // Lock / unlock { bool lockedState = ! node->isLocked (); if (plugin) plugin->setValue (PROP_GRAPHLOCKED, lockedState); node->setLocked (lockedState); node->repaint (); } break; case 4: // Mute { if (plugin) plugin->setMuted (! plugin->isMuted()); } break; case 5: // Bypass { if (plugin) plugin->setBypass (! plugin->isBypass()); } break; case 6: // Solo (TODO) break; case 7: // Disconnect all node->breakAllLinks(); break; case 8: // Disconnect inputs node->breakInputLinks(); break; case 9: // Disconnect outputs node->breakOutputLinks(); break; default: break; } currentClickedNode = 0; }
void GraphComponent::nodePopupMenuSelected (GraphNodeComponent* node) { DBG ("GraphComponent::nodePopupMenuSelected"); jassert (node != 0); currentClickedNode = node; bool addFirstSeparator = false; PopupMenu menu, subMenu, synthMidiChanMenu, midiChanMenu; BasePlugin* plugin = (BasePlugin*) node->getUserData (); if (plugin->hasEditor () || plugin->wantsEditor () || plugin->isEditorInternal ()) { menu.addItem (1, "Open editor"); menu.addItem (2, "Prefer MIDI binding editor", true, plugin->getBoolValue(PROP_WINDOWPREFERGENERIC, false)); addFirstSeparator = true; } if (node != inputs && node != outputs) { menu.addItem (3, "Remove " + plugin->getName() + String(" \"") + plugin->getInstanceName() + String("\"")); addFirstSeparator = true; } if (addFirstSeparator) menu.addSeparator (); menu.addItem (4, "Lock", true, node->isLocked ()); // node colour.. ColourSelector colourSelector; colourSelector.setName (T("background")); colourSelector.setCurrentColour (node->getNodeColour ()); colourSelector.addChangeListener (this); subMenu.addCustomItem (1234, &colourSelector, 300, 300, false); menu.addSubMenu (T("Colour"), subMenu); menu.addSeparator (); menu.addItem (5, "Mute", true, plugin->isMuted ()); menu.addItem (6, "Bypass", true, plugin->isBypass ()); menu.addItem (7, "Solo", false, false); menu.addSeparator (); synthMidiChanMenu.addItem(2020, "Omni", true, !plugin->getSynthInputChannelFilter() || plugin->getSynthInputChannel() == -1); midiChanMenu.addItem(1020, "Omni", true, !plugin->getMidiOutputChannelFilter() || plugin->getMidiOutputChannel() == -1); for (int i=1; i<17; i++) { synthMidiChanMenu.addItem(2000+i, String("Ch ") + String(i), true, plugin->getSynthInputChannelFilter() && plugin->getSynthInputChannel() == i); midiChanMenu.addItem(1000+i, String("Ch ") + String(i), true, plugin->getMidiOutputChannelFilter() && plugin->getMidiOutputChannel() == i); } menu.addSubMenu (T("Filter synth input MIDI channel"), synthMidiChanMenu); menu.addSubMenu (T("Filter output MIDI channel"), midiChanMenu); menu.addSeparator (); int inputLinks = node->getInputLinksCount (); int outputLinks = node->getOutputLinksCount (); if (inputLinks > 0 && outputLinks > 0) menu.addItem (8, "Disconnect all"); if (inputLinks > 0) menu.addItem (9, "Disconnect inputs"); if (outputLinks > 0) menu.addItem (10, "Disconnect outputs"); menu.addItem (11, String("Rename \"") + plugin->getInstanceName() + String("\"")); menu.addItem (12, "Render stem", true, plugin->getBoolValue(PROP_RENDERSTEM, false)); // only allow changing this if stems aren't rendering right now (i.e. files aren't opened) const int result = menu.show(); switch (result) { case 1: // Open editor { owner->openPluginEditorWindow (plugin); break; } case 2: // set preferred editor plugin->setValue(PROP_WINDOWPREFERGENERIC, !plugin->getBoolValue(PROP_WINDOWPREFERGENERIC, false)); break; case 12: // set stem render option plugin->setValue(PROP_RENDERSTEM, !plugin->getBoolValue(PROP_RENDERSTEM, false)); break; case 3: // Close { if (owner->isPluginEditorWindowOpen (plugin)) owner->closePluginEditorWindow (plugin); if (plugin) { host->closePlugin (plugin); selectedNodes.deselect (node); deletePluginNode (node); graphChanged (); } break; } case 4: // Lock / unlock { bool lockedState = ! node->isLocked (); if (plugin) plugin->setValue (PROP_GRAPHLOCKED, lockedState); node->setLocked (lockedState); node->repaint (); } break; case 5: // Mute { if (plugin) plugin->setMuted (! plugin->isMuted()); } break; case 6: // Bypass { if (plugin) plugin->setBypass (! plugin->isBypass()); } break; case 7: // Solo (TODO) break; case 8: // Disconnect all node->breakAllLinks(); break; case 9: // Disconnect inputs node->breakInputLinks(); break; case 10: // Disconnect outputs node->breakOutputLinks(); break; case 11: // Rename instance { TextEditor instanceName(String("renamePluginInstance")); instanceName.setSize(400, 30); instanceName.setText(plugin->getInstanceName()); DialogWindow::showModalDialog(String("Rename " + plugin->getInstanceName()), &instanceName, node, Colours::yellow, true); String newName = instanceName.getText(); if (newName.isNotEmpty()) setNodeDisplayName(plugin, node, newName); } break; case 1020: plugin->clearMidiOutputFilter(); break; case 2020: plugin->clearSynthInputFilter(); break; default: if (result >= 1001 && result <= 1016) plugin->setMidiOutputChannelFilter(result - 1000); if (result >= 2001 && result <= 2016) plugin->setSynthInputChannelFilter(result - 2000); break; } currentClickedNode = 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); } }
void showWindow (Component& button, DialogType type) { if (type >= plainAlertWindow && type <= questionAlertWindow) { AlertWindow::AlertIconType icon = AlertWindow::NoIcon; switch (type) { case warningAlertWindow: icon = AlertWindow::WarningIcon; break; case infoAlertWindow: icon = AlertWindow::InfoIcon; break; case questionAlertWindow: icon = AlertWindow::QuestionIcon; break; default: break; } AlertWindow::showMessageBoxAsync (icon, "This is an AlertWindow", "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.", "ok"); } else if (type == okCancelAlertWindow) { AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, "This is an ok/cancel AlertWindow", "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.", String::empty, String::empty, 0, ModalCallbackFunction::forComponent (alertBoxResultChosen, this)); } else if (type == calloutBoxWindow) { ColourSelector* colourSelector = new ColourSelector(); colourSelector->setName ("background"); colourSelector->setCurrentColour (findColour (TextButton::buttonColourId)); colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack); colourSelector->setSize (300, 400); CallOutBox::launchAsynchronously (colourSelector, button.getScreenBounds(), nullptr); } else if (type == extraComponentsAlertWindow) { #if JUCE_MODAL_LOOPS_PERMITTED AlertWindow w ("AlertWindow demo..", "This AlertWindow has a couple of extra components added to show how to add drop-down lists and text entry boxes.", AlertWindow::QuestionIcon); w.addTextEditor ("text", "enter some text here", "text field:"); const char* options[] = { "option 1", "option 2", "option 3", "option 4", nullptr }; w.addComboBox ("option", StringArray (options), "some options"); w.addButton ("ok", 1, KeyPress (KeyPress::returnKey, 0, 0)); w.addButton ("cancel", 0, KeyPress (KeyPress::escapeKey, 0, 0)); if (w.runModalLoop() != 0) // is they picked 'ok' { // this is the item they chose in the drop-down list.. const int optionIndexChosen = w.getComboBoxComponent ("option")->getSelectedItemIndex(); (void) optionIndexChosen; // (just avoids a compiler warning about unused variables) // this is the text they entered.. String text = w.getTextEditorContents ("text"); } #endif } else if (type == progressWindow) { // This will launch our ThreadWithProgressWindow in a modal state. (Our subclass // will take care of deleting the object when the task has finished) (new DemoBackgroundThread())->launchThread(); } else if (type >= loadChooser && type <= saveChooser) { #if JUCE_MODAL_LOOPS_PERMITTED const bool useNativeVersion = nativeButton.getToggleState(); if (type == loadChooser) { FileChooser fc ("Choose a file to open...", File::getCurrentWorkingDirectory(), "*", useNativeVersion); if (fc.browseForMultipleFilesToOpen()) { String chosen; for (int i = 0; i < fc.getResults().size(); ++i) chosen << fc.getResults().getReference(i).getFullPathName() << "\n"; AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, "File Chooser...", "You picked: " + chosen); } } else if (type == loadWithPreviewChooser) { ImagePreviewComponent imagePreview; imagePreview.setSize (200, 200); FileChooser fc ("Choose an image to open...", File::getSpecialLocation (File::userPicturesDirectory), "*.jpg;*.jpeg;*.png;*.gif", useNativeVersion); if (fc.browseForMultipleFilesToOpen (&imagePreview)) { String chosen; for (int i = 0; i < fc.getResults().size(); ++i) chosen << fc.getResults().getReference (i).getFullPathName() << "\n"; AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, "File Chooser...", "You picked: " + chosen); } } else if (type == saveChooser) { FileChooser fc ("Choose a file to save...", File::getCurrentWorkingDirectory(), "*", useNativeVersion); if (fc.browseForFileToSave (true)) { File chosenFile = fc.getResult(); AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, "File Chooser...", "You picked: " + chosenFile.getFullPathName()); } } else if (type == directoryChooser) { FileChooser fc ("Choose a directory...", File::getCurrentWorkingDirectory(), "*", useNativeVersion); if (fc.browseForDirectory()) { File chosenDirectory = fc.getResult(); AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, "File Chooser...", "You picked: " + chosenDirectory.getFullPathName()); } } #endif } }