void filesDropped (const StringArray& files, int /*x*/, int /*y*/) { AudioDemoPlaybackPage* demoPage = findParentComponentOfClass ((AudioDemoPlaybackPage*) 0); if (demoPage != 0) demoPage->showFile (File (files[0])); }
void GraphComponent::mouseDrag (const MouseEvent& e) { if (e.mods.isLeftButtonDown()) { lassoComponent->toFront (false); lassoComponent->dragLasso (e); } else if (e.mods.isMiddleButtonDown ()) { Viewport* parent = findParentComponentOfClass ((Viewport*) 0); if (parent) { int x = dragStartX - e.getDistanceFromDragStartX (); int y = dragStartY - e.getDistanceFromDragStartY (); Component* comp = parent->getViewedComponent (); if (comp) { x = jmax (0, jmin (comp->getWidth () - parent->getViewWidth (), x)); y = jmax (0, jmin (comp->getHeight () - parent->getViewHeight (), y)); } parent->setViewPosition (x, y); setMouseCursor (MouseCursor::DraggingHandCursor); } } else if (e.mods.isRightButtonDown ()) { } }
void currentTabChanged (int, const String&) { // (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug) MultiDocumentPanel* const owner = findParentComponentOfClass ((MultiDocumentPanel*) nullptr); if (owner != nullptr) owner->updateOrder(); }
void ApplicationSettingsComponent::buttonClicked (Button* buttonThatWasClicked) { //[UserbuttonClicked_Pre] //[/UserbuttonClicked_Pre] if (buttonThatWasClicked == connectButton) { //[UserButtonCode_connectButton] -- add your button handler code here.. ApplicationConfiguration::getBlipClient()->disconnect(); String port = serialPortComboBox->getText(); String speed = serialSpeedComboBox->getText(); ApplicationConfiguration::getBlipClient()->setPort(port); ApplicationConfiguration::getBlipClient()->setSpeed(speed.getIntValue()); ApplicationConfiguration::getBlipClient()->connect(); std::cout << "connected: " << ApplicationConfiguration::getBlipClient()->isConnected() << std::endl; //[/UserButtonCode_connectButton] } else if (buttonThatWasClicked == okButton) { //[UserButtonCode_okButton] -- add your button handler code here.. saveSettingsToFile(); setVisible(false); DialogWindow* dw = findParentComponentOfClass((DialogWindow*)nullptr); if(dw != nullptr) dw->exitModalState(1); //[/UserButtonCode_okButton] } else if (buttonThatWasClicked == cancelButton) { //[UserButtonCode_cancelButton] -- add your button handler code here.. setVisible(false); DialogWindow* dw = findParentComponentOfClass((DialogWindow*)nullptr); if(dw != nullptr) dw->exitModalState(0); //[/UserButtonCode_cancelButton] } //[UserbuttonClicked_Post] //[/UserbuttonClicked_Post] }
void HostFilterComponent::setCurrentSessionFile(const File& newFile) { currentSessionFile = newFile; StandaloneFilterWindow* window = findParentComponentOfClass ((StandaloneFilterWindow*) 0); if (window) { String jostMainWindowName; String filename = currentSessionFile.getFileNameWithoutExtension(); jostMainWindowName << JucePlugin_Name; if (!filename.isEmpty()) jostMainWindowName << " - " << filename; window->setName(jostMainWindowName); } }
void DocumentEditorComponent::documentAboutToClose (OpenDocumentManager::Document* closingDoc) { if (document == closingDoc) { jassert (document != nullptr); ProjectContentComponent* pcc = findParentComponentOfClass ((ProjectContentComponent*) 0); if (pcc != nullptr) { pcc->hideDocument (document); return; } jassertfalse }
void GraphEditorPanel::mouseDown (const MouseEvent& e) { if (e.mods.isPopupMenu()) { PopupMenu m; MainHostWindow* const mainWindow = findParentComponentOfClass ((MainHostWindow*) nullptr); if (mainWindow != nullptr) { mainWindow->addPluginsToMenu (m); const int r = m.show(); createNewPlugin (mainWindow->getChosenType (r), e.x, e.y); } } }
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 (); } }
//============================================================================== 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 GraphComponent::mouseDown (const MouseEvent& e) { if (e.mods.isLeftButtonDown()) { selectedNodes.deselectAll (); lassoComponent->beginLasso (e, this); } else if (e.mods.isMiddleButtonDown ()) { Viewport* parent = findParentComponentOfClass ((Viewport*) 0); if (parent) { dragStartX = parent->getViewPositionX (); dragStartY = parent->getViewPositionY (); setMouseCursor (MouseCursor::DraggingHandCursor); } } else if (e.mods.isRightButtonDown ()) { } }
GraphEditorPanel* getGraphPanel() const noexcept { return findParentComponentOfClass ((GraphEditorPanel*) nullptr); }
//============================================================================== bool GraphComponent::createPluginNode (BasePlugin* plugin) { if (plugin) { DBG ("GraphComponent::createPluginNode"); GraphNodeComponent* component; addAndMakeVisible (component = new GraphNodeComponent()); component->setNodeListener (this); // set common data component->setUserData (plugin); component->setUniqueID (plugin->getUniqueHash()); component->setText (plugin->getName ()); component->setLeftToRight (leftToRight); component->setNodeColour (Colour::fromString (plugin->getValue (PROP_GRAPHCOLOUR, T("0xff808080")))); // read properties // int maxPortCount = jmax (plugin->getNumInputs () + plugin->getNumMidiInputs (), // plugin->getNumOutputs () + plugin->getNumMidiOutputs ()); // TODO - if (maxPortCount * portWidth > defaultNodeWidth) ... int pluginType = plugin->getType(); int w = defaultNodeWidth, h = defaultNodeHeight; int numIns = plugin->getNumInputs () + plugin->getNumMidiInputs (); int numOuts = plugin->getNumOutputs () + plugin->getNumMidiOutputs (); if (leftToRight) { h = jmax (h, (jmax (numIns, numOuts) + 1) * 16); const int textHeight = currentFont.getStringWidth (plugin->getName()); h = jmax (h, 16 + jmin (textHeight, 300)); } else { w = jmax (w, (jmax (numIns, numOuts) + 1) * 16); const int textWidth = currentFont.getStringWidth (plugin->getName()); w = jmax (w, 16 + jmin (textWidth, 300)); } int wasLocked = plugin->getIntValue (PROP_GRAPHLOCKED, -1); if (wasLocked < 0) wasLocked = 0; int wasSelected = plugin->getIntValue (PROP_GRAPHSELECTED, 0); int xPos = plugin->getIntValue (PROP_GRAPHXPOS, -1); int yPos = plugin->getIntValue (PROP_GRAPHYPOS, -1); int wSize = plugin->getIntValue (PROP_GRAPHWSIZE, w); if (wSize < 0) wSize = defaultNodeWidth; int hSize = plugin->getIntValue (PROP_GRAPHHSIZE, h); if (hSize < 0) hSize = defaultNodeHeight; String pluginTooltip = plugin->getName (); // input plugin if (pluginType == JOST_PLUGINTYPE_INPUT) { inputs = component; if (xPos < 0) xPos = leftToRight ? 2 : (getWidth () - w) / 2; if (yPos < 0) yPos = leftToRight ? (getHeight() - h) / 2 : 2; } // output plugin else if (pluginType == JOST_PLUGINTYPE_OUTPUT) { outputs = component; if (xPos < 0) xPos = leftToRight ? getWidth () - w - 2 : (getWidth () - w) / 2; if (yPos < 0) yPos = leftToRight ? (getHeight() - h) / 2 : getHeight() - h - 2; } // generic plugin else { if (xPos < 0) xPos = getBounds().getCentreX(); if (yPos < 0) yPos = getBounds().getCentreY(); pluginTooltip = plugin->getFile ().getFullPathName (); } component->setBounds (xPos, yPos, wSize, hSize); component->setLocked (wasLocked); component->setTooltip (pluginTooltip); component->setVisible (true); if (wasSelected) selectedNodes.addToSelection (component); plugin->setValue (PROP_GRAPHXPOS, xPos); plugin->setValue (PROP_GRAPHYPOS, yPos); plugin->setValue (PROP_GRAPHWSIZE, wSize); plugin->setValue (PROP_GRAPHHSIZE, hSize); // restore audio input / output ports if (pluginType != JOST_PLUGINTYPE_INPUT) for (int j = 0; j < plugin->getNumInputs (); j++) component->addInputConnector (JOST_LINKTYPE_AUDIO); // audio cable if (pluginType != JOST_PLUGINTYPE_OUTPUT) for (int j = 0; j < plugin->getNumOutputs (); j++) component->addOutputConnector (JOST_LINKTYPE_AUDIO); // audio cable // restore midi input / output ports if (pluginType != JOST_PLUGINTYPE_INPUT) for (int j = 0; j < plugin->getNumMidiInputs (); j++) component->addInputConnector (JOST_LINKTYPE_MIDI); // midi cable if (pluginType != JOST_PLUGINTYPE_OUTPUT) for (int j = 0; j < plugin->getNumMidiOutputs (); j++) component->addOutputConnector (JOST_LINKTYPE_MIDI); // midi cable nodes.add (component); Viewport* parent = findParentComponentOfClass ((Viewport*) 0); if (parent) { parent->notifyComponentChanged (); } return true; } return false; }
void GraphComponent::graphChanged () { DBG ("GraphComponent::graphChanged"); jassert (host != 0); // just to be sure ! // AUDIO - ProcessingGraph* audioGraph = new ProcessingGraph (); // starting from inputs recalculateConnectionsRecursive (inputs, audioGraph, 0, true); // then adding outputs if not already recalculateConnectionsRecursive (outputs, audioGraph, audioGraph->getNodeCount (), true); // all the others that are not connected (add them after input) for (int i = 0; i < nodes.size (); i++) { recalculateConnectionsRecursive (nodes.getUnchecked (i), audioGraph, 1, true); } host->changePluginAudioGraph (audioGraph); #if JUCE_DEBUG printf ("MIDI > \n"); for (int i = 0; i < audioGraph->getNodeCount (); i++) { BasePlugin* plugin = (BasePlugin*) audioGraph->getData (i); printf ("%s > ", (const char*) plugin->getName()); } printf ("\n"); printf ("MIDI CONNECTIONS > \n"); for (int i = 0; i < audioGraph->getNodeCount (); i++) { ProcessingNode* node = audioGraph->getNode (i); if (node) { for (int j = 0; j < node->getLinksCount (JOST_LINKTYPE_MIDI); j++) { ProcessingLink* conn = node->getLink (JOST_LINKTYPE_MIDI, j); printf ("%s,%d > %s,%d \n", (const char*) ((BasePlugin*)node->getData())->getName(), conn->sourcePort, (const char*) ((BasePlugin*)conn->destination->getData())->getName(), conn->destinationPort); } } } printf ("\n"); printf ("AUDIO > \n"); for (int i = 0; i < audioGraph->getNodeCount (); i++) { BasePlugin* plugin = (BasePlugin*) audioGraph->getData (i); printf ("%s > ", (const char*) plugin->getName()); } printf ("\n"); printf ("AUDIO CONNECTIONS > \n"); for (int i = 0; i < audioGraph->getNodeCount (); i++) { ProcessingNode* node = audioGraph->getNode (i); if (node) { for (int j = 0; j < node->getLinksCount (JOST_LINKTYPE_AUDIO); j++) { ProcessingLink* conn = node->getLink (JOST_LINKTYPE_AUDIO, j); printf ("%s,%d > %s,%d \n", (const char*) ((BasePlugin*)node->getData())->getName(), conn->sourcePort, (const char*) ((BasePlugin*)conn->destination->getData())->getName(), conn->destinationPort); } } } printf ("\n"); #endif Viewport* parent = findParentComponentOfClass ((Viewport*) 0); if (parent) { parent->notifyComponentChanged (); } }
bool HostFilterComponent::perform (const InvocationInfo& info) { Config* config = Config::getInstance(); GraphComponent* graph = main->getGraph (); Transport* transport = getFilter()->getTransport(); switch (info.commandID) { //---------------------------------------------------------------------------------------------- case CommandIDs::pluginOpen: { graph->loadAndAppendPlugin (); break; } case CommandIDs::pluginClose: { graph->closeSelectedPlugins (); break; } case CommandIDs::pluginClear: { graph->closeAllPlugins (); break; } case CommandIDs::showPluginListEditor: { if (PluginListWindow::currentPluginListWindow == 0) PluginListWindow::currentPluginListWindow = new PluginListWindow (knownPluginList); PluginListWindow::currentPluginListWindow->toFront (true); break; } //---------------------------------------------------------------------------------------------- #ifndef JOST_VST_PLUGIN case CommandIDs::audioOptions: { StandaloneFilterWindow* window = findParentComponentOfClass ((StandaloneFilterWindow*) 0); if (window) window->showAudioSettingsDialog (); break; } #endif case CommandIDs::audioPlay: { transport->play (); break; } case CommandIDs::audioPlayPause: { transport->togglePlay (); break; } case CommandIDs::audioStop: { transport->stop (); break; } case CommandIDs::audioRecord: { transport->record (); break; } case CommandIDs::audioRewind: { transport->rewind (); break; } case CommandIDs::audioLoop: { transport->setLooping (! transport->isLooping()); break; } //---------------------------------------------------------------------------------------------- case CommandIDs::sessionNew: { bool retValue = AlertWindow::showYesNoCancelBox (AlertWindow::WarningIcon, T("Unsaved Changes"), T("Are you sure you want to close the current session? You may lose any unsaved changes.")); if (retValue) { closePluginEditorWindows (); getFilter()->getHost ()->closeAllPlugins (true); clearComponents (); Config::getInstance()->lastSessionFile = File::nonexistent; rebuildComponents (); } break; } case CommandIDs::sessionLoad: { FileChooser myChooser (T("Load a session file..."), Config::getInstance ()->lastSessionDirectory, JOST_SESSION_WILDCARD, JOST_USE_NATIVE_FILE_CHOOSER); if (myChooser.browseForFileToOpen()) { bool retValue = AlertWindow::showYesNoCancelBox (AlertWindow::WarningIcon, T("Unsaved Changes"), T("Are you sure you want to close the current session? You may lose any unsaved changes.")); if (retValue) { MemoryBlock fileData; File fileToLoad = myChooser.getResult(); if (fileToLoad.existsAsFile() && fileToLoad.loadFileAsData (fileData)) { getFilter ()->setStateInformation (fileData.getData (), fileData.getSize()); Config::getInstance()->addRecentSession (fileToLoad); Config::getInstance()->lastSessionFile = fileToLoad; } } } break; } case CommandIDs::sessionSave: { handleSaveCommand(); break; } case CommandIDs::sessionSaveNoPrompt: { handleSaveCommand(true); break; } case CommandIDs::audioStemsStartStop: { getHost()->toggleStemRendering(); break; } case CommandIDs::audioStemsSetup: { FileChooser myChooser (T("Save Rendered Stem Files To..."), Config::getInstance ()->lastStemsDirectory); if (myChooser.browseForDirectory ()) { Config::getInstance ()->lastStemsDirectory = myChooser.getResult(); } break; } //---------------------------------------------------------------------------------------------- case CommandIDs::appToolbar: { toolbar->showCustomisationDialog (*factory, Toolbar::allCustomisationOptionsEnabled); // (Toolbar::allowIconsOnlyChoice | Toolbar::showResetToDefaultsButton)); break; } case CommandIDs::appBrowser: { setBrowserVisible (! config->showBrowser, config->browserLeft); break; } case CommandIDs::appFullScreen: { DocumentWindow* window = findParentComponentOfClass <DocumentWindow> (); if (window) { window->setFullScreen (! window->isFullScreen ()); window->setMenuBar (window->isFullScreen () ? 0 : this); } break; } case CommandIDs::appExit: { deleteAndZero(PluginListWindow::currentPluginListWindow); JUCEApplication::getInstance()->systemRequestedQuit(); break; } case CommandIDs::appAbout: { // Image* splashImage = ImageCache::getFromMemory (Resource::jost_about, // Resource::jost_about_size); // todo: move appResourcesFolder() to somewhere everyone can use it #if JUCE_MAC File appResourcesFolder(File::getSpecialLocation(File::currentApplicationFile).getChildFile("./Contents/Resources")); #else File appResourcesFolder(File::getSpecialLocation(File::currentApplicationFile).getParentDirectory()); #endif File splashImageFile(appResourcesFolder.getChildFile("JiveAbout.png")); Image* splashImage = ImageFileFormat::loadFrom(splashImageFile); SplashScreen* splash = new SplashScreen(); splash->show (T(JucePlugin_Name), splashImage, 3500, false); break; } //---------------------------------------------------------------------------------------------- default: return false; } return true; }
MultiDocumentPanel* MultiDocumentPanelWindow::getOwner() const noexcept { // (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug) return findParentComponentOfClass ((MultiDocumentPanel*) nullptr); }