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

Added background and outline colour IDs to BubbleComponent, and updated the arguments to the LookAndFeel::drawBubble method.

This commit is contained in:
jules 2012-07-25 12:16:42 +01:00
parent 8a006e589c
commit aea20ee144
5 changed files with 29 additions and 20 deletions

View file

@ -690,6 +690,8 @@ bool ProjectContentComponent::reinvokeCommandAfterClosingPropertyEditors (const
void ProjectContentComponent::showBubbleMessage (const Rectangle<int>& pos, const String& text)
{
addChildComponent (&bubbleMessage);
bubbleMessage.setColour (BubbleComponent::backgroundColourId, Colours::white.withAlpha (0.7f));
bubbleMessage.setColour (BubbleComponent::outlineColourId, Colours::black.withAlpha (0.8f));
bubbleMessage.setAlwaysOnTop (true);
bubbleMessage.showAt (pos, AttributedString (text), 3000, true, false);

View file

@ -221,6 +221,9 @@ LookAndFeel::LookAndFeel()
GroupComponent::outlineColourId, 0x66000000,
GroupComponent::textColourId, 0xff000000,
BubbleComponent::backgroundColourId, 0xeeeeeebb,
BubbleComponent::outlineColourId, 0x77000000,
DirectoryContentsDisplayComponent::highlightColourId, textHighlightColour,
DirectoryContentsDisplayComponent::textColourId, 0xff000000,
@ -949,25 +952,17 @@ void LookAndFeel::drawTreeviewPlusMinusBox (Graphics& g, int x, int y, int w, in
}
//==============================================================================
void LookAndFeel::drawBubble (Graphics& g,
float tipX, float tipY,
float boxX, float boxY,
float boxW, float boxH)
void LookAndFeel::drawBubble (Graphics& g, BubbleComponent& comp,
const Point<float>& tip, const Rectangle<float>& body)
{
const Rectangle<float> body (boxX, boxY, boxW, boxH);
Path p;
p.addBubble (body,
body.getUnion (Rectangle<float> (tipX, tipY, 1.0f, 1.0f)),
Point<float> (tipX, tipY),
5.0f, jmin (15.0f, boxW * 0.2f, boxH * 0.2f));
p.addBubble (body, body.getUnion (Rectangle<float> (tip.x, tip.y, 1.0f, 1.0f)),
tip, 5.0f, jmin (15.0f, body.getWidth() * 0.2f, body.getHeight() * 0.2f));
//xxx need to take comp as param for colour
g.setColour (findColour (TooltipWindow::backgroundColourId).withAlpha (0.9f));
g.setColour (comp.findColour (BubbleComponent::backgroundColourId));
g.fillPath (p);
//xxx as above
g.setColour (findColour (TooltipWindow::textColourId).withAlpha (0.4f));
g.setColour (comp.findColour (BubbleComponent::outlineColourId));
g.strokePath (p, PathStrokeType (1.33f));
}

View file

@ -57,6 +57,7 @@ class ImageButton;
class CallOutBox;
class Drawable;
class CaretComponent;
class BubbleComponent;
//==============================================================================
/**
@ -335,9 +336,8 @@ public:
Button* goUpButton);
//==============================================================================
virtual void drawBubble (Graphics& g,
float tipX, float tipY,
float boxX, float boxY, float boxW, float boxH);
virtual void drawBubble (Graphics& g, BubbleComponent&,
const Point<float>& tip, const Rectangle<float>& body);
//==============================================================================
virtual void drawLasso (Graphics& g, Component& lassoComp);
@ -665,6 +665,7 @@ private:
virtual int drawTabAreaBehindFrontButton (Graphics&, int, int, TabbedButtonBar&, TabbedButtonBar::Orientation) { return 0; }
virtual int drawTabButtonText (Graphics&, int, int, int, int, const Colour&, int, const String&, Button&, TabbedButtonBar::Orientation, bool, bool, bool) { return 0; }
virtual int getTabButtonBestWidth (int, const String&, int, Button&) { return 0; }
virtual int drawBubble (Graphics&, float, float, float, float, float, float) { return 0; }
#endif
class GlassWindowButton;

View file

@ -37,9 +37,7 @@ BubbleComponent::~BubbleComponent() {}
//==============================================================================
void BubbleComponent::paint (Graphics& g)
{
getLookAndFeel().drawBubble (g, (float) arrowTip.x, (float) arrowTip.y,
(float) content.getX(), (float) content.getY(),
(float) content.getWidth(), (float) content.getHeight());
getLookAndFeel().drawBubble (g, *this, arrowTip.toFloat(), content.toFloat());
g.reduceClipRegion (content);
g.setOrigin (content.getX(), content.getY());

View file

@ -123,6 +123,19 @@ public:
*/
void setPosition (const Rectangle<int>& rectangleToPointTo);
//==============================================================================
/** A set of colour IDs to use to change the colour of various aspects of the bubble component.
These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
methods.
@see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
*/
enum ColourIds
{
backgroundColourId = 0x1000af0, /**< A background colour to fill the bubble with. */
outlineColourId = 0x1000af1 /**< The colour to use for an outline around the bubble. */
};
protected:
//==============================================================================