30 : allowablePlacements (above | below | left | right)
56 allowablePlacements = newPlacement;
62 jassert (componentToPointTo !=
nullptr);
67 target = p->getLocalArea (componentToPointTo, componentToPointTo->
getLocalBounds());
71 setPosition (target, distanceFromTarget, arrowLength);
80 int distanceFromTarget,
int arrowLength)
83 int contentW = 150, contentH = 30;
85 content.
setBounds (distanceFromTarget, distanceFromTarget, contentW, contentH);
88 const int totalW = content.
getWidth() + distanceFromTarget * 2;
89 const int totalH = content.
getHeight() + distanceFromTarget * 2;
94 int spaceAbove = ((allowablePlacements & above) != 0) ?
jmax (0, rectangleToPointTo.
getY() - availableSpace.getY()) : -1;
95 int spaceBelow = ((allowablePlacements & below) != 0) ?
jmax (0, availableSpace.getBottom() - rectangleToPointTo.
getBottom()) : -1;
96 int spaceLeft = ((allowablePlacements & left) != 0) ?
jmax (0, rectangleToPointTo.
getX() - availableSpace.getX()) : -1;
97 int spaceRight = ((allowablePlacements & right) != 0) ?
jmax (0, availableSpace.getRight() - rectangleToPointTo.
getRight()) : -1;
101 && (spaceAbove > totalH + 20 || spaceBelow > totalH + 20))
103 spaceLeft = spaceRight = 0;
106 && (spaceLeft > totalW + 20 || spaceRight > totalW + 20))
108 spaceAbove = spaceBelow = 0;
111 int targetX, targetY;
113 if (
jmax (spaceAbove, spaceBelow) >=
jmax (spaceLeft, spaceRight))
115 targetX = rectangleToPointTo.
getCentre().x;
116 arrowTip.
x = totalW / 2;
118 if (spaceAbove >= spaceBelow)
121 targetY = rectangleToPointTo.
getY();
122 arrowTip.
y = content.
getBottom() + arrowLength;
127 targetY = rectangleToPointTo.
getBottom();
128 arrowTip.
y = content.
getY() - arrowLength;
133 targetY = rectangleToPointTo.
getCentre().y;
134 arrowTip.
y = totalH / 2;
136 if (spaceLeft > spaceRight)
139 targetX = rectangleToPointTo.
getX();
140 arrowTip.
x = content.
getRight() + arrowLength;
145 targetX = rectangleToPointTo.
getRight();
146 arrowTip.
x = content.
getX() - arrowLength;
150 setBounds (targetX - arrowTip.
x, targetY - arrowTip.
y, totalW, totalH);
BubbleComponent()
Creates a BubbleComponent.
void setPosition(Component *componentToPointTo, int distanceFromTarget=15, int arrowLength=10)
Moves and resizes the bubble to point at a given component.
virtual void paintContent(Graphics &g, int width, int height)=0
Subclasses should override this to draw their bubble's contents.
~BubbleComponent() override
Destructor.
void lookAndFeelChanged() override
Called to let the component react to a change in the look-and-feel setting.
void paint(Graphics &) override
Components can override this method to draw their content.
void setAllowedPlacement(int newPlacement)
Tells the bubble which positions it's allowed to put itself in, relative to the point at which it's p...
virtual void getContentSize(int &width, int &height)=0
Subclasses should override this to return the size of the content they want to draw inside the bubble...
The base class for all JUCE user-interface objects.
AffineTransform getTransform() const
Returns the transform that is currently being applied to this component.
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Changes the default return value for the hitTest() method.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
Rectangle< int > getScreenBounds() const
Returns the bounds of this component, relative to the screen's top-left.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
Rectangle< int > getParentMonitorArea() const
Returns the screen coordinates of the monitor that contains this component.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
A graphics context, used for drawing a component or image.
bool reduceClipRegion(int x, int y, int width, int height)
Intersects the current clipping region with another region.
void setOrigin(Point< int > newOrigin)
Moves the position of the context's origin.
A pair of (x, y) coordinates.
constexpr Point< float > toFloat() const noexcept
Casts this point to a Point<float> object.
ValueType y
The point's Y coordinate.
ValueType x
The point's X coordinate.
Manages a rectangle and allows geometric operations to be performed on it.
ValueType getRight() const noexcept
Returns the x coordinate of the rectangle's right-hand-side.
Point< ValueType > getCentre() const noexcept
Returns the centre point of the rectangle.
Rectangle< float > toFloat() const noexcept
Casts this rectangle to a Rectangle<float>.
ValueType getX() const noexcept
Returns the x coordinate of the rectangle's left-hand-side.
Point< ValueType > getPosition() const noexcept
Returns the rectangle's top-left position as a Point.
ValueType getBottom() const noexcept
Returns the y coordinate of the rectangle's bottom edge.
ValueType getWidth() const noexcept
Returns the width of the rectangle.
ValueType getY() const noexcept
Returns the y coordinate of the rectangle's top edge.
Rectangle transformedBy(const AffineTransform &transform) const noexcept
Returns the smallest rectangle that can contain the shape created by applying a transform to this rec...
ValueType getHeight() const noexcept
Returns the height of the rectangle.
void setBounds(ValueType newX, ValueType newY, ValueType newWidth, ValueType newHeight) noexcept
Changes all the rectangle's coordinates.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
virtual void drawBubble(Graphics &g, BubbleComponent &bubbleComponent, const Point< float > &positionOfTip, const Rectangle< float > &body)=0
Override this method to draw a speech-bubble pointing at a specific location on the screen.
virtual void setComponentEffectForBubbleComponent(BubbleComponent &bubbleComponent)=0
Override this method to set effects, such as a drop-shadow, on a BubbleComponent.