Make inventory thumbnail tooltips work with inventory lists

master
Ansariel 2023-12-09 02:04:41 +01:00
parent 4ffe206285
commit d7eaff4a32
1 changed files with 32 additions and 0 deletions

View File

@ -41,6 +41,10 @@
#include "llinventorymodel.h"
#include "llviewerinventory.h"
#include "llinspecttexture.h"
#include "lltooltip.h"
#include "llviewercontrol.h"
static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelInventoryListItemBaseParams(&typeid(LLPanelInventoryListItemBase::Params), "inventory_list_item");
static const S32 WIDGET_SPACING = 3;
@ -419,6 +423,34 @@ void LLPanelInventoryListItemBase::setTitle(const std::string& title,
BOOL LLPanelInventoryListItemBase::handleToolTip( S32 x, S32 y, MASK mask)
{
LLRect text_box_rect = mTitleCtrl->getRect();
// <FS:Ansariel> Make inventory thumbnail tooltips work with inventory lists
static LLCachedControl<bool> showInventoryThumbnailTooltips(gSavedSettings, "FSShowInventoryThumbnailTooltips");
if (showInventoryThumbnailTooltips && text_box_rect.pointInRect(x, y))
{
if (auto inventoryItem = gInventory.getItem(mInventoryItemUUID); inventoryItem)
{
static LLCachedControl<F32> inventoryThumbnailTooltipsDelay(gSavedSettings, "FSInventoryThumbnailTooltipsDelay");
static LLCachedControl<F32> tooltip_fast_delay(gSavedSettings, "ToolTipFastDelay");
F32 tooltipDelay = LLToolTipMgr::instance().toolTipVisible() ? tooltip_fast_delay() : inventoryThumbnailTooltipsDelay();
if (const LLUUID& thumbnailUUID = inventoryItem->getThumbnailUUID(); !thumbnailUUID.isNull())
{
LLSD params;
params["thumbnail_id"] = thumbnailUUID;
LLToolTipMgr::instance().show(LLToolTip::Params()
.message(inventoryItem->getName())
.sticky_rect(calcScreenRect())
.delay_time(tooltipDelay)
.create_callback(boost::bind(&LLInspectTextureUtil::createInventoryToolTip, _1))
.create_params(params));
return TRUE;
}
}
}
// </FS:Ansariel>
if (text_box_rect.pointInRect(x, y) &&
mTitleCtrl->getTextPixelWidth() <= text_box_rect.getWidth())
{