Hi I am currently trying to create a Drawable Button with 4 times the same image (for the states Up, Over, Down and Disabled). But I would like to resize the image corresponding to the Down toggle state so that It gives the illusion of being pressed.
I tried to do it directly by applying an AffineTransform::scale() to the Drawable. But it doesn’t change anything. Probably because of the the buttons are set to be ButtonStyle::ImageFitted. Just to be sure I am not doing something stupid, here is the code I used. In the private section I initialize a unique pointer :
- std::unique_ptr < Drawable > instDown = Drawable::createFromImageData (BinaryData::instrumentDown_svg, BinaryData::instrumentDown_svgSize);
Then in the constructor I resize the image and initialize the drawable buttons doing :
- instDown.get()->setTransform( juce::AffineTransform::scale(10.f, 10.f, instDown.get()->getDrawableBounds().getCentreX(), instDown.get()->getDrawableBounds().getCentreX()));
- instDrawableButton.setImages(instUp.get(), instOver.get(), instDown.get(), instUp.get());
I thought of something else that would do the trick, which is to create a DrawableComposite and to resize my drawable inside the composite. But then I struggle to create a DrawableComposite. I don’t understand how to add a Drawable to a composite because in the documentation there is no such function as “AddDrawable” in DrawableComposite.
Also, could someone tell me how to add code in a forum topic ? Here I use blockquotes but I would like to know for the next time.
I’ll appreciate any help.