mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fix tooltips rendering when they shouldn't, fixes #5035
This commit is contained in:
parent
787224a2a7
commit
4b25f8d63e
|
@ -33,13 +33,17 @@ void CTooltips::DoToolTip(const void *pID, const CUIRect *pNearRect, const char
|
||||||
const auto result = m_Tooltips.emplace(ID, CTooltip{
|
const auto result = m_Tooltips.emplace(ID, CTooltip{
|
||||||
*pNearRect,
|
*pNearRect,
|
||||||
pText,
|
pText,
|
||||||
WidthHint});
|
WidthHint,
|
||||||
|
false});
|
||||||
CTooltip &Tooltip = result.first->second;
|
CTooltip &Tooltip = result.first->second;
|
||||||
|
|
||||||
if(!result.second)
|
if(!result.second)
|
||||||
{
|
{
|
||||||
Tooltip.m_Rect = *pNearRect; // update in case of window resize
|
Tooltip.m_Rect = *pNearRect; // update in case of window resize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tooltip.m_OnScreen = true;
|
||||||
|
|
||||||
if(UI()->MouseInside(&Tooltip.m_Rect))
|
if(UI()->MouseInside(&Tooltip.m_Rect))
|
||||||
{
|
{
|
||||||
SetActiveTooltip(Tooltip);
|
SetActiveTooltip(Tooltip);
|
||||||
|
@ -54,10 +58,14 @@ void CTooltips::OnRender()
|
||||||
|
|
||||||
if(!UI()->MouseInside(&Tooltip.m_Rect))
|
if(!UI()->MouseInside(&Tooltip.m_Rect))
|
||||||
{
|
{
|
||||||
|
Tooltip.m_OnScreen = false;
|
||||||
ClearActiveTooltip();
|
ClearActiveTooltip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!Tooltip.m_OnScreen)
|
||||||
|
return;
|
||||||
|
|
||||||
// Delay tooltip until 1 second passed.
|
// Delay tooltip until 1 second passed.
|
||||||
if(HoverTime > time_get() - time_freq())
|
if(HoverTime > time_get() - time_freq())
|
||||||
return;
|
return;
|
||||||
|
@ -100,5 +108,6 @@ void CTooltips::OnRender()
|
||||||
RenderTools()->DrawUIRect(&Rect, ColorRGBA(0.2, 0.2, 0.2, 0.80f), CUI::CORNER_ALL, 5.0f);
|
RenderTools()->DrawUIRect(&Rect, ColorRGBA(0.2, 0.2, 0.2, 0.80f), CUI::CORNER_ALL, 5.0f);
|
||||||
Rect.Margin(2.0f, &Rect);
|
Rect.Margin(2.0f, &Rect);
|
||||||
UI()->DoLabel(&Rect, Tooltip.m_pText, 14.0f, TEXTALIGN_LEFT);
|
UI()->DoLabel(&Rect, Tooltip.m_pText, 14.0f, TEXTALIGN_LEFT);
|
||||||
|
Tooltip.m_OnScreen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ struct CTooltip
|
||||||
CUIRect m_Rect;
|
CUIRect m_Rect;
|
||||||
const char *m_pText;
|
const char *m_pText;
|
||||||
float m_WidthHint;
|
float m_WidthHint;
|
||||||
|
bool m_OnScreen; // used to know if the tooltip should be rendered.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue