BubbleComponent feature request

It would be nice if you could add child components instead of just having to override paint

Fair point.

The following addition to BubbleComponent::setPosition stops it from falling off of the screen which is useful.

[code] Rectangle newPosition(x, y, w, h);

if (!availableSpace.contains(newPosition))
{
	if (newPosition.getX() < availableSpace.getX())
	{
		int offset = availableSpace.getX() - newPosition.getX();
		newPosition.translate(offset, 0);
		arrowTipX -= offset;
	}
	if (newPosition.getRight() > availableSpace.getRight())
	{
		int offset = newPosition.getRight() - availableSpace.getRight();
		newPosition.translate(-offset, 0);
		arrowTipX += offset;
	}

	if (newPosition.getY() < availableSpace.getY())
	{
		int offset = availableSpace.getY() - newPosition.getY();
		newPosition.translate(0, offset);
		arrowTipY -= offset;
	}
	if (newPosition.getBottom() > availableSpace.getBottom())
	{
		int offset = newPosition.getBottom() - availableSpace.getBottom();
		newPosition.translate(0, -offset);
		arrowTipX -= offset;
	}
}

setBounds (newPosition);[/code]

Oh, ok. Thanks. I didn’t realise it could fall off the screen, but I’ll add that logic!