void Ambix_binauralAudioProcessorEditor::buttonClicked (Button* buttonThatWasClicked) { Ambix_binauralAudioProcessor* ourProcessor = getProcessor(); /* if (buttonThatWasClicked == btn_open) { FileChooser myChooser ("Please select the preset file to load...", ourProcessor->lastDir, "*.config"); if (myChooser.browseForFileToOpen()) { File mooseFile (myChooser.getResult()); ourProcessor->LoadConfiguration(mooseFile); UpdateText(); ourProcessor->lastDir = mooseFile.getParentDirectory(); } } */ if (buttonThatWasClicked == btn_open) { popup_presets.showMenuAsync(PopupMenu::Options().withTargetComponent (btn_open), ModalCallbackFunction::forComponent (menuItemChosenCallback, this)); } else if (buttonThatWasClicked == btn_preset_folder) { FileChooser myChooser ("Please select the new preset folder...", ourProcessor->presetDir, "*.config"); if (myChooser.browseForDirectory()) { File mooseFile (myChooser.getResult()); ourProcessor->presetDir = mooseFile; ourProcessor->SearchPresets(mooseFile); ourProcessor->lastDir = mooseFile.getParentDirectory(); UpdatePresets(); } } #if BINAURAL_DECODER if (buttonThatWasClicked == tgl_load_irs) { ourProcessor->_load_ir = tgl_load_irs->getToggleState(); } #endif }
void FileSearchPathListComponent::buttonClicked (Button* button) { const int currentRow = listBox.getSelectedRow(); if (button == &removeButton) { deleteKeyPressed (currentRow); } else if (button == &addButton) { File start (defaultBrowseTarget); if (start == File::nonexistent) start = path [0]; if (start == File::nonexistent) start = File::getCurrentWorkingDirectory(); #if JUCE_MODAL_LOOPS_PERMITTED FileChooser chooser (TRANS("Add a folder..."), start, "*"); if (chooser.browseForDirectory()) path.add (chooser.getResult(), currentRow); #else jassertfalse; // needs rewriting to deal with non-modal environments #endif } else if (button == &changeButton) { returnKeyPressed (currentRow); } else if (button == &upButton) { if (currentRow > 0 && currentRow < path.getNumPaths()) { const File f (path[currentRow]); path.remove (currentRow); path.add (f, currentRow - 1); listBox.selectRow (currentRow - 1); } } else if (button == &downButton) { if (currentRow >= 0 && currentRow < path.getNumPaths() - 1) { const File f (path[currentRow]); path.remove (currentRow); path.add (f, currentRow + 1); listBox.selectRow (currentRow + 1); } } changed(); }
void EnabledModuleList::addModuleFromUserSelectedFile() { static File lastLocation (findDefaultModulesFolder (project)); FileChooser fc ("Select a module to add...", lastLocation, String::empty, false); if (fc.browseForDirectory()) { lastLocation = fc.getResult(); addModuleOfferingToCopy (lastLocation); } }
void FileSearchPathListComponent::returnKeyPressed (int row) { #if JUCE_MODAL_LOOPS_PERMITTED FileChooser chooser (TRANS("Change folder..."), path [row], "*"); if (chooser.browseForDirectory()) { path.remove (row); path.add (chooser.getResult(), row); changed(); } #endif }
void FilenameComponent::buttonClicked (Button*) { #if JUCE_MODAL_LOOPS_PERMITTED FileChooser fc (isDir ? TRANS ("Choose a new directory") : TRANS ("Choose a new file"), getLocationToBrowse(), wildcard); if (isDir ? fc.browseForDirectory() : (isSaving ? fc.browseForFileToSave (false) : fc.browseForFileToOpen())) { setCurrentFile (fc.getResult(), true); } #else jassertfalse; // needs rewriting to deal with non-modal environments #endif }
//=============================================================================== void CabbageFileButton::buttonClicked (Button* button) { if (mode == "file") { const String lastKnownDirectory = owner->getLastOpenedDirectory(); FileChooser fc ("Choose File", lastKnownDirectory.isEmpty() ? File (getCsdFile()).getParentDirectory() : File (lastKnownDirectory), "", CabbageUtilities::shouldUseNativeBrowser()); if (fc.browseForFileToOpen()) { owner->sendChannelStringDataToCsound (getChannel(), returnValidPath (fc.getResult())); CabbageWidgetData::setStringProp (widgetData, CabbageIdentifierIds::file, returnValidPath (fc.getResult())); //owner->refreshComboBoxContents(); } owner->setLastOpenedDirectory (fc.getResult().getParentDirectory().getFullPathName()); } else if (mode == "save") { const String lastKnownDirectory = owner->getLastOpenedDirectory(); FileChooser fc ("Choose File", lastKnownDirectory.isEmpty() ? File (getCsdFile()).getParentDirectory() : File (lastKnownDirectory), "", CabbageUtilities::shouldUseNativeBrowser()); if (fc.browseForFileToSave(true)) { owner->sendChannelStringDataToCsound (getChannel(), returnValidPath (fc.getResult())); CabbageWidgetData::setStringProp (widgetData, CabbageIdentifierIds::file, returnValidPath (fc.getResult())); //owner->refreshComboBoxContents(); } owner->setLastOpenedDirectory (fc.getResult().getParentDirectory().getFullPathName()); owner->refreshComboListBoxContents(); startTimer(500); } else if (mode == "directory") { const String lastKnownDirectory = owner->getLastOpenedDirectory(); FileChooser fc ("Open Directory", lastKnownDirectory.isEmpty() ? File (getCsdFile()).getChildFile (getFilename()) : File (lastKnownDirectory), "", CabbageUtilities::shouldUseNativeBrowser()); if (fc.browseForDirectory()) { owner->sendChannelStringDataToCsound (getChannel(), returnValidPath (fc.getResult())); CabbageWidgetData::setStringProp (widgetData, CabbageIdentifierIds::file, returnValidPath (fc.getResult())); } owner->setLastOpenedDirectory (fc.getResult().getParentDirectory().getFullPathName()); } else if (mode == "snapshot") { String newFileName; if (owner->isAudioUnit()) newFileName = File(getCsdFile()).withFileExtension(".snaps").getFullPathName(); else newFileName = owner->createNewGenericNameForPresetFile(); owner->sendChannelStringDataToCsound (getChannel(), newFileName); owner->savePluginStateToFile (File (newFileName)); owner->refreshComboListBoxContents(); } else if (mode == "named snapshot") { String newFileName; if (owner->isAudioUnit()) newFileName = File(getCsdFile()).withFileExtension(".snaps").getFullPathName(); else newFileName = owner->createNewGenericNameForPresetFile(); #if JUCE_MODAL_LOOPS_PERMITTED String presetname; AlertWindow w ("Preset", "Set preset name (warning, will overwrite previous preset of same name)", AlertWindow::NoIcon); w.setLookAndFeel(&getLookAndFeel()); w.setSize(100, 100); w.addTextEditor ("text", "enter name here", ""); 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' { presetname = w.getTextEditorContents ("text"); } #endif owner->sendChannelStringDataToCsound (getChannel(), newFileName); owner->savePluginStateToFile (File (newFileName), presetname); owner->refreshComboListBoxContents(); } owner->getProcessor().updateHostDisplay(); }
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; }
void MainContentComponent::buttonClicked (Button *button) { if (button == installButton) { // === Locate the AlphaLive directory === alphaLiveDirectory = File::getSpecialLocation (File::globalApplicationsDirectory).getFullPathName() + File::separatorString + "AlphaLive"; bool continueInstallation = true; if (! alphaLiveDirectory.isDirectory()) { //If can't be found, ask user to manually locate it bool userSelection = AlertWindow::showOkCancelBox(AlertWindow::WarningIcon, translate("AlphaLive not found!"), translate("The AlphaLive folder can not be found on your computer. Please manually locate it.")); if (userSelection == true) { FileChooser myChooser (translate("Please select the AlphaLive directory..."), File::getSpecialLocation (File::globalApplicationsDirectory)); if (myChooser.browseForDirectory() == true) { // Perform some basic check to see if this is the AlphaLive directory #if JUCE_MAC || JUCE_LINUX File alphaLiveApp (myChooser.getResult().getFullPathName() + File::separatorString + "AlphaLive.app"); #endif #if JUCE_WINDOWS File alphaLiveApp (myChooser.getResult().getFullPathName() + File::separatorString + "AlphaLive.exe"); #endif if (alphaLiveApp.exists()) { // Presume that this is the AlphaLive directory alphaLiveDirectory = myChooser.getResult(); } else { AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, translate("Error!"), translate("The selected directory does not contain the AlphaLive application. Please try again.")); continueInstallation = false; } } else continueInstallation = false; } else continueInstallation = false; } if (continueInstallation == true) { startThread(); } } else if (button == closeButton) { JUCEApplication::quit(); } else if (button == cancelButton) { bool userSelection = AlertWindow::showOkCancelBox(AlertWindow::WarningIcon, translate("Are you sure?"), translate("Are you sure you want to cancel? The audio library will not be fully installed if so.")); if (userSelection == true) { signalThreadShouldExit(); } } }
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 } }