diff options
Diffstat (limited to 'indra/newview/llinspectobject.cpp')
| -rw-r--r-- | indra/newview/llinspectobject.cpp | 173 | 
1 files changed, 155 insertions, 18 deletions
| diff --git a/indra/newview/llinspectobject.cpp b/indra/newview/llinspectobject.cpp index 29cca14a7b..91cbbbf430 100644 --- a/indra/newview/llinspectobject.cpp +++ b/indra/newview/llinspectobject.cpp @@ -35,10 +35,13 @@  // Viewer  #include "llinspect.h" -#include "llnotifications.h"	// *TODO: Eliminate, add LLNotificationsUtil wrapper +#include "llmediaentry.h" +#include "llnotificationsutil.h"	// *TODO: Eliminate, add LLNotificationsUtil wrapper  #include "llselectmgr.h"  #include "llslurl.h"  #include "llviewermenu.h"		// handle_object_touch(), handle_buy() +#include "llviewermedia.h" +#include "llviewermediafocus.h"  #include "llviewerobjectlist.h"	// to select the requested object  // Linden libraries @@ -48,6 +51,7 @@  #include "llmenubutton.h"  #include "llresmgr.h"			// getMonetaryString  #include "llsafehandle.h" +#include "llsidetray.h"  #include "lltextbox.h"			// for description truncation  #include "lltrans.h"  #include "llui.h"				// positionViewNearMouse() @@ -80,6 +84,10 @@ public:  	// Release the selection and do other cleanup  	/*virtual*/ void onClose(bool app_quitting); +	// override the inspector mouse leave so timer is only paused if  +	// gear menu is not open +	/* virtual */ void onMouseLeave(S32 x, S32 y, MASK mask); +	  private:  	// Refresh displayed data with information from selection manager  	void update(); @@ -92,8 +100,10 @@ private:  	void updateName(LLSelectNode* nodep);  	void updateDescription(LLSelectNode* nodep);  	void updatePrice(LLSelectNode* nodep); -	  	void updateCreator(LLSelectNode* nodep); +	 +	void updateMediaCurrentURL();	 +	void updateSecureBrowsing();  	void onClickBuy();  	void onClickPay(); @@ -106,13 +116,19 @@ private:  private:  	LLUUID				mObjectID; +	S32					mObjectFace; +	viewer_media_t		mMediaImpl; +	LLMediaEntry*       mMediaEntry;  	LLSafeHandle<LLObjectSelection> mObjectSelection;  };  LLInspectObject::LLInspectObject(const LLSD& sd)  :	LLInspect( LLSD() ),	// single_instance, doesn't really need key -	mObjectID(),			// set in onOpen() -	mObjectSelection() +	mObjectID(NULL),			// set in onOpen() +	mObjectFace(0), +	mObjectSelection(NULL), +	mMediaImpl(NULL), +	mMediaEntry(NULL)  {  	// can't make the properties request until the widgets are constructed  	// as it might return immediately, so do it in postBuild. @@ -139,7 +155,7 @@ BOOL LLInspectObject::postBuild(void)  	getChild<LLUICtrl>("object_name")->setValue("");  	getChild<LLUICtrl>("object_creator")->setValue("");  	getChild<LLUICtrl>("object_description")->setValue(""); - +	getChild<LLUICtrl>("object_media_url")->setValue("");  	// Set buttons invisible until we know what this object can do  	hideButtons(); @@ -171,7 +187,6 @@ BOOL LLInspectObject::postBuild(void)  	return TRUE;  } -  // Multiple calls to showInstance("inspect_avatar", foo) will provide different  // LLSD for foo, which we will catch here.  //virtual @@ -182,7 +197,11 @@ void LLInspectObject::onOpen(const LLSD& data)  	// Extract appropriate avatar id  	mObjectID = data["object_id"]; - +	 +	if(data.has("object_face")) +	{ +		mObjectFace = data["object_face"]; +	}  	// Position the inspector relative to the mouse cursor  	// Similar to how tooltips are positioned  	// See LLToolTipMgr::createToolTip @@ -200,6 +219,10 @@ void LLInspectObject::onOpen(const LLSD& data)  	LLViewerObject* obj = gObjectList.findObject( mObjectID );  	if (obj)  	{ +		// Media focus and this code fight over the select manager.   +		// Make sure any media is unfocused before changing the selection here. +		LLViewerMediaFocus::getInstance()->clearFocus(); +		  		LLSelectMgr::instance().deselectAll();  		mObjectSelection = LLSelectMgr::instance().selectObjectAndFamily(obj); @@ -213,6 +236,17 @@ void LLInspectObject::onOpen(const LLSD& data)  			}  		} functor;  		mObjectSelection->applyToNodes(&functor); +		 +		// Does this face have media? +		const LLTextureEntry* tep = obj->getTE(mObjectFace); +		if (!tep) +			return; +		 +		mMediaEntry = tep->hasMedia() ? tep->getMediaData() : NULL; +		if(!mMediaEntry) +			return; +		 +		mMediaImpl = LLViewerMedia::getMediaImplFromTextureID(mMediaEntry->getMediaID());  	}  } @@ -243,6 +277,30 @@ void LLInspectObject::update()  	updateDescription(nodep);  	updateCreator(nodep);  	updatePrice(nodep); +	 +	LLViewerObject* obj = nodep->getObject(); +	if(!obj) +		return; +	 +	if ( mObjectFace < 0  +		||  mObjectFace >= obj->getNumTEs() ) +	{ +		return; +	} +	 +	// Does this face have media? +	const LLTextureEntry* tep = obj->getTE(mObjectFace); +	if (!tep) +		return; +	 +	mMediaEntry = tep->hasMedia() ? tep->getMediaData() : NULL; +	if(!mMediaEntry) +		return; +	 +	mMediaImpl = LLViewerMedia::getMediaImplFromTextureID(mMediaEntry->getMediaID()); +	 +	updateMediaCurrentURL(); +	updateSecureBrowsing();  }  void LLInspectObject::hideButtons() @@ -367,18 +425,45 @@ void LLInspectObject::updateDescription(LLSelectNode* nodep)  	LLTextBox* textbox = getChild<LLTextBox>("object_description");  	textbox->setValue(desc); +} -	// Truncate description text to fit in widget -	// *HACK: OMG, use lower-left corner to truncate text -	// Don't round the position, we want the left of the character -	S32 corner_index = textbox->getDocIndexFromLocalCoord( 0, 0, FALSE); -	LLWString desc_wide = textbox->getWText(); -	// index == length if position is past last character -	if (corner_index < (S32)desc_wide.length()) +void LLInspectObject::updateMediaCurrentURL() +{	 +	if(!mMediaEntry) +		return; +	LLTextBox* textbox = getChild<LLTextBox>("object_media_url"); +	std::string media_url = ""; +	textbox->setValue(media_url); +	textbox->setToolTip(media_url); +	LLStringUtil::format_map_t args; +	 +	if(mMediaImpl.notNull() && mMediaImpl->hasMedia())  	{ -		desc_wide = desc_wide.substr(0, corner_index); -		textbox->setWText(desc_wide); +		 +		LLPluginClassMedia* media_plugin = NULL; +		media_plugin = mMediaImpl->getMediaPlugin(); +		if(media_plugin) +		{ +			if(media_plugin->pluginSupportsMediaTime()) +			{ +				args["[CurrentURL]"] =  mMediaImpl->getMediaURL(); +			} +			else +			{ +				args["[CurrentURL]"] =  media_plugin->getLocation(); +			} +			media_url = LLTrans::getString("CurrentURL", args); + +		} +	} +	else if(mMediaEntry->getCurrentURL() != "") +	{ +		args["[CurrentURL]"] = mMediaEntry->getCurrentURL(); +		media_url = LLTrans::getString("CurrentURL", args);  	} + +	textbox->setText(media_url); +	textbox->setToolTip(media_url);  }  void LLInspectObject::updateCreator(LLSelectNode* nodep) @@ -453,6 +538,57 @@ void LLInspectObject::updatePrice(LLSelectNode* nodep)  	getChild<LLUICtrl>("price_icon")->setVisible(show_price_icon);  } +void LLInspectObject::updateSecureBrowsing() +{ +	bool is_secure_browsing = false; +	 +	if(mMediaImpl.notNull()  +	   && mMediaImpl->hasMedia()) +	{ +		LLPluginClassMedia* media_plugin = NULL; +		std::string current_url = ""; +		media_plugin = mMediaImpl->getMediaPlugin(); +		if(media_plugin) +		{ +			if(media_plugin->pluginSupportsMediaTime()) +			{ +				current_url = mMediaImpl->getMediaURL(); +			} +			else +			{ +				current_url =  media_plugin->getLocation(); +			} +		} +		 +		std::string prefix =  std::string("https://"); +		std::string test_prefix = current_url.substr(0, prefix.length()); +		LLStringUtil::toLower(test_prefix);	 +		if(test_prefix == prefix) +		{ +			is_secure_browsing = true; +		} +	} +	getChild<LLUICtrl>("secure_browsing")->setVisible(is_secure_browsing); +} + +// For the object inspector, only unpause the fade timer  +// if the gear menu is not open +void LLInspectObject::onMouseLeave(S32 x, S32 y, MASK mask) +{ +	LLMenuGL* gear_menu = getChild<LLMenuButton>("gear_btn")->getMenu(); +	if ( gear_menu && gear_menu->getVisible() ) +	{ +		return; +	} + +	if(childHasVisiblePopupMenu()) +	{ +		return; +	} + +	mOpenTimer.unpause(); +} +  void LLInspectObject::onClickBuy()  {  	handle_buy(); @@ -508,8 +644,9 @@ void LLInspectObject::onClickOpen()  void LLInspectObject::onClickMoreInfo()  { -	// *TODO: Show object info side panel, once that is implemented. -	LLNotifications::instance().add("ClickUnimplemented"); +	LLSD key; +	key["task"] = "task"; +	LLSideTray::getInstance()->showPanel("sidepanel_inventory", key);	  	closeFloater();  } | 
