Browse Source

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

tags/2021-05-28
jules 13 years ago
parent
commit
aea20ee144
5 changed files with 29 additions and 20 deletions
  1. +2
    -0
      extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp
  2. +9
    -14
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp
  3. +4
    -3
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h
  4. +1
    -3
      modules/juce_gui_basics/misc/juce_BubbleComponent.cpp
  5. +13
    -0
      modules/juce_gui_basics/misc/juce_BubbleComponent.h

+ 2
- 0
extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp 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);


+ 9
- 14
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp 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));
}


+ 4
- 3
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h 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;


+ 1
- 3
modules/juce_gui_basics/misc/juce_BubbleComponent.cpp 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());


+ 13
- 0
modules/juce_gui_basics/misc/juce_BubbleComponent.h 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:
//==============================================================================


Loading…
Cancel
Save