diff --git a/extras/JuceDemo/Source/demos/WidgetsDemo.cpp b/extras/JuceDemo/Source/demos/WidgetsDemo.cpp index 72ee209680..d9c852d449 100644 --- a/extras/JuceDemo/Source/demos/WidgetsDemo.cpp +++ b/extras/JuceDemo/Source/demos/WidgetsDemo.cpp @@ -935,8 +935,12 @@ public: addChildComponent (bmc); } - bmc->showAt (button, "This is a demo of the BubbleMessageComponent, which lets you pop up a message pointing at a component or somewhere on the screen.\n\nThe message bubbles will disappear after a timeout period, or when the mouse is clicked.", - 2000, true, true); + AttributedString text ("This is a demo of the BubbleMessageComponent, which lets you pop up a message pointing " + "at a component or somewhere on the screen.\n\n" + "The message bubbles will disappear after a timeout period, or when the mouse is clicked."); + text.setJustification (Justification::centred); + + bmc->showAt (button, text, 2000, true, true); } static const Colour getRandomBrightColour() diff --git a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp index e436a0dbbf..626d5aa578 100644 --- a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp @@ -35,7 +35,7 @@ BubbleMessageComponent::~BubbleMessageComponent() } void BubbleMessageComponent::showAt (int x, int y, - const String& text, + const AttributedString& text, const int numMillisecondsBeforeRemoving, const bool removeWhenMouseClicked, const bool deleteSelfAfterUse) @@ -46,7 +46,7 @@ void BubbleMessageComponent::showAt (int x, int y, } void BubbleMessageComponent::showAt (Component* const component, - const String& text, + const AttributedString& text, const int numMillisecondsBeforeRemoving, const bool removeWhenMouseClicked, const bool deleteSelfAfterUse) @@ -56,13 +56,9 @@ void BubbleMessageComponent::showAt (Component* const component, init (numMillisecondsBeforeRemoving, removeWhenMouseClicked, deleteSelfAfterUse); } -void BubbleMessageComponent::createLayout (const String& text) +void BubbleMessageComponent::createLayout (const AttributedString& text) { - AttributedString attString; - attString.append (text, Font (14.0f)); - attString.setJustification (Justification::centred); - - textLayout.createLayoutWithBalancedLineLengths (attString, 256); + textLayout.createLayoutWithBalancedLineLengths (text, 256); } void BubbleMessageComponent::init (const int numMillisecondsBeforeRemoving, @@ -90,15 +86,15 @@ void BubbleMessageComponent::init (const int numMillisecondsBeforeRemoving, void BubbleMessageComponent::getContentSize (int& w, int& h) { - w = (int) (textLayout.getWidth() + 16.0f); - h = (int) (textLayout.getHeight() + 16.0f); + w = 16 + (int) textLayout.getWidth(); + h = 16 + (int) textLayout.getHeight(); } void BubbleMessageComponent::paintContent (Graphics& g, int w, int h) { g.setColour (findColour (TooltipWindow::textColourId)); - textLayout.draw (g, Rectangle (0.0f, 0.0f, (float) w, (float) h)); + textLayout.draw (g, Rectangle ((float) w, (float) h)); } void BubbleMessageComponent::timerCallback() diff --git a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h index 67550f88e4..830b9e2be8 100644 --- a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h +++ b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h @@ -77,7 +77,7 @@ public: it becomes invisible */ void showAt (int x, int y, - const String& message, + const AttributedString& message, int numMillisecondsBeforeRemoving, bool removeWhenMouseClicked = true, bool deleteSelfAfterUse = false); @@ -100,7 +100,7 @@ public: it becomes invisible */ void showAt (Component* component, - const String& message, + const AttributedString& message, int numMillisecondsBeforeRemoving, bool removeWhenMouseClicked = true, bool deleteSelfAfterUse = false); @@ -121,7 +121,7 @@ private: int64 expiryTime; bool deleteAfterUse; - void createLayout (const String&); + void createLayout (const AttributedString&); void init (int numMillisecondsBeforeRemoving, bool removeWhenMouseClicked, bool deleteSelfAfterUse);