my DrawableText is created from an svg and its size is calculated from Font and Text metrics.
If, at a later point in Time, I want to replace the Text I also need to resize the DrawableText (at least if the new Text is wider), or it will be squeezed into the originally given size.
setSize() doesnt seem to have any affect. Probably because the text could be transformed.
I see that setBoundingBox() affects the size, but I don't understand how I simply apply this method (or any other more adequate) to only resize the text field, so the new text fits.
I don't want to be irritant but whats so difficult about anwering this simple question?
(Its OK to say something like: "its not possible. What you are trying is completely nuts. A DrawableText is not intended for resizing - thats completely out of the concept of a DrawableText..." or something similar.)
Its not pretty straightforward to me how the Bounding stuff and the Positioner actually work...
Apologies it took so long, we missed your other posts!
I agree that this isn't too intuitive, so thank you for your feedback. I've written some code for you that explains things for you (assume drawableText is an instance of DrawableText)...
MainContentComponent::MainContentComponent()
{
addAndMakeVisible (&drawableText);
drawableText.setText ("Test!");
drawableText.setColour(Colour (0xff00ff50));
setSize (600, 400);
}
MainContentComponent::~MainContentComponent()
{
}
void MainContentComponent::paint (Graphics& g)
{
g.fillAll (Colour (0xff001F36));
drawableText.draw (g, 1.0f);
}
void MainContentComponent::resized()
{
// these dimensions are used to draw the text
// the reason setBounds doesn't work in this context is
// because the MainContentComponent is drawing it using a
// Graphics& object within its own bounds
drawableText.setBoundingBox
(
RelativeParallelogram
(
Rectangle<float> (0, 0, getWidth(), getHeight())
)
);
// set your font height here!
drawableText.setFontHeight (getHeight());
}