Fix tooltip locations after window resize (fixes #5026)

This commit is contained in:
Dennis Felsing 2022-04-27 00:51:02 +02:00
parent 6270b1c11d
commit c174274edc

View file

@ -30,32 +30,19 @@ inline void CTooltips::ClearActiveTooltip()
void CTooltips::DoToolTip(const void *pID, const CUIRect *pNearRect, const char *pText, float WidthHint) void CTooltips::DoToolTip(const void *pID, const CUIRect *pNearRect, const char *pText, float WidthHint)
{ {
uintptr_t ID = reinterpret_cast<uintptr_t>(pID); uintptr_t ID = reinterpret_cast<uintptr_t>(pID);
const auto result = m_Tooltips.emplace(ID, CTooltip{
*pNearRect,
pText,
WidthHint});
CTooltip &Tooltip = result.first->second;
const auto &it = m_Tooltips.find(ID); if(!result.second)
if(it == m_Tooltips.end())
{ {
CTooltip NewTooltip = { Tooltip.m_Rect = *pNearRect; // update in case of window resize
*pNearRect,
pText,
WidthHint,
};
m_Tooltips[ID] = NewTooltip;
CTooltip &Tooltip = m_Tooltips[ID];
if(UI()->MouseInside(&Tooltip.m_Rect))
{
SetActiveTooltip(Tooltip);
}
} }
else if(UI()->MouseInside(&Tooltip.m_Rect))
{ {
if(UI()->MouseInside(&it->second.m_Rect)) SetActiveTooltip(Tooltip);
{
SetActiveTooltip(it->second);
}
} }
} }