class PanelControl : public PanelBase
{
public:
PanelControl():
mButtonPingPong(mAudioprocessor.getmApvts(),
MyParamId::Control::PingPong.getParamID(),
MyHelper::CmdIdButtons::PingPong)
{
mLabelPingPong.setText("PingPong", juce::NotificationType::dontSendNotification);
mLabelPingPong.setJustificationType(juce::Justification::centred);
addAndMakeVisible(mLabelPingPong);
addAndMakeVisible(mButtonPingPong);
}
private:
juce::Label mLabelPingPong;
MyParamToggleButton mButtonPingPong;
}
class PanelDelay : public PanelBase,
private juce::Button::Listener
{
public:
PanelDelay(juce::Button& inButtonPingPong):
mButtonPingPong(inButtonPingPong)
{
mButtonPingPong.addListener(this);
}
~PanelDelay()
{
mButtonPingPong.removeListener(this);
}
private:
juce::Button& mButtonPingPong;
}
Delay Panel has to be added as a listener of button of ping-pong.
buttonClicked(juce::Button* inButton)
{
switch(inButton->getCommandID())
{
case MyHelper::CmdIdButtons::PingPong:
{
setTextLabels(inButton -> getToggleState());
setVisibleLaveAndKnobs(mButtonTempo.getToggleState(), inButton -> getToggleState());
break;
}
default: break;
}
}
When ping-pong button is clicked, we need to change the label of delay L and show delay knob partically.
setVisibleLaveAndKnobs(const bool inTempo, const bool inPingPong) noexcept
{
for(int i=0;i<2 ; ++i)
{
mLabelTime[i].setVisible(i == 0 ? !inTempo : !inTempo && !inPingPong);
mKnobTime[i].setVisible(i == 0 ? !inTempo : !inTempo && !inPingPong);
mLabelNote[i].setVisible(i == 0 ? inTempo : inTempo && !inPingPong);
mKnobNote[i].setVisible(i == 0 ? inTempo : inTempo && !inPingPong);
}
}
This function sets the visibility of labels and knobs based on two conditions (inTempo and inPingPong). For the first element (i == 0), visibility depends only on inTempo. For the second element (i == 1), visibility is set only if inTempo is off (false) and inPingPong is also off (false).
setTextLabels(const bool inPingPong) noexcept
{
mLabelTime[0].setText(inPingPong ? "Time" : "Time L", juce::NotificationType::dontSendNotification);
mLabelNote[0].setText(inPingPong ? "Note" : "Note L", juce::NotificationType::dontSendNotification);
}
This function sets label texts to either "Time"/"Note" if inPingPong is active (true), or "Time L"/"Note L" if it's inactive (false).