Tsury
February 17, 2012, 9:34pm
1
juce_TextEditor.cpp:
if (isMultiLine())
{
g.drawText (textToShowWhenEmpty,
0, 0, getWidth(), getHeight(),
Justification::centred, true);
}
else
{
g.drawText (textToShowWhenEmpty,
leftIndent, topIndent,
viewport->getWidth() - leftIndent,
viewport->getHeight() - topIndent,
[b]Justification::centredLeft[/b], true);
}
I noticed the textToShowWhenEmpty appears slightly lower than the normal text.
Setting the bold line to Justification::topLeft fixed it.
jules
February 17, 2012, 9:50pm
2
Well… I think my intention was that the text would go in the centre of the component. E.g. if it’s a multi-line component, the message would be in the middle rather than at the top.
Tsury
February 17, 2012, 9:56pm
3
When you’re drawing the normal text you use setOrigin(leftIndent, topIndent) - for single lined text editors this looks funny in the best case and cut out in the worst one.
jules
February 20, 2012, 10:42am
4
Actually, looking at that snippet again, I think that what I probably meant to write was this:
g.drawText (textToShowWhenEmpty,
leftIndent, 0, viewport->getWidth() - leftIndent, getHeight(),
Justification::centredLeft, true);
…does that sort it out? I don’t think the justification setting was wrong, but it looks like I got the bounding box slightly off…
Tsury
February 20, 2012, 3:51pm
5
[quote=“jules”]Actually, looking at that snippet again, I think that what I probably meant to write was this:
g.drawText (textToShowWhenEmpty,
leftIndent, 0, viewport->getWidth() - leftIndent, getHeight(),
Justification::centredLeft, true);
…does that sort it out? I don’t think the justification setting was wrong, but it looks like I got the bounding box slightly off…[/quote]
Yup, seems like it hit the spot, thanks…