PanelControl::PanelControl()
:mTempoButton(mAudioprocessor.getmApvts(),
MyParamId::Control::Tempo.getParamID(),
MyHelper::CmdId::Tempo)
class PanelDelay : public PanelBase,
private juce::Button::Listener
ToggleButton is derived from Button, we can use the Button class's Listener. And I want to use Listener only in the derived class, the access specifier was set to private.
juce::Button& PanelControl::getTempoButton() noexcept
{
return mTempoButton;
}
PanelDelay(const juce::String& inTitle,
EulerDelayAudioProcessor& inAudioprocessor,
juce::Button& inButton);
AudioProcessorEditor()
: mPanelControl("Control"),
mPanelDelay("Delay", mPanelControl.getTempoButton())
PanelDelay::PanelDelay()
: mTempoButton(inButton)
Is is important to set the state of ToggleButton as a reference.
class JUCE_API Listener
{
public:
/** Called when the button is clicked. */
virtual void buttonClicked (Button*) = 0;
};
Listener class has a buttonClicked() as a pure virtual function, we have to define that.
void PanelDelay::buttonClicked (juce::Button* inButton)
{
switch(inButton->getCommandID())
{
case MyHelper::CmdId::Tempo: //
{
setVisibleParam(inButton->getToggleState());
break;
}
default: break;
}
}
If we add PanelDelay as a lisnter for many buttons, we should identify which botton has changed when buttonClicked() is called. By using specific ID of button, we can recognize.
Finally, setVisibleParam() is the function of what would be displayed at PanelDelay in GUI.
void PanelDelay::setVisibleParam (const bool inState) noexcept
{
for(int i=0;i<2;++i)
{
mLabelTime[i].setVisible(!inState);
mKnobTime[i].setVisible(!inState);
mLabelNote[i].setVisible(inState);
mKnobNote[i].setVisible(inState);
}
}
Just get the bool object as a parameter, we can directly pass that to the setvisible() function.
|
|