bool MainContentComponent::perform (const InvocationInfo& info) { switch (info.commandID) { case Ananke::menuFileOption: break; case Ananke::menuExitOption: break; case Ananke::menuSettingsOption: { auto selector = appController->getSelector (); DialogWindow::LaunchOptions o; o.content.setNonOwned (selector.get ()); o.dialogTitle = "Audio Settings"; o.componentToCentreAround = this; o.dialogBackgroundColour = Colours::azure; o.escapeKeyTriggersCloseButton = true; o.useNativeTitleBar = false; o.resizable = false; o.runModal (); return true; } case Ananke::menuHelpOption: break; } return false; }
void MainHostWindow::showAudioSettings() { AudioDeviceSelectorComponent audioSettingsComp (deviceManager, 0, 256, 0, 256, true, true, true, false); audioSettingsComp.setSize (500, 450); DialogWindow::LaunchOptions o; o.content.setNonOwned (&audioSettingsComp); o.dialogTitle = "Audio Settings"; o.componentToCentreAround = this; o.dialogBackgroundColour = Colours::azure; o.escapeKeyTriggersCloseButton = true; o.useNativeTitleBar = false; o.resizable = false; o.runModal(); ScopedPointer<XmlElement> audioState (deviceManager.createStateXml()); appProperties->getUserSettings()->setValue ("audioDeviceState", audioState); appProperties->getUserSettings()->saveIfNeeded(); GraphDocumentComponent* const graphEditor = getGraphEditor(); if (graphEditor != nullptr) graphEditor->graph.removeIllegalConnections(); }
/// Static helper function to create a dialog window for validation /// settings. /// /// @param pluginEditor audio plug-in editor /// /// @param audioProcessor audio processor /// /// @return created dialog window /// DialogWindow *WindowValidationContent::createDialogWindow( AudioProcessorEditor *pluginEditor, KmeterAudioProcessor *audioProcessor) { // prepare dialog window DialogWindow::LaunchOptions windowValidationLauncher; // create content component WindowValidationContent *contentComponent = new WindowValidationContent(audioProcessor); // initialise dialog window settings windowValidationLauncher.dialogTitle = String("Validation"); windowValidationLauncher.dialogBackgroundColour = Colours::white; windowValidationLauncher.content.setOwned(contentComponent); windowValidationLauncher.componentToCentreAround = pluginEditor; windowValidationLauncher.escapeKeyTriggersCloseButton = true; windowValidationLauncher.useNativeTitleBar = false; windowValidationLauncher.resizable = false; windowValidationLauncher.useBottomRightCornerResizer = false; // launch dialog window DialogWindow *windowValidation = windowValidationLauncher.launchAsync(); windowValidation->setAlwaysOnTop(true); return windowValidation; }
void ProjucerApplication::showLoginForm() { if (ProjucerLicences::getInstance()->isDLLPresent()) { jassert (MessageManager::getInstance()->isThisTheMessageThread()); if (loginForm != nullptr) return; DialogWindow::LaunchOptions lo; lo.dialogTitle = "Log-in to Projucer"; lo.dialogBackgroundColour = Colour (0xffdddddd); lo.content.setOwned (loginForm = new LoginForm()); lo.escapeKeyTriggersCloseButton = true; lo.componentToCentreAround = nullptr; lo.escapeKeyTriggersCloseButton = true; lo.resizable = false; lo.useBottomRightCornerResizer = false; lo.useNativeTitleBar = true; lo.launchAsync(); getGlobalProperties().setValue ("lastLoginAttemptTime", (int) (Time::getCurrentTime().toMilliseconds() / 1000)); } }
void GuiApp::newSession() { if (sessionDoc->hasChangedSinceSaved()) { sessionDoc->save (true, true); // content->stabilize(); } DialogWindow::LaunchOptions opts; opts.dialogBackgroundColour = Colours::darkgrey; opts.content.set (new NewSessionView (globals().session()), true); opts.dialogTitle = "New Session"; opts.resizable = false; opts.useBottomRightCornerResizer = false; opts.useNativeTitleBar = true; opts.componentToCentreAround = (Component*) mainWindow.get(); if (DialogWindow* dw = opts.create()) { windowManager->push (dw); sessionDoc->setFile (File::nonexistent); globals().session().clear(); globals().session().open(); // content->stabilize(); sessionDoc->setChangedFlag (false); } }
//============================================================================== void TestComponent::showInDialogBox (JucerDocument& document) { DialogWindow::LaunchOptions o; o.content.setOwned (new TestComponent (nullptr, document.createCopy(), true)); o.dialogTitle = "Testing: " + document.getClassName(); o.dialogBackgroundColour = Colours::azure; o.escapeKeyTriggersCloseButton = true; o.useNativeTitleBar = false; o.resizable = true; o.launchAsync(); }
void JuceUpdater::show (ModuleList& moduleList, Component* mainWindow, const String& message) { DialogWindow::LaunchOptions o; o.content.setOwned (new JuceUpdater (moduleList, message)); o.dialogTitle = "JUCE Module Updater"; o.dialogBackgroundColour = Colours::lightgrey; o.componentToCentreAround = mainWindow; o.escapeKeyTriggersCloseButton = true; o.useNativeTitleBar = true; o.resizable = true; o.runModal(); }
//============================================================================== void PreferencesPanel::showInDialogBox (const String& dialogTitle, int dialogWidth, int dialogHeight, Colour backgroundColour) { setSize (dialogWidth, dialogHeight); DialogWindow::LaunchOptions o; o.content.setNonOwned (this); o.dialogTitle = dialogTitle; o.dialogBackgroundColour = backgroundColour; o.escapeKeyTriggersCloseButton = false; o.useNativeTitleBar = false; o.resizable = false; o.launchAsync(); }
void CtrlrPanelResourceEditor::showResourceInfo(const int resourceIndex) { CtrlrPanelResource *res = resources[resourceIndex]; if (res == nullptr) return; String message; message << "Load time: " + res->getLoadedTime().toString(true, true, true, true) + "\n"; message << "Data file: " + res->getFile().getFullPathName() + "\n"; message << "Source file: " + res->getSourceFile().getFullPathName() + "\n"; message << "Source hash: " + STR(res->getHashCode()) + "\n"; AudioFormatReader *afr = res->asAudioFormat(); if (afr) { message << "Type: Audio\n"; message << "Format name: " << afr->getFormatName() << "\n"; message << "Sample rate: " << afr->sampleRate << "\n"; message << "Bits per sample: " << ((int)afr->bitsPerSample) << "\n"; message << "Length in samples: " << afr->lengthInSamples << "\n"; message << "Number of channels: " << ((int)afr->numChannels) << "\n"; message << "Metadata:\n"; message << "\t" << afr->metadataValues.getDescription(); } if (!res->asImage().isNull()) { Image i = res->asImage(); message << "Type: Image\n"; message << "Width: " + STR(i.getWidth()) + "\n"; message << "Height: " + STR(i.getHeight()) + "\n"; message << "Has alpha: " + STR(i.hasAlphaChannel()) + "\n"; } DialogWindow::LaunchOptions lo; Label *l = new Label ("", message); l->setSize (400, 150); l->setJustificationType (Justification::centred); l->setFont (Font(12.0f)); lo.content.set(l, true); lo.componentToCentreAround = this; lo.dialogBackgroundColour = Colours::whitesmoke; lo.dialogTitle = "Resource information"; lo.resizable = true; lo.useBottomRightCornerResizer = false; lo.useNativeTitleBar = true; lo.launchAsync(); }
bool CodeWindow::perform (const InvocationInfo& info) { Logger::writeToLog(String(info.commandID)); //--------------------------------------------------------------------------------------------- if(info.commandID==CommandIDs::fileNew) { String tempFile = File::getSpecialLocation(File::userHomeDirectory).getFullPathName()+"/liveCodeSession.csd"; Logger::writeToLog(tempFile); csdFile = tempFile; csoundDoc.replaceAllContent(csdFile.loadFileAsString()); toggleTextWindows(); } else if(info.commandID==CommandIDs::fileSave) { Logger::writeToLog("fileSaved"); sendActionMessage("fileSaved"); } else if(info.commandID==CommandIDs::fileSaveAs) { Logger::writeToLog("fileSaveAs"); sendActionMessage("fileSaveAs"); } else if(info.commandID==CommandIDs::fileOpen) { Logger::writeToLog("fileOpen"); sendActionMessage("fileOpen"); } else if(info.commandID==CommandIDs::AudioSettings) { sendActionMessage("audioSettings"); } else if(info.commandID==CommandIDs::fileQuit) { JUCEApplication::getInstance()->systemRequestedQuit(); } else if(info.commandID==CommandIDs::editUndo) { textEditor->undo(); } else if(info.commandID==CommandIDs::fileKeyboardShorts) { DialogWindow::LaunchOptions o; o.content.setOwned(new ShortcutsPanel()); o.dialogTitle = TRANS("Keyboard Shortcuts"); o.dialogBackgroundColour = Colours::black; o.resizable = false; o.useNativeTitleBar = false; o.escapeKeyTriggersCloseButton = true; //o.content->setLookAndFeel(&this->getLookAndFeel()); o.launchAsync(); } else if(info.commandID==CommandIDs::editCut) { textEditor->cutToClipboard(); } else if(info.commandID==CommandIDs::editCopy) { textEditor->copyToClipboard(); } else if(info.commandID==CommandIDs::editPaste) { textEditor->pasteFromClipboard(); } else if(info.commandID==CommandIDs::editRedo) { textEditor->redo(); } else if(info.commandID==CommandIDs::editToggleText) { toggleTextWindows(); } else if(info.commandID==CommandIDs::editZoomIn) { setFontSize("in"); } else if(info.commandID==CommandIDs::editZoomOut) { setFontSize("out"); } else if(info.commandID==CommandIDs::whiteBackground) { setEditorColourScheme("white"); } else if(info.commandID==CommandIDs::blackBackground) { setEditorColourScheme("dark"); } else if(info.commandID==CommandIDs::insertRecentEvent) { } else if(info.commandID==CommandIDs::insertFromRepo) { popupDisplay->setVisible(false); CodeWindow::insertFromRepo(); } else if(info.commandID==CommandIDs::openPythonEditor) { /*if(pythonEditor==nullptr){ pythonEditor = new PythonEditor("Python Editor"); //pythonEditor->textEditor->setLookAndFeel(lookAndFeel); //pythonEditor->setLookAndFeel(lookAndFeel); pythonEditor->addActionListener(this); pythonEditor->setAlwaysOnTop(true); pythonEditor->setVisible(true); pythonEditor->textEditor->setColour(CodeEditorComponent::backgroundColourId, Colour::fromRGB(40, 40, 40)); } pythonEditor->toFront(true); cabbageTimer->startTimedEvent(1, "pythonFocus"); //pythonEditor->textEditor->highlightLine("oscil 1"); */ } else if(info.commandID==CommandIDs::addFromRepo) { textEditor->addToRepository(); } else if(info.commandID==CommandIDs::viewCsoundHelp) { toggleManuals("Csound"); } else if(info.commandID==CommandIDs::viewCabbageHelp) { toggleManuals("Cabbage"); } return true; }
void SoundboardAudioProcessorEditor::buttonClicked(Button *buttonThatWasClicked) { if (loadDirectoryButton == buttonThatWasClicked) { FileChooser chooser("Open..."); if (chooser.browseForDirectory()) { auto directory = chooser.getResult(); if (directory.isDirectory()) { processor.openDirectory(directory); table->updateContent(); grid->updateContent(); } } } else if (settingsButton == buttonThatWasClicked) { DialogWindow::LaunchOptions launchOptions; launchOptions.componentToCentreAround = this; launchOptions.content.setOwned(new SoundboardSettingsComponent(processor)); launchOptions.content->setSize(640, 480); launchOptions.dialogBackgroundColour = Colours::black; launchOptions.dialogTitle = TRANS("Soundboard Settings"); launchOptions.escapeKeyTriggersCloseButton = true; launchOptions.resizable = true; launchOptions.useNativeTitleBar = true; launchOptions.runModal(); } else if (gridButton == buttonThatWasClicked) { gridButton->setEnabled(false); listButton->setEnabled(true); table->setVisible(false); grid->setVisible(true); grid->toFront(true); if (resizableCornerComponent) { resizableCornerComponent->toFront(false); } } else if (listButton == buttonThatWasClicked) { listButton->setEnabled(false); gridButton->setEnabled(true); grid->setVisible(false); table->setVisible(true); table->toFront(true); if (resizableCornerComponent) { resizableCornerComponent->toFront(false); } } else if (duckButton == buttonThatWasClicked) { bool ducking = processor.getOscManager()->getOscParameterValue("/ultraschall/soundboard/duck/enabled"); processor.getOscManager()->setOscParameterValue("/ultraschall/soundboard/duck/enabled", !ducking); if (!ducking) { duckButton->setButtonText(FontAwesome_Comment); } else { duckButton->setButtonText(FontAwesome_Comment_O); } } else if (lockButton == buttonThatWasClicked) { processor.toggleLocked(); if (processor.getLocked()) { lockButton->setButtonText(FontAwesome_Lock); } else { lockButton->setButtonText(FontAwesome_Unlock); } } }
void MainContentComponent::buttonClicked(Button* button) { if (button == &_rescanButton) { // Re-enumerate MIDI IN and OUT devices MIDIProcessor::getInstance().rescanDevices(); MIDISender::getInstance().rescanDevices(); } else if (button == &_removeRowButton) { if (_commandTable.getSelectedRow() != -1) { _commandTableModel.removeRow(_commandTable.getSelectedRow()); _commandTable.updateContent(); } } else if (button == &_saveButton) { bool profileDirSet = SettingsManager::getInstance().getProfileDirectory().isNotEmpty(); FileBrowserComponent browser(FileBrowserComponent::canSelectFiles | FileBrowserComponent::saveMode | FileBrowserComponent::warnAboutOverwriting, profileDirSet ? SettingsManager::getInstance().getProfileDirectory() : File::getCurrentWorkingDirectory(), nullptr, nullptr); FileChooserDialogBox dialogBox("Save profile", "Enter filename to save profile", browser, true, Colours::lightgrey); if (dialogBox.show()) { File selectedFile = browser.getSelectedFile(0).withFileExtension("xml"); CommandMap::getInstance().toXMLDocument(selectedFile); } } else if (button == &_loadButton) { bool profileDirSet = SettingsManager::getInstance().getProfileDirectory().isNotEmpty(); WildcardFileFilter wildcardFilter("*.xml", String::empty, "MIDI2LR profiles"); FileBrowserComponent browser(FileBrowserComponent::canSelectFiles | FileBrowserComponent::openMode, profileDirSet ? SettingsManager::getInstance().getProfileDirectory() : File::getCurrentWorkingDirectory(), &wildcardFilter, nullptr); FileChooserDialogBox dialogBox("Open profile", "Select a profile to open", browser, true, Colours::lightgrey); if (dialogBox.show()) { ScopedPointer<XmlElement> elem = XmlDocument::parse(browser.getSelectedFile(0)); if (elem) { _profileNameLabel.setText(browser.getSelectedFile(0).getFileName(), NotificationType::dontSendNotification); _commandTableModel.buildFromXml(elem); _commandTable.updateContent(); _commandTable.repaint(); } } } else if (button == &_settingsButton) { DialogWindow::LaunchOptions dwOpt; dwOpt.dialogTitle = "Settings"; dwOpt.content.setOwned(new SettingsComponent()); dwOpt.content->setSize(300, 200); dwOpt.escapeKeyTriggersCloseButton = true; dwOpt.useNativeTitleBar = false; _settingsDialog = dwOpt.create(); _settingsDialog->setVisible(true); } }
void MainContentComponent::buttonClicked (Button* buttonThatWasClicked) { //[UserbuttonClicked_Pre] //[/UserbuttonClicked_Pre] if (buttonThatWasClicked == convButton) { //[UserButtonCode_convButton] -- add your button handler code here.. const ScopedLock fl(soundListLock); setPlayheadUiEnabled(false); bool convValid = true; float q; float s; double nfft; { const ScopedLock pl(paramLock); q = qParam; s = sParam; nfft = static_cast<double>(nfftParam); } int fftInputLen = static_cast<int>(std::pow(2.0, nfft)); int fftOutputLen = fftInputLen / 2 + 1; int numChannels = 1; unordered_set<int> includedSounds; int maxChannels = 0; float pSum = 0.0f; float rSum = 0.0f; for (const auto& iter : idToSound) { int id = iter.first; Sound* sound = iter.second.get(); int numChannels = sound->getBufferNumChannels(); if (sound->isIncluded() && numChannels > 0) { maxChannels = numChannels > maxChannels ? numChannels : maxChannels; includedSounds.emplace(id); pSum += static_cast<float>(sound->getPValue()); rSum += static_cast<float>(sound->getRValue()); } } float n = static_cast<float>(includedSounds.size()); float pScale = n * q / pSum; float rScale = n * s / rSum; if (maxChannels == 0) { return; } kiss_fftr_state* fftInverseState = kiss_fftr_alloc(fftInputLen, 1, nullptr, nullptr); kiss_fft_cpx* CONV = static_cast<kiss_fft_cpx*>(calloc(fftOutputLen * maxChannels, sizeof(kiss_fft_cpx))); conv.setSize(maxChannels, fftInputLen); float max = -1.0f; // convolve for (int convChannel = 0; convChannel < maxChannels; ++convChannel) { kiss_fft_cpx* CONVCHANNEL = CONV + (convChannel * fftOutputLen); bool isFirstSound = true; for (const auto& id : includedSounds) { Sound* sound = idToSound[id].get(); jassert(sound != nullptr); float p = pScale * static_cast<float>(sound->getPValue()); float r = rScale * static_cast<float>(sound->getRValue()); int soundNumChannels = sound->getBufferNumChannels(); int soundNumSamples = sound->getBufferNumSamples(); int soundChannel = convChannel >= soundNumChannels ? soundNumChannels - 1 : convChannel; const kiss_fft_cpx* SOUNDCHANNEL = sound->getSpectra(fftInputLen, soundChannel); for (int i = 0; i < fftOutputLen; ++i) { float xr = SOUNDCHANNEL[i].r; float xi = SOUNDCHANNEL[i].i; float xMag = sqrtf((xr * xr) + (xi * xi)); float xPhs = atan2f(xi, xr); float convMag = powf(xMag, p); float convPhs = r * xPhs; float convr = convMag * cosf(convPhs); float convi = convMag * sinf(convPhs); if (std::isnan(convr) || std::isnan(convi)) { convValid = false; } if (isFirstSound) { CONVCHANNEL[i].r = convr; CONVCHANNEL[i].i = convi; } else { float a = CONVCHANNEL[i].r; float b = CONVCHANNEL[i].i; float c = convr; float d = convi; CONVCHANNEL[i].r = a * c - b * d; CONVCHANNEL[i].i = a * d + b * c; } } isFirstSound = false; } // ifft kiss_fftri(fftInverseState, CONVCHANNEL, conv.getWritePointer(convChannel)); // check max float channelMax = conv.findMinMax(convChannel, 0, fftInputLen).getEnd(); max = channelMax > max ? channelMax : max; } delete fftInverseState; delete CONV; // normalize conv.applyGain(1.0f / max); if (!convValid) { AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "Error", "Parameters produced NaN value."); return; } setPlayheadAudio(&conv); //[/UserButtonCode_convButton] } else if (buttonThatWasClicked == settingsButton) { //[UserButtonCode_settingsButton] -- add your button handler code here.. AudioDeviceSelectorComponent audioSettingsComp(deviceManager, 0, 256, 0, 256, true, true, true, false); audioSettingsComp.setSize(500, 450); DialogWindow::LaunchOptions o; o.content.setNonOwned(&audioSettingsComp); o.dialogTitle = "Audio Settings"; o.componentToCentreAround = this; o.dialogBackgroundColour = Colours::azure; o.escapeKeyTriggersCloseButton = true; o.useNativeTitleBar = false; o.resizable = false; o.runModal(); ScopedPointer<XmlElement> audioState(deviceManager.createStateXml()); getAppProperties().getUserSettings()->setValue("audioDeviceState", audioState); getAppProperties().getUserSettings()->saveIfNeeded(); //[/UserButtonCode_settingsButton] } else if (buttonThatWasClicked == playButton) { //[UserButtonCode_playButton] -- add your button handler code here.. const ScopedLock pal(playheadAudioLock); playheadState = PlayheadState::playing; playheadAudioSamplesCompleted = 0; //[/UserButtonCode_playButton] } else if (buttonThatWasClicked == loopButton) { //[UserButtonCode_loopButton] -- add your button handler code here.. const ScopedLock pal(playheadAudioLock); playheadState = PlayheadState::looping; //[/UserButtonCode_loopButton] } else if (buttonThatWasClicked == stopButton) { //[UserButtonCode_stopButton] -- add your button handler code here.. const ScopedLock pal(playheadAudioLock); playheadState = PlayheadState::stopped; playheadAudioSamplesCompleted = 0; //[/UserButtonCode_stopButton] } else if (buttonThatWasClicked == qDefaultButton) { //[UserButtonCode_qDefaultButton] -- add your button handler code here.. qSlider->setValue(1.0); //[/UserButtonCode_qDefaultButton] } else if (buttonThatWasClicked == sDefaultButton) { //[UserButtonCode_sDefaultButton] -- add your button handler code here.. sSlider->setValue(1.0); //[/UserButtonCode_sDefaultButton] } else if (buttonThatWasClicked == saveButton) { //[UserButtonCode_saveButton] -- add your button handler code here.. const ScopedLock pal(playheadAudioLock); if (playheadAudio.getNumChannels() > 0 && playheadAudio.getNumSamples() > 0) { FileChooser fileChooser("Save as...", File::nonexistent, "*.wav", true); if (fileChooser.browseForFileToSave(true)) { File outputFile = fileChooser.getResult(); outputFile.deleteFile(); WavAudioFormat wavFormat; ScopedPointer<FileOutputStream> outputFileStream = outputFile.createOutputStream(); ScopedPointer<AudioFormatWriter> writer = wavFormat.createWriterFor(outputFileStream, 44100.0, playheadAudio.getNumChannels(), 16, StringPairArray(), 0); writer->writeFromAudioSampleBuffer(playheadAudio, 0, playheadAudio.getNumSamples()); outputFileStream.release(); } } //[/UserButtonCode_saveButton] } else if (buttonThatWasClicked == inputRemoveButton) { //[UserButtonCode_inputRemoveButton] -- add your button handler code here.. const ScopedLock fl(soundListLock); SparseSet<int> selectedRows = inputFileListComponent->getSelectedRows(); for (int i = 0; i < selectedRows.size(); ++i) { int row = selectedRows[i]; int id = inputFileListComponent->getIdForRow(row); const auto& iter = idToSound.find(id); jassert(iter != idToSound.end()); idToSound.erase(iter); } if (selectedRows.size() > 0) { inputFilesChanged(dontSendNotification); } //[/UserButtonCode_inputRemoveButton] } else if (buttonThatWasClicked == inputAddButton) { //[UserButtonCode_inputAddButton] -- add your button handler code here.. const ScopedLock fl(soundListLock); FileChooser fileChooser("Add sound...", File::nonexistent, "*.wav;*.aif;*.aiff;*.ogg", true); if (fileChooser.browseForMultipleFilesToOpen()) { Array<File> files = fileChooser.getResults(); StringArray filePaths; for (int i = 0; i < files.size(); ++i) { filePaths.add(files[i].getFullPathName()); } filesDropped(filePaths, -1, -1); } //[/UserButtonCode_inputAddButton] } //[UserbuttonClicked_Post] //[/UserbuttonClicked_Post] }
void MainContentComponent::buttonClicked(Button* button) { if (button == &_rescanButton) { // Re-enumerate MIDI IN and OUT devices if (m_midiProcessor) { m_midiProcessor->rescanDevices(); } if (m_midiSender) { m_midiSender->rescanDevices(); } // Send new CC parameters to MIDI Out devices if (m_lr_IPC_IN) { m_lr_IPC_IN->refreshMIDIOutput(); } } else if (button == &_removeRowButton) { if (_commandTable.getSelectedRow() != -1) { _commandTableModel.removeRow(_commandTable.getSelectedRow()); _commandTable.updateContent(); } } else if (button == &_saveButton) { File profileDir; if (m_settingsManager) { profileDir = m_settingsManager->getProfileDirectory(); } if (!profileDir.exists()) { profileDir = File::getCurrentWorkingDirectory(); } WildcardFileFilter wildcardFilter("*.xml", String::empty, "MIDI2LR profiles"); FileBrowserComponent browser(FileBrowserComponent::canSelectFiles | FileBrowserComponent::saveMode | FileBrowserComponent::warnAboutOverwriting, profileDir, &wildcardFilter, nullptr); FileChooserDialogBox dialogBox("Save profile", "Enter filename to save profile", browser, true, Colours::lightgrey); if (dialogBox.show()) { File selectedFile = browser.getSelectedFile(0).withFileExtension("xml"); if (m_commandMap) { m_commandMap->toXMLDocument(selectedFile); } } } else if (button == &_loadButton) { File profileDir; if (m_settingsManager) { profileDir = m_settingsManager->getProfileDirectory(); } if (!profileDir.exists()) { profileDir = File::getCurrentWorkingDirectory(); } WildcardFileFilter wildcardFilter("*.xml", String::empty, "MIDI2LR profiles"); FileBrowserComponent browser(FileBrowserComponent::canSelectFiles | FileBrowserComponent::openMode, profileDir, &wildcardFilter, nullptr); FileChooserDialogBox dialogBox("Open profile", "Select a profile to open", browser, true, Colours::lightgrey); if (dialogBox.show()) { ScopedPointer<XmlElement> elem = XmlDocument::parse(browser.getSelectedFile(0)); if (elem) { File newprofile = browser.getSelectedFile(0); String command = String("ChangedToFullPath ") + newprofile.getFullPathName() + "\n"; if (m_lr_IPC_OUT) { m_lr_IPC_OUT->sendCommand(command); } _profileNameLabel.setText(newprofile.getFileName(), NotificationType::dontSendNotification); _commandTableModel.buildFromXml(elem); _commandTable.updateContent(); _commandTable.repaint(); } } } else if (button == &_settingsButton) { DialogWindow::LaunchOptions dwOpt; dwOpt.dialogTitle = "Settings"; //create new object SettingsComponent *comp = new SettingsComponent(); comp->Init(m_settingsManager); dwOpt.content.setOwned(comp); dwOpt.content->setSize(400, 300); dwOpt.escapeKeyTriggersCloseButton = true; dwOpt.useNativeTitleBar = false; _settingsDialog = dwOpt.create(); _settingsDialog->setVisible(true); } }
void ContentComponent::buttonClicked (Button* buttonThatWasClicked) { //[UserbuttonClicked_Pre] //[/UserbuttonClicked_Pre] if (buttonThatWasClicked == openButton) { //[UserButtonCode_openButton] -- add your button handler code here.. bool movieLoaded = false; bool cancelled = false; FileChooser chooser ("Choose a Movie File", File(), "*.mp4"); if (chooser.browseForFileToOpen()) { movieLoaded = tick->openFile (chooser.getResult()); } else { cancelled = true; } if (cancelled) return; if (! movieLoaded) { AlertWindow::showMessageBox (AlertWindow::WarningIcon, "Error", "Could not open movie file"); } else { } //[/UserButtonCode_openButton] } else if (buttonThatWasClicked == forwardButton) { //[UserButtonCode_forwardButton] -- add your button handler code here.. //[/UserButtonCode_forwardButton] } else if (buttonThatWasClicked == backButton) { //[UserButtonCode_backButton] -- add your button handler code here.. //[/UserButtonCode_backButton] } else if (buttonThatWasClicked == playButton) { //[UserButtonCode_playButton] -- add your button handler code here.. tick->setPlaying (! tick->isPlaying()); stabilizeComponents(); //[/UserButtonCode_playButton] } else if (buttonThatWasClicked == stopButton) { //[UserButtonCode_stopButton] -- add your button handler code here.. tick->setPlaying (false); tick->requestPlayPosition (0.0); stabilizeComponents(); //[/UserButtonCode_stopButton] } else if (buttonThatWasClicked == audioButton) { //[UserButtonCode_audioButton] -- add your button handler code here.. DialogWindow::LaunchOptions dialog; dialog.content.setOwned (new AudioDeviceSelectorComponent ( devices, 0, 0, 2, 2, false, false, true,false)); dialog.dialogTitle = "Audio Device"; dialog.componentToCentreAround = this; dialog.content->setSize (384, 444); dialog.resizable = false; dialog.runModal(); //[/UserButtonCode_audioButton] } //[UserbuttonClicked_Post] //[/UserbuttonClicked_Post] }