gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit 4b25b632fe3aa23f926756999775fc922127c2ef
parent 5a3782b6af77a2bdd25073aa79ce31cb7f3bce76
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Thu,  6 Mar 2025 23:25:00 +0100

add right click menu to graphs to save wave that is being edited

Diffstat:
Msource/xtJucePlugin/weGraph.cpp | 3+++
Msource/xtJucePlugin/xtWaveEditor.cpp | 73++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Msource/xtJucePlugin/xtWaveEditor.h | 6+++++-
3 files changed, 52 insertions(+), 30 deletions(-)

diff --git a/source/xtJucePlugin/weGraph.cpp b/source/xtJucePlugin/weGraph.cpp @@ -89,7 +89,10 @@ namespace xtJucePlugin Component::mouseDown(_e); if (_e.mods.isPopupMenu()) + { + m_editor.openGraphPopupMenu(*this, _e); return; + } setLastMouseEvent(_e); const auto i = mouseToIndex(_e); diff --git a/source/xtJucePlugin/xtWaveEditor.cpp b/source/xtJucePlugin/xtWaveEditor.cpp @@ -117,35 +117,6 @@ namespace xtJucePlugin { } - void WaveEditor::saveWave() - { - if(xt::wave::isReadOnly(m_selectedWave)) - { - // open menu and let user select one of the wave slots - juce::PopupMenu menu; - - uint16_t count = 0; - for(uint16_t i=xt::wave::g_firstRamWaveIndex; i<xt::wave::g_firstRamWaveIndex+xt::wave::g_ramWaveCount; ++i) - { - const auto id = xt::WaveId(i); - menu.addItem(WaveTreeItem::getWaveName(id), true, false, [this, id] - { - saveWaveTo(id); - }); - - ++count; - if((count % 25) == 0) - menu.addColumnBreak(); - } - - menu.showMenuAsync({}); - } - else - { - saveWaveTo(m_selectedWave); - } - } - bool WaveEditor::saveWaveTo(const xt::WaveId _target) { if(xt::wave::isReadOnly(_target)) @@ -166,6 +137,27 @@ namespace xtJucePlugin { } + juce::PopupMenu WaveEditor::createRamWavesPopupMenu(const std::function<void(xt::WaveId)>& _callback) + { + juce::PopupMenu subMenu; + + uint16_t count = 0; + for (uint16_t i = xt::wave::g_firstRamWaveIndex; i < xt::wave::g_firstRamWaveIndex + xt::wave::g_ramWaveCount; ++i) + { + const auto id = xt::WaveId(i); + subMenu.addItem(WaveTreeItem::getWaveName(id), true, false, [id, _callback] + { + _callback(id); + }); + + ++count; + if ((count % 25) == 0) + subMenu.addColumnBreak(); + } + + return subMenu; + } + void WaveEditor::onReceiveWave(const pluginLib::MidiPacket::Data& _data, const std::vector<uint8_t>& _msg) { m_data.onReceiveWave(_msg); @@ -306,4 +298,27 @@ namespace xtJucePlugin }); } } + + void WaveEditor::openGraphPopupMenu(const Graph&, const juce::MouseEvent&) + { + juce::PopupMenu menu; + + if (!xt::wave::isReadOnly(m_selectedWave)) + { + menu.addItem("Save (overwrite " + WaveTreeItem::getWaveName(m_selectedWave) + ')', true, false, [this] + { + saveWaveTo(m_selectedWave); + }); + } + + // open menu and let user select one of the wave slots + const auto subMenu = createRamWavesPopupMenu([this](const xt::WaveId _id) + { + saveWaveTo(_id); + }); + + menu.addSubMenu("Save as...", subMenu); + + menu.showMenuAsync({}); + } } diff --git a/source/xtJucePlugin/xtWaveEditor.h b/source/xtJucePlugin/xtWaveEditor.h @@ -1,6 +1,7 @@ #pragma once #include "weData.h" +#include "weGraph.h" #include "weGraphData.h" #include "xtWaveEditorStyle.h" @@ -57,6 +58,8 @@ namespace xtJucePlugin void filesDropped(std::map<xt::WaveId, xt::WaveData>& _waves, std::map<xt::TableId, xt::TableData>& _tables, const juce::StringArray& _files); + void openGraphPopupMenu(const Graph& _graph, const juce::MouseEvent& _event); + private: // ComponentMovementWatcher void componentVisibilityChanged() override { checkFirstTimeVisible(); } @@ -71,11 +74,12 @@ namespace xtJucePlugin void onWaveDataChanged(const xt::WaveData& _data) const; - void saveWave(); bool saveWaveTo(xt::WaveId _target); void saveWavetable(); + static juce::PopupMenu createRamWavesPopupMenu(const std::function<void(xt::WaveId)>& _callback); + Editor& m_editor; std::unique_ptr<WaveTree> m_waveTree;