Highlight parameters of spectral module when clicked in the spectral chain editor

This commit is contained in:
xenakios 2018-02-01 15:11:41 +02:00
parent 0e997e1d43
commit e6fb981e01
2 changed files with 53 additions and 1 deletions

View File

@ -55,6 +55,25 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
if (parid->paramID.startsWith("fftsize") || parid->paramID.startsWith("numoutchans")) if (parid->paramID.startsWith("fftsize") || parid->paramID.startsWith("numoutchans"))
notifyonlyonrelease = true; notifyonlyonrelease = true;
m_parcomps.push_back(std::make_shared<ParameterComponent>(pars[i],notifyonlyonrelease)); m_parcomps.push_back(std::make_shared<ParameterComponent>(pars[i],notifyonlyonrelease));
int group_id = -1;
if (i == cpi_harmonicsbw || i == cpi_harmonicsfreq || i == cpi_harmonicsgauss || i == cpi_numharmonics)
group_id = 0;
if (i == cpi_octavesm2 || i == cpi_octavesm1 || i == cpi_octaves0 || i == cpi_octaves1 || i == cpi_octaves15 ||
i == cpi_octaves2)
group_id = 4;
if (i == cpi_tonalvsnoisebw || i == cpi_tonalvsnoisepreserve)
group_id = 1;
if (i == cpi_filter_low || i == cpi_filter_high)
group_id = 6;
if (i == cpi_compress)
group_id = 7;
if (i == cpi_spreadamount)
group_id = 5;
if (i == cpi_frequencyshift)
group_id = 2;
if (i == cpi_pitchshift)
group_id = 3;
m_parcomps.back()->m_group_id = group_id;
addAndMakeVisible(m_parcomps.back().get()); addAndMakeVisible(m_parcomps.back().get());
} }
@ -72,6 +91,16 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
m_wavecomponent.ShowFileCacheRange = true; m_wavecomponent.ShowFileCacheRange = true;
m_spec_order_ed.setSource(processor.getStretchSource()); m_spec_order_ed.setSource(processor.getStretchSource());
addAndMakeVisible(&m_spec_order_ed); addAndMakeVisible(&m_spec_order_ed);
m_spec_order_ed.ModuleSelectedCallback = [this](int id)
{
for (int i = 0; i < m_parcomps.size(); ++i)
{
if (m_parcomps[i]->m_group_id == id)
m_parcomps[i]->setHighLighted(true);
else
m_parcomps[i]->setHighLighted(false);
}
};
startTimer(1, 100); startTimer(1, 100);
startTimer(2, 1000); startTimer(2, 1000);
startTimer(3, 200); startTimer(3, 200);
@ -94,7 +123,7 @@ void PaulstretchpluginAudioProcessorEditor::resized()
m_import_button.changeWidthToFitText(); m_import_button.changeWidthToFitText();
m_settings_button.setBounds(m_import_button.getRight() + 1, 1, 60, 24); m_settings_button.setBounds(m_import_button.getRight() + 1, 1, 60, 24);
m_settings_button.changeWidthToFitText(); m_settings_button.changeWidthToFitText();
m_perfmeter.setBounds(m_settings_button.getRight() + 1, 1, 200, 12); m_perfmeter.setBounds(m_settings_button.getRight() + 1, 1, 150, 24);
m_info_label.setBounds(m_settings_button.getRight() + 1, m_settings_button.getY(), m_info_label.setBounds(m_settings_button.getRight() + 1, m_settings_button.getY(),
getWidth()-m_settings_button.getRight()-1, 24); getWidth()-m_settings_button.getRight()-1, 24);
int w = getWidth(); int w = getWidth();
@ -724,6 +753,8 @@ void SpectralChainEditor::mouseDown(const MouseEvent & ev)
m_cur_index = ev.x / box_w; m_cur_index = ev.x / box_w;
if (m_cur_index >= 0) if (m_cur_index >= 0)
{ {
if (ModuleSelectedCallback)
ModuleSelectedCallback(m_order[m_cur_index].m_index);
juce::Rectangle<int> r(box_w*m_cur_index, 1, 12, 12); juce::Rectangle<int> r(box_w*m_cur_index, 1, 12, 12);
if (r.contains(ev.x, ev.y)) if (r.contains(ev.x, ev.y))
{ {
@ -808,6 +839,7 @@ void SpectralChainEditor::drawBox(Graphics & g, int index, int x, int y, int w,
ParameterComponent::ParameterComponent(AudioProcessorParameter * par, bool notifyOnlyOnRelease) : m_par(par) ParameterComponent::ParameterComponent(AudioProcessorParameter * par, bool notifyOnlyOnRelease) : m_par(par)
{ {
addAndMakeVisible(&m_label); addAndMakeVisible(&m_label);
m_labeldefcolor = m_label.findColour(Label::textColourId);
m_label.setText(par->getName(50), dontSendNotification); m_label.setText(par->getName(50), dontSendNotification);
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(par); AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(par);
if (floatpar) if (floatpar)
@ -914,6 +946,22 @@ void ParameterComponent::updateComponent()
} }
} }
void ParameterComponent::setHighLighted(bool b)
{
if (b == false)
{
m_label.setColour(Label::textColourId, m_labeldefcolor);
if (m_togglebut)
m_togglebut->setColour(ToggleButton::textColourId, m_labeldefcolor);
}
else
{
m_label.setColour(Label::textColourId, Colours::yellow);
if (m_togglebut)
m_togglebut->setColour(ToggleButton::textColourId, Colours::yellow);
}
}
MySlider::MySlider(NormalisableRange<float>* range) : m_range(range) MySlider::MySlider(NormalisableRange<float>* range) : m_range(range)
{ {
} }

View File

@ -62,6 +62,8 @@ public:
void sliderDragEnded(Slider* slid) override; void sliderDragEnded(Slider* slid) override;
void buttonClicked(Button* but) override; void buttonClicked(Button* but) override;
void updateComponent(); void updateComponent();
void setHighLighted(bool b);
int m_group_id = -1;
private: private:
Label m_label; Label m_label;
AudioProcessorParameter* m_par = nullptr; AudioProcessorParameter* m_par = nullptr;
@ -70,6 +72,7 @@ private:
std::unique_ptr<ToggleButton> m_togglebut; std::unique_ptr<ToggleButton> m_togglebut;
bool m_notify_only_on_release = false; bool m_notify_only_on_release = false;
bool m_dragging = false; bool m_dragging = false;
Colour m_labeldefcolor;
}; };
class PerfMeterComponent : public Component class PerfMeterComponent : public Component
@ -151,6 +154,7 @@ public:
void mouseDown(const MouseEvent& ev) override; void mouseDown(const MouseEvent& ev) override;
void mouseDrag(const MouseEvent& ev) override; void mouseDrag(const MouseEvent& ev) override;
void mouseUp(const MouseEvent& ev) override; void mouseUp(const MouseEvent& ev) override;
std::function<void(int)> ModuleSelectedCallback;
private: private:
StretchAudioSource * m_src = nullptr; StretchAudioSource * m_src = nullptr;
bool m_did_drag = false; bool m_did_drag = false;