|
|
@@ -109,7 +109,8 @@ void TooltipWindow::displayTip (Point<int> screenPos, const String& tip) |
|
|
|
if (w != this && w->tipShowing == tipShowing)
|
|
|
|
{
|
|
|
|
// Looks like you have more than one TooltipWindow showing the same tip..
|
|
|
|
// Be careful not to create more than one instance of this class!
|
|
|
|
// Be careful not to create more than one instance of this class with the
|
|
|
|
// same parent component!
|
|
|
|
jassertfalse;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -153,50 +154,55 @@ void TooltipWindow::timerCallback() |
|
|
|
auto now = Time::getApproximateMillisecondCounter();
|
|
|
|
|
|
|
|
auto* newComp = mouseSource.isTouch() ? nullptr : mouseSource.getComponentUnderMouse();
|
|
|
|
auto newTip = newComp != nullptr ? getTipFor (*newComp) : String();
|
|
|
|
bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse);
|
|
|
|
lastComponentUnderMouse = newComp;
|
|
|
|
lastTipUnderMouse = newTip;
|
|
|
|
auto* parent = getParentComponent();
|
|
|
|
|
|
|
|
auto clickCount = desktop.getMouseButtonClickCounter();
|
|
|
|
auto wheelCount = desktop.getMouseWheelMoveCounter();
|
|
|
|
bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves);
|
|
|
|
mouseClicks = clickCount;
|
|
|
|
mouseWheelMoves = wheelCount;
|
|
|
|
if (newComp == nullptr || parent == nullptr || parent == newComp || parent->isParentOf (newComp))
|
|
|
|
{
|
|
|
|
auto newTip = newComp != nullptr ? getTipFor (*newComp) : String();
|
|
|
|
bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse);
|
|
|
|
lastComponentUnderMouse = newComp;
|
|
|
|
lastTipUnderMouse = newTip;
|
|
|
|
|
|
|
|
auto mousePos = mouseSource.getScreenPosition();
|
|
|
|
bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
|
|
|
|
lastMousePos = mousePos;
|
|
|
|
auto clickCount = desktop.getMouseButtonClickCounter();
|
|
|
|
auto wheelCount = desktop.getMouseWheelMoveCounter();
|
|
|
|
bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves);
|
|
|
|
mouseClicks = clickCount;
|
|
|
|
mouseWheelMoves = wheelCount;
|
|
|
|
|
|
|
|
if (tipChanged || mouseWasClicked || mouseMovedQuickly)
|
|
|
|
lastCompChangeTime = now;
|
|
|
|
auto mousePos = mouseSource.getScreenPosition();
|
|
|
|
bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
|
|
|
|
lastMousePos = mousePos;
|
|
|
|
|
|
|
|
if (isVisible() || now < lastHideTime + 500)
|
|
|
|
{
|
|
|
|
// if a tip is currently visible (or has just disappeared), update to a new one
|
|
|
|
// immediately if needed..
|
|
|
|
if (newComp == nullptr || mouseWasClicked || newTip.isEmpty())
|
|
|
|
if (tipChanged || mouseWasClicked || mouseMovedQuickly)
|
|
|
|
lastCompChangeTime = now;
|
|
|
|
|
|
|
|
if (isVisible() || now < lastHideTime + 500)
|
|
|
|
{
|
|
|
|
if (isVisible())
|
|
|
|
// if a tip is currently visible (or has just disappeared), update to a new one
|
|
|
|
// immediately if needed..
|
|
|
|
if (newComp == nullptr || mouseWasClicked || newTip.isEmpty())
|
|
|
|
{
|
|
|
|
lastHideTime = now;
|
|
|
|
hideTip();
|
|
|
|
if (isVisible())
|
|
|
|
{
|
|
|
|
lastHideTime = now;
|
|
|
|
hideTip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (tipChanged)
|
|
|
|
{
|
|
|
|
displayTip (mousePos.roundToInt(), newTip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (tipChanged)
|
|
|
|
{
|
|
|
|
displayTip (mousePos.roundToInt(), newTip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if there isn't currently a tip, but one is needed, only let it
|
|
|
|
// appear after a timeout..
|
|
|
|
if (newTip.isNotEmpty()
|
|
|
|
&& newTip != tipShowing
|
|
|
|
&& now > lastCompChangeTime + (uint32) millisecondsBeforeTipAppears)
|
|
|
|
else
|
|
|
|
{
|
|
|
|
displayTip (mousePos.roundToInt(), newTip);
|
|
|
|
// if there isn't currently a tip, but one is needed, only let it
|
|
|
|
// appear after a timeout..
|
|
|
|
if (newTip.isNotEmpty()
|
|
|
|
&& newTip != tipShowing
|
|
|
|
&& now > lastCompChangeTime + (uint32) millisecondsBeforeTipAppears)
|
|
|
|
{
|
|
|
|
displayTip (mousePos.roundToInt(), newTip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|