|
|
@@ -24,22 +24,18 @@ |
|
|
==============================================================================
|
|
|
==============================================================================
|
|
|
*/
|
|
|
*/
|
|
|
|
|
|
|
|
|
TooltipWindow::TooltipWindow (Component* const parentComp, const int delayMs)
|
|
|
|
|
|
|
|
|
TooltipWindow::TooltipWindow (Component* parentComp, int delayMs)
|
|
|
: Component ("tooltip"),
|
|
|
: Component ("tooltip"),
|
|
|
lastComponentUnderMouse (nullptr),
|
|
|
|
|
|
millisecondsBeforeTipAppears (delayMs),
|
|
|
|
|
|
mouseClicks (0), mouseWheelMoves (0),
|
|
|
|
|
|
lastCompChangeTime (0), lastHideTime (0),
|
|
|
|
|
|
reentrant (false)
|
|
|
|
|
|
|
|
|
millisecondsBeforeTipAppears (delayMs)
|
|
|
{
|
|
|
{
|
|
|
if (Desktop::getInstance().getMainMouseSource().canHover())
|
|
|
|
|
|
startTimer (123);
|
|
|
|
|
|
|
|
|
|
|
|
setAlwaysOnTop (true);
|
|
|
setAlwaysOnTop (true);
|
|
|
setOpaque (true);
|
|
|
setOpaque (true);
|
|
|
|
|
|
|
|
|
if (parentComp != nullptr)
|
|
|
if (parentComp != nullptr)
|
|
|
parentComp->addChildComponent (this);
|
|
|
parentComp->addChildComponent (this);
|
|
|
|
|
|
|
|
|
|
|
|
if (Desktop::getInstance().getMainMouseSource().canHover())
|
|
|
|
|
|
startTimer (123);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
TooltipWindow::~TooltipWindow()
|
|
|
TooltipWindow::~TooltipWindow()
|
|
|
@@ -102,14 +98,13 @@ void TooltipWindow::displayTip (Point<int> screenPos, const String& tip) |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
String TooltipWindow::getTipFor (Component* const c)
|
|
|
|
|
|
|
|
|
String TooltipWindow::getTipFor (Component& c)
|
|
|
{
|
|
|
{
|
|
|
if (c != nullptr
|
|
|
|
|
|
&& Process::isForegroundProcess()
|
|
|
|
|
|
|
|
|
if (Process::isForegroundProcess()
|
|
|
&& ! ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown())
|
|
|
&& ! ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown())
|
|
|
{
|
|
|
{
|
|
|
if (TooltipClient* const ttc = dynamic_cast<TooltipClient*> (c))
|
|
|
|
|
|
if (! c->isCurrentlyBlockedByAnotherModalComponent())
|
|
|
|
|
|
|
|
|
if (auto* ttc = dynamic_cast<TooltipClient*> (&c))
|
|
|
|
|
|
if (! c.isCurrentlyBlockedByAnotherModalComponent())
|
|
|
return ttc->getTooltip();
|
|
|
return ttc->getTooltip();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -128,24 +123,24 @@ void TooltipWindow::hideTip() |
|
|
|
|
|
|
|
|
void TooltipWindow::timerCallback()
|
|
|
void TooltipWindow::timerCallback()
|
|
|
{
|
|
|
{
|
|
|
Desktop& desktop = Desktop::getInstance();
|
|
|
|
|
|
const MouseInputSource mouseSource (desktop.getMainMouseSource());
|
|
|
|
|
|
const unsigned int now = Time::getApproximateMillisecondCounter();
|
|
|
|
|
|
|
|
|
auto& desktop = Desktop::getInstance();
|
|
|
|
|
|
auto mouseSource = desktop.getMainMouseSource();
|
|
|
|
|
|
auto now = Time::getApproximateMillisecondCounter();
|
|
|
|
|
|
|
|
|
Component* const newComp = ! mouseSource.isTouch() ? mouseSource.getComponentUnderMouse() : nullptr;
|
|
|
|
|
|
const String newTip (getTipFor (newComp));
|
|
|
|
|
|
const bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse);
|
|
|
|
|
|
|
|
|
auto* newComp = mouseSource.isTouch() ? nullptr : mouseSource.getComponentUnderMouse();
|
|
|
|
|
|
auto newTip = newComp != nullptr ? getTipFor (*newComp) : String();
|
|
|
|
|
|
bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse);
|
|
|
lastComponentUnderMouse = newComp;
|
|
|
lastComponentUnderMouse = newComp;
|
|
|
lastTipUnderMouse = newTip;
|
|
|
lastTipUnderMouse = newTip;
|
|
|
|
|
|
|
|
|
const int clickCount = desktop.getMouseButtonClickCounter();
|
|
|
|
|
|
const int wheelCount = desktop.getMouseWheelMoveCounter();
|
|
|
|
|
|
const bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves);
|
|
|
|
|
|
|
|
|
auto clickCount = desktop.getMouseButtonClickCounter();
|
|
|
|
|
|
auto wheelCount = desktop.getMouseWheelMoveCounter();
|
|
|
|
|
|
bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves);
|
|
|
mouseClicks = clickCount;
|
|
|
mouseClicks = clickCount;
|
|
|
mouseWheelMoves = wheelCount;
|
|
|
mouseWheelMoves = wheelCount;
|
|
|
|
|
|
|
|
|
const Point<float> mousePos (mouseSource.getScreenPosition());
|
|
|
|
|
|
const bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
|
|
|
|
|
|
|
|
|
auto mousePos = mouseSource.getScreenPosition();
|
|
|
|
|
|
bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
|
|
|
lastMousePos = mousePos;
|
|
|
lastMousePos = mousePos;
|
|
|
|
|
|
|
|
|
if (tipChanged || mouseWasClicked || mouseMovedQuickly)
|
|
|
if (tipChanged || mouseWasClicked || mouseMovedQuickly)
|
|
|
@@ -174,7 +169,7 @@ void TooltipWindow::timerCallback() |
|
|
// appear after a timeout..
|
|
|
// appear after a timeout..
|
|
|
if (newTip.isNotEmpty()
|
|
|
if (newTip.isNotEmpty()
|
|
|
&& newTip != tipShowing
|
|
|
&& newTip != tipShowing
|
|
|
&& now > lastCompChangeTime + (unsigned int) millisecondsBeforeTipAppears)
|
|
|
|
|
|
|
|
|
&& now > lastCompChangeTime + (uint32) millisecondsBeforeTipAppears)
|
|
|
{
|
|
|
{
|
|
|
displayTip (mousePos.roundToInt(), newTip);
|
|
|
displayTip (mousePos.roundToInt(), newTip);
|
|
|
}
|
|
|
}
|
|
|
|