Ejemplo n.º 1
0
void DexedAudioProcessorEditor::saveCart() {
    File startFileName = processor->activeFileCartridge.exists() ? processor->activeFileCartridge : processor->dexedCartDir;

    FileChooser fc ("Export DX sysex...", processor->dexedCartDir, "*.syx", 1);
    if ( fc.browseForFileToSave(true) ) {
        if ( ! processor->currentCart.saveVoice(fc.getResults().getReference(0)) ) {
            AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
                                              "Error",
                                              "Unable to write: " + fc.getResults().getReference(0).getFullPathName());
        }
    }
}
Ejemplo n.º 2
0
void ProjectTreeViewBase::browseToAddExistingFiles()
{
    const File location (item.isGroup() ? item.determineGroupFolder() : getFile());
    FileChooser fc ("Add Files to Jucer Project", location, String::empty, false);

    if (fc.browseForMultipleFilesOrDirectories())
    {
        StringArray files;

        for (int i = 0; i < fc.getResults().size(); ++i)
            files.add (fc.getResults().getReference(i).getFullPathName());

        addFiles (files, 0);
    }
}
Ejemplo n.º 3
0
void CtrlrLuaMethodEditor::addMethodFromFile(ValueTree parentGroup)
{
	FileChooser fc ("Select LUA files", lastBrowsedSourceDir, "*.lua;*.txt");
	if (fc.browseForMultipleFilesToOpen ())
	{
		Array <File> results = fc.getResults();

		for (int i=0; i<results.size(); i++)
		{
			getMethodManager().addMethodFromFile (parentGroup, results[i]);
		}
	}

	updateRootItem();

	saveSettings(); // save settings
}
Ejemplo n.º 4
0
void DexedAudioProcessorEditor::saveCart() {
    File startFileName = processor->activeFileCartridge.exists() ? processor->activeFileCartridge : processor->dexedCartDir;

    FileChooser fc ("Export DX sysex...", processor->dexedCartDir, "*.syx", 1);
    if ( fc.browseForFileToSave(true) ) {
        String f = fc.getResults().getReference(0).getFullPathName();
        char syx_data[4104];
        
        exportSysexCart((char *) syx_data, (char *) &processor->sysex, 0);
        
        ofstream fp_out(f.toRawUTF8(), ios::binary);
        fp_out.write((char *)syx_data, 4104);
        fp_out.close();
        
        if (fp_out.fail()) {
            AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
                                              "Error",
                                              "Unable to write: " + f);
        }
    }
}
void CtrlrPanelResourceEditor::addResourceFromFile()
{
	FileChooser fileChooser ("Resource file", File(owner.getOwner().getCtrlrManager().getProperty(Ids::ctrlrLastBrowsedResourceDir)));
	if (fileChooser.browseForMultipleFilesToOpen(0))
 	{
		Array <File> filesToOpen = fileChooser.getResults();

		for (int i=0; i<filesToOpen.size(); i++)
		{
			if (i == 0)
				owner.getOwner().getCtrlrManager().setProperty (Ids::ctrlrLastBrowsedResourceDir, filesToOpen[i].getParentDirectory().getFullPathName());

			if (getResourceManager().resourceExists (filesToOpen[i]))
			{
				if ((bool)owner.getOwner().getOwner().getProperty(Ids::ctrlrOverwriteResources) == false)
				{
					if (!SURE("Resource: "+filesToOpen[i].getFileNameWithoutExtension()+" already exists. Overwrite?", this))
					{
						return;
					}
				}

				int index = getResourceManager().getResourceIndex(filesToOpen[i].getFileNameWithoutExtension());

				if (index >= 0)
				{
					getResourceManager().removeResource(index);
					getResourceManager().addResource (filesToOpen[i]);
				}
			}
			else
			{
 				getResourceManager().addResource (filesToOpen[i]);
			}
		}
 	}

	updateTable();
}
Ejemplo n.º 6
0
void mlrVSTGUI::buttonClicked(Button* btn)
{
    if(btn == &toggleSetlistBtn)
    {
        const bool currentlyVisible = presetPanel.isVisible();
        // close any existing panels
        closePanels();
        // Toggle the visibility of the setlist manager panel
        presetPanel.setVisible(!currentlyVisible);
        // and update the button
        toggleSetlistBtn.setToggleState(!currentlyVisible, NotificationType::dontSendNotification);
    }

    else if(btn == &toggleSettingsBtn)
    {
        const bool currentlyVisible = settingsPanel.isVisible();
        // close any existing panels
        closePanels();
        // Toggle the visibility of the settings panel
        settingsPanel.setVisible(!currentlyVisible);
        // and update the button
        toggleSettingsBtn.setToggleState(!currentlyVisible, NotificationType::dontSendNotification);
    }

    else if(btn == &toggleMappingBtn)
    {
        const bool currentlyVisible = mappingPanel.isVisible();
        // close any existing panels
        closePanels();
        // Toggle the settings panel
        mappingPanel.setVisible(!currentlyVisible);
        // and update the button
        toggleMappingBtn.setToggleState(!currentlyVisible, NotificationType::dontSendNotification);
    }

    else if(btn == &addPresetBtn)
    {
#if JUCE_MODAL_LOOPS_PERMITTED

        AlertWindow w("save preset", "please enter a name for this preset", AlertWindow::NoIcon);

        w.setColour(AlertWindow::textColourId, Colours::black);
        w.setColour(AlertWindow::outlineColourId, Colours::black);

        w.addTextEditor("text", "preset name", "preset name:");

        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 text they entered..
            String newPresetName(w.getTextEditorContents("text"));

            parent->createNewPreset(newPresetName);
        }

        // update the preset list to show new additions
        presetPanel.refreshPresetLists();
#endif
    }

    else if(btn == &resampleBtn)
    {
        parent->startResampling();
    }

    else if(btn == &recordBtn)
    {
        parent->startRecording();
    }

    else if(btn == &patternBtn)
    {
        parent->startPatternRecording();
    }

    // load files manually using file dialog
    else if(btn == &loadFilesBtn)
    {
        FileChooser myChooser ("Please choose a file:",
            File::getSpecialLocation(File::userDesktopDirectory),
            parent->getWildcardFormats());

        // ask user to load at least one file
        if(myChooser.browseForMultipleFilesToOpen())
        {
            // if sucessful, try to add these to the sample pool
            Array<File> newFiles = myChooser.getResults();
            for (int i = 0; i < newFiles.size(); ++i)
            {
                File currentFile = newFiles[i];
                parent->addNewSample(currentFile);
            }
        }
    }

    else if (btn == &sampleStripToggle)
    {
        if (displayMode == modeSampleStrips)
        {
            sampleStripToggle.setImages(&patternImg);
            displayMode = modePatternStrips;

            for(int i = 0; i < patternStripArray.size(); ++i)
                patternStripArray[i]->setVisible(true);
            for(int i = 0; i < sampleStripControlArray.size(); ++i)
                sampleStripControlArray[i]->setVisible(false);
        }
        else if (displayMode == modePatternStrips)
        {
            sampleStripToggle.setImages(&sampleImg);
            displayMode = modeSampleStrips;

            for(int i = 0; i < patternStripArray.size(); ++i)
                patternStripArray[i]->setVisible(false);
            for(int i = 0; i < sampleStripControlArray.size(); ++i)
                sampleStripControlArray[i]->setVisible(true);
        }
    }

    else if (btn == &debugButton)
    {
        parent->createNewPreset("test");
        DBG("Hai");
    }

    else
    {
        for (int s = 0; s < slidersMuteBtnArray.size(); ++s)
        {
            if (btn == slidersMuteBtnArray[s])
                parent->setChannelMute(s, btn->getToggleState());
        }
    }
}
Ejemplo n.º 7
0
    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
        }
    }