DrawableText stopped working


I updated to the tip and suddenly DrawableText stopped working. I use them on a DrawableButton, but they don’t show up anymore?


I’ve been making huge changes to the drawables - you’ll probably need to look at your code and tweak it, because their parameters may have changed a bit.


something must be wrong with the DrawableText, I can get it to crash, just try this in your demo:

in the ButtonsPage constructor in the WidgetsDemo change:

DrawableText down; down.setText(T("Hello!")); /* DrawableImage down; down.setImage (ImageCache::getFromMemory (BinaryData::juce_png, BinaryData::juce_pngSize)); down.setOverlayColour (Colours::black.withAlpha (0.3f)); */

If you press the button it will crash.


You need to give it a bounding box for the text. The default constructor doesn’t set one up, so it’s having problems with divisions-by-zero - I can stop that happening, but you’ll still need to call setBoundingBox and setFont or setFontSizeControlPoint to actually get it to do something sensible.


I am trying to understand the concept by reading your comments in the code.

It seems I have to set a bounding box with a RelativeParallelogram and then a setFont()? The other way around doesn’t seem to work. Also, if I set applySizeAndScale in setFont() to false it doesn’t work either.

I just need a simple text written in a DrawableButtton… How do I set that up?


Sorry, that class is pretty complicated now, and isn’t finished, and may all still change completely… For the new jucer vector editor, it needs to be able to manipulate the position of the text using a set of points, so you have to set a parallelogram that represents the text box limits, and then the font is defined by a point within that parallelogram, whose distance from the top-left corner indicates the font’s height and horizontal scale… Sounds incredibly complex, but when you’re editing these objects visually in the jucer, it all kind of makes sense, honest!

I’m not going to add proper comments until I’m sure I’ve got the class’s design right, but a simple setup might be something like

DrawableText t; t.setBoundingBox (RelativeParallelogram (RelativePoint (0.0f, 0.0f), RelativePoint (50.0f, 0.0f), RelativePoint (0.0f, 20.0f))); t.setFont (Font (15.0f), true); t.setText ("sdfsdf");