From d4b1bffe7ab93b3d4082264c93c2d19d0b1424e5 Mon Sep 17 00:00:00 2001 From: xenakios Date: Fri, 9 Mar 2018 19:39:39 +0200 Subject: [PATCH] Kind of working now, but maybe not in the best way... --- Source/PS_Source/ProcessedStretch.h | 12 ++++++++++++ Source/PluginEditor.cpp | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Source/PS_Source/ProcessedStretch.h b/Source/PS_Source/ProcessedStretch.h index 46d8607..7e20d9f 100644 --- a/Source/PS_Source/ProcessedStretch.h +++ b/Source/PS_Source/ProcessedStretch.h @@ -443,6 +443,18 @@ public: AudioParameterBool* m_enabled = nullptr; }; +// Special function to swap the modules. We don't want to mess up the AudioParameterBool pointers, +// just swap the boolean states... + +inline void swapSpectrumProcesses(SpectrumProcess& a, SpectrumProcess& b) +{ + bool aenab = *b.m_enabled; + bool benab = *a.m_enabled; + std::swap(a.m_index, b.m_index); + *a.m_enabled = aenab; + *b.m_enabled = benab; +} + class ProcessedStretch final : public Stretch { public: diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index e8cb274..5fc4945 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -348,7 +348,7 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id) m_wavecomponent.setTimeSelection(processor.getTimeSelection()); if (processor.m_state_dirty) { - m_spec_order_ed.setSource(processor.getStretchSource()); + //m_spec_order_ed.setSource(processor.getStretchSource()); processor.m_state_dirty = false; } } @@ -950,7 +950,8 @@ void SpectralChainEditor::mouseDrag(const MouseEvent & ev) int new_index = ev.x / box_w; if (new_index >= 0 && new_index < m_order.size() && new_index != m_cur_index) { - std::swap(m_order[m_cur_index], m_order[new_index]); + swapSpectrumProcesses(m_order[m_cur_index], m_order[new_index]); + m_cur_index = new_index; m_did_drag = true; m_src->setSpectrumProcessOrder(m_order); @@ -1025,7 +1026,7 @@ void SpectralChainEditor::drawBox(Graphics & g, int index, int x, int y, int w, //g.drawFittedText(m_order[index].m_enabled->name, x, y, w, h, Justification::centred, 3); g.setColour(Colours::gold); g.drawRect(x + 2, y + 2, 12, 12); - if (*m_order[index].m_enabled == true) + if ((bool)*m_order[index].m_enabled == true) { g.drawLine(x+2, y+2, x+14, y+14); g.drawLine(x+2, y+14, x+14, y+2);