1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Complete rewrite of the TextLayout class, to provide better support for native platform layout functions. It now works with the AttributedString class, to provide a pre-formatted AttributedString that can be drawn.

This commit is contained in:
jules 2011-11-25 14:25:12 +00:00
parent 1a5bdda7f1
commit 58db7eb880
16 changed files with 994 additions and 1200 deletions

View file

@ -43,12 +43,8 @@ void BubbleMessageComponent::showAt (int x, int y,
const bool removeWhenMouseClicked,
const bool deleteSelfAfterUse)
{
textLayout.clear();
textLayout.setText (text, Font (14.0f));
textLayout.layout (256, Justification::centredLeft, true);
createLayout (text);
setPosition (x, y);
init (numMillisecondsBeforeRemoving, removeWhenMouseClicked, deleteSelfAfterUse);
}
@ -58,15 +54,20 @@ void BubbleMessageComponent::showAt (Component* const component,
const bool removeWhenMouseClicked,
const bool deleteSelfAfterUse)
{
textLayout.clear();
textLayout.setText (text, Font (14.0f));
textLayout.layout (256, Justification::centredLeft, true);
createLayout (text);
setPosition (component);
init (numMillisecondsBeforeRemoving, removeWhenMouseClicked, deleteSelfAfterUse);
}
void BubbleMessageComponent::createLayout (const String& text)
{
AttributedString attString;
attString.append (text, Font (14.0f));
attString.setJustification (Justification::centred);
textLayout.createLayoutWithBalancedLineLengths (attString, 256);
}
void BubbleMessageComponent::init (const int numMillisecondsBeforeRemoving,
const bool removeWhenMouseClicked,
const bool deleteSelfAfterUse)
@ -92,15 +93,15 @@ void BubbleMessageComponent::init (const int numMillisecondsBeforeRemoving,
void BubbleMessageComponent::getContentSize (int& w, int& h)
{
w = textLayout.getWidth() + 16;
h = textLayout.getHeight() + 16;
w = (int) (textLayout.getWidth() + 16.0f);
h = (int) (textLayout.getHeight() + 16.0f);
}
void BubbleMessageComponent::paintContent (Graphics& g, int w, int h)
{
g.setColour (findColour (TooltipWindow::textColourId));
textLayout.drawWithin (g, 0, 0, w, h, Justification::centred);
textLayout.draw (g, Rectangle<float> (0.0f, 0.0f, (float) w, (float) h));
}
void BubbleMessageComponent::timerCallback()