diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-02-01 00:35:22 +0200 | 
|---|---|---|
| committer | akleshchev <117672381+akleshchev@users.noreply.github.com> | 2023-02-01 16:38:47 +0200 | 
| commit | 6ada89ce0b9372d6a7f49ac45bad6713ad5d3355 (patch) | |
| tree | 7e9f024aa51b30a03b7b6490f13c5259b9e4f8bc | |
| parent | aa6c7902af2ab2cc10bc86000a91078edafb522f (diff) | |
SL-19117 Extend texture preview to show thumbnails when present
| -rw-r--r-- | indra/llui/llview.cpp | 20 | ||||
| -rw-r--r-- | indra/llui/llview.h | 1 | ||||
| -rw-r--r-- | indra/newview/llinspecttexture.cpp | 49 | ||||
| -rw-r--r-- | indra/newview/llinventorypanel.cpp | 12 | ||||
| -rw-r--r-- | indra/newview/llviewertexteditor.cpp | 9 | 
5 files changed, 54 insertions, 37 deletions
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 9ba71913d0..10e4755cd3 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -877,6 +877,17 @@ LLView*	LLView::childFromPoint(S32 x, S32 y, bool recur)  	return 0;  } +F32 LLView::getTooltipTimeout() +{ +    static LLCachedControl<F32> tooltip_fast_delay(*LLUI::getInstance()->mSettingGroups["config"], "ToolTipFastDelay", 0.1f); +    static LLCachedControl<F32> tooltip_delay(*LLUI::getInstance()->mSettingGroups["config"], "ToolTipDelay", 0.7f); +    // allow "scrubbing" over ui by showing next tooltip immediately +    // if previous one was still visible +    return (F32)(LLToolTipMgr::instance().toolTipVisible() +    ? tooltip_fast_delay +    : tooltip_delay); +} +  BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask)  {  	BOOL handled = FALSE; @@ -886,14 +897,7 @@ BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask)  	std::string tooltip = getToolTip();  	if (!tooltip.empty())  	{ -        static LLCachedControl<F32> tooltip_fast_delay(*LLUI::getInstance()->mSettingGroups["config"], "ToolTipFastDelay", 0.1f); -        static LLCachedControl<F32> tooltip_delay(*LLUI::getInstance()->mSettingGroups["config"], "ToolTipDelay", 0.7f);          static LLCachedControl<bool> allow_ui_tooltips(*LLUI::getInstance()->mSettingGroups["config"], "BasicUITooltips", true); -		// allow "scrubbing" over ui by showing next tooltip immediately -		// if previous one was still visible -		F32 timeout = LLToolTipMgr::instance().toolTipVisible()  -		              ? tooltip_fast_delay -		              : tooltip_delay;  		// Even if we don't show tooltips, consume the event, nothing below should show tooltip  		if (allow_ui_tooltips) @@ -901,7 +905,7 @@ BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask)  			LLToolTipMgr::instance().show(LLToolTip::Params()  			                              .message(tooltip)  			                              .sticky_rect(calcScreenRect()) -			                              .delay_time(timeout)); +			                              .delay_time(getTooltipTimeout()));  		}  		handled = TRUE;  	} diff --git a/indra/llui/llview.h b/indra/llui/llview.h index bec45df78a..444a4c3cb5 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -243,6 +243,7 @@ public:  	ECursorType	getHoverCursor() { return mHoverCursor; } +    static F32 getTooltipTimeout();  	virtual const std::string getToolTip() const			{ return mToolTipMsg.getString(); }  	void		sendChildToFront(LLView* child); diff --git a/indra/newview/llinspecttexture.cpp b/indra/newview/llinspecttexture.cpp index cd288e9603..af96561c45 100644 --- a/indra/newview/llinspecttexture.cpp +++ b/indra/newview/llinspecttexture.cpp @@ -136,14 +136,17 @@ BOOL LLInspectTexture::postBuild()  LLToolTip* LLInspectTextureUtil::createInventoryToolTip(LLToolTip::Params p)  { -	const LLSD& sdTooltip = p.create_params; +    const LLSD& sdTooltip = p.create_params; +     +    if (sdTooltip.has("thumbnail_id")) +    { +        // go straight for tooltip regardless of type +        return LLUICtrlFactory::create<LLTextureToolTip>(p); +    }  	LLInventoryType::EType eInvType = (sdTooltip.has("inv_type")) ? (LLInventoryType::EType)sdTooltip["inv_type"].asInteger() : LLInventoryType::IT_NONE;  	switch (eInvType)  	{ -		case LLInventoryType::IT_SNAPSHOT: -		case LLInventoryType::IT_TEXTURE: -			return LLUICtrlFactory::create<LLTextureToolTip>(p);  		case LLInventoryType::IT_CATEGORY:  			{  				if (sdTooltip.has("item_id")) @@ -277,23 +280,27 @@ LLTextureToolTip::~LLTextureToolTip()  void LLTextureToolTip::initFromParams(const LLToolTip::Params& p)  { -	LLToolTip::initFromParams(p); - -	// Create and add the preview control -	LLView::Params p_preview; -	p_preview.name = "texture_preview"; -	LLRect rctPreview; -	rctPreview.setOriginAndSize(mPadding, mTextBox->getRect().mTop, mPreviewSize, mPreviewSize); -	p_preview.rect = rctPreview; -	mPreviewView = LLUICtrlFactory::create<LLTexturePreviewView>(p_preview); -	addChild(mPreviewView); - -	// Parse the control params -	const LLSD& sdTextureParams = p.create_params; -	if (sdTextureParams.has("asset_id")) -		mPreviewView->setImageFromAssetId(sdTextureParams["asset_id"].asUUID()); -	else if (sdTextureParams.has("item_id")) -		mPreviewView->setImageFromItemId(sdTextureParams["item_id"].asUUID()); +    LLToolTip::initFromParams(p); +     +    // Create and add the preview control +    LLView::Params p_preview; +    p_preview.name = "texture_preview"; +    LLRect rctPreview; +    rctPreview.setOriginAndSize(mPadding, mTextBox->getRect().mTop, mPreviewSize, mPreviewSize); +    p_preview.rect = rctPreview; +    mPreviewView = LLUICtrlFactory::create<LLTexturePreviewView>(p_preview); +    addChild(mPreviewView); +     +    // Parse the control params +    const LLSD& sdTextureParams = p.create_params; +    if (sdTextureParams.has("thumbnail_id")) +    { +        mPreviewView->setImageFromAssetId(sdTextureParams["thumbnail_id"].asUUID()); +    } +    else if (sdTextureParams.has("item_id")) +    { +        mPreviewView->setImageFromItemId(sdTextureParams["item_id"].asUUID()); +    }  	snapToChildren();  } diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index dabe633b8c..d6f4b8f103 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -1285,16 +1285,16 @@ BOOL LLInventoryPanel::handleToolTip(S32 x, S32 y, MASK mask)  	{  		if (const LLFolderViewModelItemInventory* vm_item_p = static_cast<const LLFolderViewModelItemInventory*>(hover_item_p->getViewModelItem()))  		{ -			// Copy/pasted from LLView::handleToolTip() -			F32 nTimeout = LLToolTipMgr::instance().toolTipVisible() -					? LLUI::getInstance()->mSettingGroups["config"]->getF32("ToolTipFastDelay") -					: LLUI::getInstance()->mSettingGroups["config"]->getF32("ToolTipDelay"); +            LLSD params; +            params["inv_type"] = vm_item_p->getInventoryType(); +            params["item_id"] = vm_item_p->getUUID(); +              			LLToolTipMgr::instance().show(LLToolTip::Params()  					.message(hover_item_p->getToolTip())  					.sticky_rect(hover_item_p->calcScreenRect()) -					.delay_time(nTimeout) +					.delay_time(LLView::getTooltipTimeout())  					.create_callback(boost::bind(&LLInspectTextureUtil::createInventoryToolTip, _1)) -					.create_params(LLSD().with("inv_type", vm_item_p->getInventoryType()).with("item_id", vm_item_p->getUUID()))); +					.create_params(params));  			return TRUE;  		}  	} diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 299047d91b..13505a2cf3 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -246,12 +246,17 @@ public:  	}  	virtual BOOL				handleToolTip(S32 x, S32 y, MASK mask )  	{  -		if (LLAssetType::AT_TEXTURE == mItem->getType()) +		if (mItem->getThumbnailUUID().notNull())  		{ +            LLSD params; +            params["inv_type"] = mItem->getInventoryType(); +            params["thumbnail_id"] = mItem->getThumbnailUUID(); +            params["asset_id"] = mItem->getAssetUUID(); +              			LLToolTipMgr::instance().show(LLToolTip::Params()  					.message(mToolTip)  					.create_callback(boost::bind(&LLInspectTextureUtil::createInventoryToolTip, _1)) -					.create_params(LLSD().with("inv_type", mItem->getInventoryType()).with("asset_id", mItem->getAssetUUID()))); +					.create_params(params));  			return TRUE;  		}  | 
