diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 89bea5a..581ccd3 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -21,6 +21,19 @@ www.gnu.org/licenses #include #include "RenderSettingsComponent.h" +class MyPopmenuCallback : public ModalComponentManager::Callback +{ +public: + MyPopmenuCallback(PaulstretchpluginAudioProcessorEditor* owner) : m_owner(owner) {} + void modalStateFinished(int returnValue) override + { + jassert(m_owner != nullptr); + m_owner->executeModalMenuAction(0, returnValue); + } + PaulstretchpluginAudioProcessorEditor* m_owner = nullptr; +}; + + //============================================================================== PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(PaulstretchpluginAudioProcessor& p) : AudioProcessorEditor(&p), @@ -260,6 +273,54 @@ void PaulstretchpluginAudioProcessorEditor::showRenderDialog() /*CallOutBox& myBox =*/ CallOutBox::launchAsynchronously(content, m_render_button.getBounds(), this); } +void PaulstretchpluginAudioProcessorEditor::executeModalMenuAction(int menuid, int r) +{ + if (r >= 200 && r < 210) + { + int caplen = m_capturelens[r - 200]; + *processor.getFloatParameter(cpi_max_capture_len) = (float)caplen; + } + if (r == 1) + { + toggleBool(processor.m_play_when_host_plays); + } + if (r == 2) + { + toggleBool(processor.m_capture_when_host_plays); + } + if (r == 8) + { + toggleBool(processor.m_mute_while_capturing); + } + if (r == 4) + { + processor.resetParameters(); + } + if (r == 5) + { + toggleBool(processor.m_load_file_with_state); + } + if (r == 3) + { + showAbout(); + } + + if (r == 6) + { + ValueTree tree = processor.getStateTree(true, true); + MemoryBlock destData; + MemoryOutputStream stream(destData, true); + tree.writeToStream(stream); + String txt = Base64::toBase64(destData.getData(), destData.getSize()); + SystemClipboard::copyTextToClipboard(txt); + } + if (r == 7) + { + toggleBool(processor.m_show_technical_info); + processor.m_propsfile->m_props_file->setValue("showtechnicalinfo", processor.m_show_technical_info); + } +} + void PaulstretchpluginAudioProcessorEditor::paint (Graphics& g) { g.fillAll(Colours::darkgrey); @@ -501,70 +562,28 @@ void PaulstretchpluginAudioProcessorEditor::chooseFile() void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() { - PopupMenu menu; - menu.addItem(4, "Reset parameters", true, false); - menu.addItem(5, "Load file with plugin state", true, processor.m_load_file_with_state); - menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays); - menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays); - menu.addItem(8, "Mute audio while capturing", true, processor.m_mute_while_capturing); + m_test_menu = PopupMenu(); + m_test_menu.addItem(4, "Reset parameters", true, false); + m_test_menu.addItem(5, "Load file with plugin state", true, processor.m_load_file_with_state); + m_test_menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays); + m_test_menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays); + m_test_menu.addItem(8, "Mute audio while capturing", true, processor.m_mute_while_capturing); int capturelen = *processor.getFloatParameter(cpi_max_capture_len); PopupMenu capturelenmenu; - std::vector capturelens{ 2,5,10,30,60,120 }; - for (int i=0;i= 200 && r < 210) - { - int caplen = capturelens[r - 200]; - *processor.getFloatParameter(cpi_max_capture_len) = (float)caplen; - } - if (r == 1) - { - toggleBool(processor.m_play_when_host_plays); - } - if (r == 2) - { - toggleBool(processor.m_capture_when_host_plays); - } - if (r == 8) - { - toggleBool(processor.m_mute_while_capturing); - } - if (r == 4) - { - processor.resetParameters(); - } - if (r == 5) - { - toggleBool(processor.m_load_file_with_state); - } - if (r == 3) - { - showAbout(); - } - - if (r == 6) - { - ValueTree tree = processor.getStateTree(true,true); - MemoryBlock destData; - MemoryOutputStream stream(destData, true); - tree.writeToStream(stream); - String txt = Base64::toBase64(destData.getData(), destData.getSize()); - SystemClipboard::copyTextToClipboard(txt); - } - if (r == 7) - { - toggleBool(processor.m_show_technical_info); - processor.m_propsfile->m_props_file->setValue("showtechnicalinfo", processor.m_show_technical_info); - } + m_test_menu.addItem(7, "Show technical info", true, processor.m_show_technical_info); + //int r = menu.show(); + + m_test_menu.showMenuAsync(PopupMenu::Options(), new MyPopmenuCallback(this)); } void PaulstretchpluginAudioProcessorEditor::showAbout() diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 52d3eb4..3c1ee9a 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -310,7 +310,6 @@ public: void resized() override; void timerCallback(int id) override; - bool isInterestedInFileDrag(const StringArray &files) override; void filesDropped(const StringArray &files, int x, int y) override; @@ -319,8 +318,10 @@ public: WaveformComponent m_wavecomponent; void chooseFile(); void showRenderDialog(); + void executeModalMenuAction(int menuid, int actionid); private: - PaulstretchpluginAudioProcessor& processor; + PopupMenu m_test_menu; + PaulstretchpluginAudioProcessor& processor; uptrvec m_parcomps; //SpectralVisualizer m_specvis; PerfMeterComponent m_perfmeter; @@ -339,6 +340,7 @@ private: MyTabComponent m_wavefilter_tab; Component* m_wave_container=nullptr; void showAbout(); + std::vector m_capturelens{ 2,5,10,30,60,120 }; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor) };