From aea20ee144cad761aff6423dbb96a080c67076cf Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 25 Jul 2012 12:16:42 +0100 Subject: [PATCH] Added background and outline colour IDs to BubbleComponent, and updated the arguments to the LookAndFeel::drawBubble method. --- .../Project/jucer_ProjectContentComponent.cpp | 2 ++ .../lookandfeel/juce_LookAndFeel.cpp | 23 ++++++++----------- .../lookandfeel/juce_LookAndFeel.h | 7 +++--- .../misc/juce_BubbleComponent.cpp | 4 +--- .../misc/juce_BubbleComponent.h | 13 +++++++++++ 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp b/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp index 795265dab0..df06ebd053 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp @@ -690,6 +690,8 @@ bool ProjectContentComponent::reinvokeCommandAfterClosingPropertyEditors (const void ProjectContentComponent::showBubbleMessage (const Rectangle& 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); diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index c7e6baa3cf..4cfdc2a903 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp @@ -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& tip, const Rectangle& body) { - const Rectangle body (boxX, boxY, boxW, boxH); - Path p; - p.addBubble (body, - body.getUnion (Rectangle (tipX, tipY, 1.0f, 1.0f)), - Point (tipX, tipY), - 5.0f, jmin (15.0f, boxW * 0.2f, boxH * 0.2f)); + p.addBubble (body, body.getUnion (Rectangle (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)); } diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h index 2c24bb4103..7bfcb213ce 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h @@ -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& tip, const Rectangle& 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; diff --git a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp index 94f585c889..94a55337b2 100644 --- a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp +++ b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp @@ -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()); diff --git a/modules/juce_gui_basics/misc/juce_BubbleComponent.h b/modules/juce_gui_basics/misc/juce_BubbleComponent.h index 7acfa940e5..d37cb4072c 100644 --- a/modules/juce_gui_basics/misc/juce_BubbleComponent.h +++ b/modules/juce_gui_basics/misc/juce_BubbleComponent.h @@ -123,6 +123,19 @@ public: */ void setPosition (const Rectangle& 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: //==============================================================================