mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added some layout arguments to BubbleComponent::setPosition()
This commit is contained in:
parent
6f19816cf4
commit
3a8f6d0300
2 changed files with 23 additions and 16 deletions
|
|
@ -49,35 +49,37 @@ void BubbleComponent::setAllowedPlacement (const int newPlacement)
|
|||
allowablePlacements = newPlacement;
|
||||
}
|
||||
|
||||
void BubbleComponent::setPosition (Component* componentToPointTo)
|
||||
//==============================================================================
|
||||
void BubbleComponent::setPosition (Component* componentToPointTo, int distanceFromTarget, int arrowLength)
|
||||
{
|
||||
jassert (componentToPointTo != nullptr);
|
||||
|
||||
Rectangle<int> target;
|
||||
|
||||
if (Component* p = getParentComponent())
|
||||
setPosition (p->getLocalArea (componentToPointTo, componentToPointTo->getLocalBounds()));
|
||||
target = p->getLocalArea (componentToPointTo, componentToPointTo->getLocalBounds());
|
||||
else
|
||||
setPosition (componentToPointTo->getScreenBounds());
|
||||
target = componentToPointTo->getScreenBounds();
|
||||
|
||||
setPosition (target, distanceFromTarget, arrowLength);
|
||||
}
|
||||
|
||||
void BubbleComponent::setPosition (Point<int> pos)
|
||||
void BubbleComponent::setPosition (Point<int> arrowTipPos, int arrowLength)
|
||||
{
|
||||
setPosition (Rectangle<int> (pos.x, pos.y, 1, 1));
|
||||
setPosition (Rectangle<int> (arrowTipPos.x, arrowTipPos.y, 1, 1), arrowLength, arrowLength);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void BubbleComponent::setPosition (const Rectangle<int>& rectangleToPointTo)
|
||||
void BubbleComponent::setPosition (Rectangle<int> rectangleToPointTo,
|
||||
int distanceFromTarget, int arrowLength)
|
||||
{
|
||||
const int edgeSpace = 15;
|
||||
const int arrowLength = 10;
|
||||
|
||||
{
|
||||
int contentW = 150, contentH = 30;
|
||||
getContentSize (contentW, contentH);
|
||||
content.setBounds (edgeSpace, edgeSpace, contentW, contentH);
|
||||
content.setBounds (distanceFromTarget, distanceFromTarget, contentW, contentH);
|
||||
}
|
||||
|
||||
const int totalW = content.getWidth() + edgeSpace * 2;
|
||||
const int totalH = content.getHeight() + edgeSpace * 2;
|
||||
const int totalW = content.getWidth() + distanceFromTarget * 2;
|
||||
const int totalH = content.getHeight() + distanceFromTarget * 2;
|
||||
|
||||
const Rectangle<int> availableSpace (getParentComponent() != nullptr ? getParentComponent()->getLocalBounds()
|
||||
: getParentMonitorArea());
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ public:
|
|||
on where there's the most space, honouring any restrictions that were set
|
||||
with setAllowedPlacement().
|
||||
*/
|
||||
void setPosition (Component* componentToPointTo);
|
||||
void setPosition (Component* componentToPointTo,
|
||||
int distanceFromTarget = 15, int arrowLength = 10);
|
||||
|
||||
/** Moves and resizes the bubble to point at a given point.
|
||||
|
||||
|
|
@ -107,7 +108,7 @@ public:
|
|||
on where there's the most space, honouring any restrictions that were set
|
||||
with setAllowedPlacement().
|
||||
*/
|
||||
void setPosition (Point<int> arrowTipPosition);
|
||||
void setPosition (Point<int> arrowTipPosition, int arrowLength = 10);
|
||||
|
||||
/** Moves and resizes the bubble to point at a given rectangle.
|
||||
|
||||
|
|
@ -119,8 +120,12 @@ public:
|
|||
It'll put itself either above, below, or to the side of the component depending
|
||||
on where there's the most space, honouring any restrictions that were set
|
||||
with setAllowedPlacement().
|
||||
|
||||
distanceFromTarget is the amount of space to leave between the bubble and the
|
||||
target rectangle, and arrowLength is the length of the arrow that it will draw.
|
||||
*/
|
||||
void setPosition (const Rectangle<int>& rectangleToPointTo);
|
||||
void setPosition (Rectangle<int> rectangleToPointTo,
|
||||
int distanceFromTarget = 15, int arrowLength = 10);
|
||||
|
||||
//==============================================================================
|
||||
/** A set of colour IDs to use to change the colour of various aspects of the bubble component.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue