Path, DrawablePath Usage


#1

Hi Jules,

When moving from 1.46 to the tip, some stuff stopped working.
I am wondering if the problem is in my code or in the new implementation.

I used to do this to draw a little arrow in a button like a prev/next button.
The following code being the previous one.

const float sqrt3div2 = sqrt(3.f)/2.f;

juce::Path triangleClosed;
triangleClosed.addTriangle(-0.5, -sqrt3div2, 1, 0, -0.5, sqrt3div2);
triangleClosed.applyTransform(juce::AffineTransform::scale(0.5f,0.5f));

juce::DrawablePath triangle;
triangle.setPath(triangleClosed);
triangle.setFill(juce::Colour(0xff000000));

juce::DrawableComposite normal;
normal.insertDrawable(triangle);

juce::DrawableButton *pButton = new juce::DrawableButton("next", juce::DrawableButton::ImageOnButtonBackground);
pButton->setImages(&normal, &normal, &normal, &normal, &normal, &normal, &normal, &normal);
pButton->setBackgroundColours(juce::Colour(0xff91989B), juce::Colours::royalblue);
pButton->setEdgeIndent(0);

Any idea what is going wrong ?

Thanks,


#2

For what it worth
if I use triangleClosed.applyTransform(juce::AffineTransform::scale(100.f,100.f));
instead of the 0.5f, it works fine.

Did the DrawableButton used to expand the path but now only resize it ?

Thanks,


#3

The DrawableComposite now has a bounding box that marks the active area, so you need to set that appropriately to tell the button what area it should use. There’s a method to do it automatically: resetContentAreaAndBoundingBoxToFitChildren().


#4

Works fine with that.

Thanks a lot.