mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Altered BubbleMessageComponent to take an AttributedString rather than a plain String, for more control over its layout.
This commit is contained in:
parent
20f0734863
commit
cb169b251d
3 changed files with 16 additions and 16 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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<float> (0.0f, 0.0f, (float) w, (float) h));
|
||||
textLayout.draw (g, Rectangle<float> ((float) w, (float) h));
|
||||
}
|
||||
|
||||
void BubbleMessageComponent::timerCallback()
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue