Juce无法在音频插件上插入按钮



我正在尝试在音频插件中添加一个按钮,但似乎无法在测试时显示它。

我正在使用插件主机进行测试,并查看GUI。pad1PluginEditor.h中定义:

private:
    // This reference is provided as a quick way for your editor to
    // access the processor object that created it.
    CPAudioProcessor& processor;
    TextButton pad1;

我已将以下代码放在PluginEditor.cpp

CPAudioProcessorEditor::CPAudioProcessorEditor (CPAudioProcessor& p)
    : AudioProcessorEditor (&p), processor (p)
{
    pad1.setColour(TextButton::buttonColourId, Colours::lime);
    pad1.setButtonText("Press Me!");
    addAndMakeVisible(pad1);
    // Make sure that before the constructor has finished, you've set the
    // editor's size to whatever you need it to be.
    setSize (400, 300);
}

我正在关注本教程,作为如何添加按钮的指南:https://www.juce.com/doc/tutorial_rectangle_advanced

我缺少什么吗?它看起来与指南中的代码相同。

问题是我忘了在覆盖的resized方法中设置宽度/高度。

void CPAudioProcessorEditor::resized()
{
    // This is generally where you'll want to lay out the positions of any
    // subcomponents in your editor..
    pad1.setBounds(10, 10, 100, 100);
}

最新更新