Use new JUCE button callback stuff
This commit is contained in:
parent
64ad16f8cb
commit
96a88e8016
@ -33,11 +33,11 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor (Pa
|
||||
{
|
||||
addAndMakeVisible(&m_import_button);
|
||||
m_import_button.setButtonText("Import file...");
|
||||
attachCallback(m_import_button, [this]() { chooseFile(); });
|
||||
m_import_button.onClick = [this]() { chooseFile(); };
|
||||
|
||||
addAndMakeVisible(&m_settings_button);
|
||||
m_settings_button.setButtonText("Settings...");
|
||||
attachCallback(m_settings_button, [this]() { showSettingsMenu(); });
|
||||
m_settings_button.onClick = [this]() { showSettingsMenu(); };
|
||||
|
||||
addAndMakeVisible(&m_info_label);
|
||||
m_info_label.setJustificationType(Justification::centredRight);
|
||||
|
@ -40,34 +40,6 @@ private:
|
||||
double m_elapsed = 0.0;
|
||||
};
|
||||
|
||||
inline void attachCallback(Button& button, std::function<void()> callback)
|
||||
{
|
||||
struct ButtonCallback : public Button::Listener,
|
||||
private ComponentListener
|
||||
{
|
||||
ButtonCallback(Button& b, std::function<void()> f) : target(b), fn(f)
|
||||
{
|
||||
target.addListener(this);
|
||||
target.addComponentListener(this);
|
||||
}
|
||||
|
||||
~ButtonCallback()
|
||||
{
|
||||
target.removeListener(this);
|
||||
}
|
||||
|
||||
void componentBeingDeleted(Component&) override { delete this; }
|
||||
void buttonClicked(Button*) override { fn(); }
|
||||
|
||||
Button& target;
|
||||
std::function<void()> fn;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ButtonCallback)
|
||||
};
|
||||
|
||||
new ButtonCallback(button, callback);
|
||||
}
|
||||
|
||||
class MySlider : public Slider
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user