I have this black background showing on the button’s bounds when I turn on the toggle state of a DrawableButton. I can’t see what I’m doing wrong.
Here is a minimal code example:
/*
==============================================================================
This file was auto-generated!
==============================================================================
*/
#include "MainComponent.h"
//==============================================================================
MainComponent::MainComponent()
{
playButtonImage = Drawable::createFromImageData(BinaryData::button_play_svg, BinaryData::button_play_svgSize);
pauseButtonImage = Drawable::createFromImageData(BinaryData::button_pause_svg, BinaryData::button_pause_svgSize);
playButton.reset(new DrawableButton("playButton", DrawableButton::ButtonStyle::ImageFitted));
playButton->setImages(playButtonImage.get(), playButtonImage.get(), playButtonImage.get(), nullptr,
pauseButtonImage.get(), pauseButtonImage.get(), pauseButtonImage.get(), nullptr
);
addAndMakeVisible(playButton.get());
playButton->addListener(this);
setSize (600, 400);
}
MainComponent::~MainComponent()
{
}
//==============================================================================
void MainComponent::paint (Graphics& g)
{
g.fillAll (Colours::blanchedalmond);
}
void MainComponent::resized()
{
playButton->setBounds(getLocalBounds().reduced(getWidth()/4, getHeight()/4));
}
void MainComponent::buttonClicked (Button* buttonThatWasClicked)
{
isOn = !isOn;
playButton->setToggleState(isOn, NotificationType::dontSendNotification);
}
Example source with assets :
Source.zip (7.5 KB)