summaryrefslogtreecommitdiff
path: root/indra/newview/lltoolpie.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltoolpie.cpp')
-rw-r--r--indra/newview/lltoolpie.cpp265
1 files changed, 216 insertions, 49 deletions
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index b015f668e4..304f1dffaf 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -48,6 +48,7 @@
#include "lltooltip.h"
#include "llhudeffecttrail.h"
#include "llhudmanager.h"
+#include "llkeyboard.h"
#include "llmediaentry.h"
#include "llmenugl.h"
#include "llmutelist.h"
@@ -518,11 +519,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
if(!object)
{
- // We need to clear media hover flag
- if (LLViewerMediaFocus::getInstance()->getMouseOverFlag())
- {
- LLViewerMediaFocus::getInstance()->setMouseOverFlag(false);
- }
+ LLViewerMediaFocus::getInstance()->clearHover();
}
}
@@ -735,7 +732,47 @@ BOOL LLToolPie::handleToolTip(S32 local_x, S32 local_y, MASK mask)
{
tooltip_msg.append( nodep->mName );
}
-
+
+ bool is_time_based_media = false;
+ bool is_web_based_media = false;
+ bool is_media_playing = false;
+
+ // Does this face have media?
+ const LLTextureEntry* tep = hover_object->getTE(mHoverPick.mObjectFace);
+
+ if(tep)
+ {
+ const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL;
+ if (mep)
+ {
+ viewer_media_t media_impl = mep ? LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID()) : NULL;
+ LLPluginClassMedia* media_plugin = NULL;
+
+ if (media_impl.notNull() && (media_impl->hasMedia()))
+ {
+ LLStringUtil::format_map_t args;
+
+ media_plugin = media_impl->getMediaPlugin();
+ if(media_plugin)
+ { if(media_plugin->pluginSupportsMediaTime())
+ {
+ is_time_based_media = true;
+ is_web_based_media = false;
+ args["[CurrentURL]"] = media_impl->getMediaURL();
+ is_media_playing = media_impl->isMediaPlaying();
+ }
+ else
+ {
+ is_time_based_media = false;
+ is_web_based_media = true;
+ args["[CurrentURL]"] = media_plugin->getLocation();
+ }
+ //tooltip_msg.append(LLTrans::getString("CurrentURL", args));
+ }
+ }
+ }
+ }
+
bool needs_tip = needs_tooltip(nodep);
if (show_all_object_tips || needs_tip)
@@ -744,8 +781,13 @@ BOOL LLToolPie::handleToolTip(S32 local_x, S32 local_y, MASK mask)
mPick = mHoverPick;
LLToolTipMgr::instance().show(LLToolTip::Params()
.message(tooltip_msg)
- .image(LLUI::getUIImage("Info"))
- .click_callback(boost::bind(showObjectInspector, hover_object->getID()))
+ .image(LLUI::getUIImage("Info_Off"))
+ .click_callback(boost::bind(showObjectInspector, hover_object->getID(), mHoverPick.mObjectFace))
+ .time_based_media(is_time_based_media)
+ .web_based_media(is_web_based_media)
+ .media_playing(is_media_playing)
+ .click_playmedia_callback(boost::bind(playCurrentMedia, mHoverPick))
+ .click_homepage_callback(boost::bind(VisitHomePage, mHoverPick))
.visible_time_near(6.f)
.visible_time_far(3.f)
.wrap(false));
@@ -928,6 +970,20 @@ static void show_inspector(const char* inspector, const char* param, const LLUUI
LLFloaterReg::showInstance(inspector, params);
}
+
+static void show_inspector(const char* inspector, LLSD& params)
+{
+ if (LLToolTipMgr::instance().toolTipVisible())
+ {
+ LLRect rect = LLToolTipMgr::instance().getToolTipRect();
+ params["pos"]["x"] = rect.mLeft;
+ params["pos"]["y"] = rect.mTop;
+ }
+
+ LLFloaterReg::showInstance(inspector, params);
+}
+
+
// static
void LLToolPie::showAvatarInspector(const LLUUID& avatar_id)
{
@@ -940,6 +996,114 @@ void LLToolPie::showObjectInspector(const LLUUID& object_id)
show_inspector("inspect_object", "object_id", object_id);
}
+
+// static
+void LLToolPie::showObjectInspector(const LLUUID& object_id, const S32& object_face)
+{
+ LLSD params;
+ params["object_id"] = object_id;
+ params["object_face"] = object_face;
+ show_inspector("inspect_object", params);
+}
+
+// static
+void LLToolPie::playCurrentMedia(const LLPickInfo& info)
+{
+ //FIXME: how do we handle object in different parcel than us?
+ LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
+ if (!parcel) return;
+
+ LLPointer<LLViewerObject> objectp = info.getObject();
+
+ // Early out cases. Must clear media hover.
+ // did not hit an object or did not hit a valid face
+ if ( objectp.isNull() ||
+ info.mObjectFace < 0 ||
+ info.mObjectFace >= objectp->getNumTEs() )
+ {
+ return;
+ }
+
+ // Does this face have media?
+ const LLTextureEntry* tep = objectp->getTE(info.mObjectFace);
+ if (!tep)
+ return;
+
+ const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL;
+ if(!mep)
+ return;
+
+ LLPluginClassMedia* media_plugin = NULL;
+
+// if (gSavedSettings.getBOOL("MediaOnAPrimUI"))
+// {
+ viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
+
+ if(media_impl.notNull() && media_impl->hasMedia())
+ {
+ media_plugin = media_impl->getMediaPlugin();
+
+ if (media_plugin && media_plugin->pluginSupportsMediaTime())
+ {
+ if(media_impl->isMediaPlaying())
+ {
+ media_impl->pause();
+ }
+ else //if(media_impl->isMediaPaused())
+ {
+ media_impl->play();
+ }
+
+ }
+
+ }
+// }
+
+}
+
+// static
+void LLToolPie::VisitHomePage(const LLPickInfo& info)
+{
+ //FIXME: how do we handle object in different parcel than us?
+ LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
+ if (!parcel) return;
+
+ LLPointer<LLViewerObject> objectp = info.getObject();
+
+ // Early out cases. Must clear media hover.
+ // did not hit an object or did not hit a valid face
+ if ( objectp.isNull() ||
+ info.mObjectFace < 0 ||
+ info.mObjectFace >= objectp->getNumTEs() )
+ {
+ return;
+ }
+
+ // Does this face have media?
+ const LLTextureEntry* tep = objectp->getTE(info.mObjectFace);
+ if (!tep)
+ return;
+
+ const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL;
+ if(!mep)
+ return;
+
+ LLPluginClassMedia* media_plugin = NULL;
+
+ viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
+
+ if(media_impl.notNull() && media_impl->hasMedia())
+ {
+ media_plugin = media_impl->getMediaPlugin();
+
+ if (media_plugin && !(media_plugin->pluginSupportsMediaTime()))
+ {
+ media_impl->navigateHome();
+ }
+ }
+}
+
+
void LLToolPie::handleDeselect()
{
if( hasMouseCapture() )
@@ -1029,7 +1193,6 @@ bool LLToolPie::handleMediaClick(const LLPickInfo& pick)
pick.mObjectFace < 0 ||
pick.mObjectFace >= objectp->getNumTEs())
{
- LLSelectMgr::getInstance()->deselect();
LLViewerMediaFocus::getInstance()->clearFocus();
return false;
@@ -1037,29 +1200,31 @@ bool LLToolPie::handleMediaClick(const LLPickInfo& pick)
- // HACK: This is directly referencing an impl name. BAD!
- // This can be removed when we have a truly generic media browser that only
- // builds an impl based on the type of url it is passed.
-
- // is media playing on this face?
+ // Does this face have media?
const LLTextureEntry* tep = objectp->getTE(pick.mObjectFace);
+ if(!tep)
+ return false;
+
LLMediaEntry* mep = (tep->hasMedia()) ? tep->getMediaData() : NULL;
+
+ if(!mep)
+ return false;
+
viewer_media_t media_impl = mep ? LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID()) : NULL;
- if (tep
- && mep
- && gSavedSettings.getBOOL("MediaOnAPrimUI")
+ if (gSavedSettings.getBOOL("MediaOnAPrimUI")
&& media_impl.notNull())
{
- // LLObjectSelectionHandle selection = /*LLViewerMediaFocus::getInstance()->getSelection()*/ LLSelectMgr::getInstance()->getSelection();
- if (/*! selection->contains(pick.getObject(), pick.mObjectFace)*/
- ! LLViewerMediaFocus::getInstance()->isFocusedOnFace(pick.getObject(), pick.mObjectFace) )
+ if (!LLViewerMediaFocus::getInstance()->isFocusedOnFace(pick.getObject(), pick.mObjectFace) )
{
- LLViewerMediaFocus::getInstance()->setFocusFace(TRUE, pick.getObject(), pick.mObjectFace, media_impl);
+ LLViewerMediaFocus::getInstance()->setFocusFace(pick.getObject(), pick.mObjectFace, media_impl, pick.mNormal);
}
else
{
- media_impl->mouseDown(pick.mUVCoords);
+ // Make sure keyboard focus is set to the media focus object.
+ gFocusMgr.setKeyboardFocus(LLViewerMediaFocus::getInstance());
+
+ media_impl->mouseDown(pick.mUVCoords, gKeyboard->currentMask(TRUE));
mMediaMouseCaptureID = mep->getMediaID();
setMouseCapture(TRUE); // This object will send a mouse-up to the media when it loses capture.
}
@@ -1067,7 +1232,6 @@ bool LLToolPie::handleMediaClick(const LLPickInfo& pick)
return true;
}
- LLSelectMgr::getInstance()->deselect();
LLViewerMediaFocus::getInstance()->clearFocus();
return false;
@@ -1081,50 +1245,53 @@ bool LLToolPie::handleMediaHover(const LLPickInfo& pick)
LLPointer<LLViewerObject> objectp = pick.getObject();
- // Early out cases. Must clear mouse over media focus flag
+ // Early out cases. Must clear media hover.
// did not hit an object or did not hit a valid face
if ( objectp.isNull() ||
pick.mObjectFace < 0 ||
pick.mObjectFace >= objectp->getNumTEs() )
{
- LLViewerMediaFocus::getInstance()->setMouseOverFlag(false);
+ LLViewerMediaFocus::getInstance()->clearHover();
return false;
}
-
- // HACK: This is directly referencing an impl name. BAD!
- // This can be removed when we have a truly generic media browser that only
- // builds an impl based on the type of url it is passed.
-
- // is media playing on this face?
+ // Does this face have media?
const LLTextureEntry* tep = objectp->getTE(pick.mObjectFace);
+ if(!tep)
+ return false;
+
const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL;
if (mep
&& gSavedSettings.getBOOL("MediaOnAPrimUI"))
{
viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
- if(LLViewerMediaFocus::getInstance()->getFocus() && media_impl.notNull())
- {
- media_impl->mouseMove(pick.mUVCoords);
-
- gViewerWindow->setCursor(media_impl->getLastSetCursor());
- }
- else
+
+ if(media_impl.notNull())
{
- gViewerWindow->setCursor(UI_CURSOR_ARROW);
- }
+ // Update media hover object
+ if (!LLViewerMediaFocus::getInstance()->isHoveringOverFace(objectp, pick.mObjectFace))
+ {
+ LLViewerMediaFocus::getInstance()->setHoverFace(objectp, pick.mObjectFace, media_impl, pick.mNormal);
+ }
+
+ // If this is the focused media face, send mouse move events.
+ if (LLViewerMediaFocus::getInstance()->isFocusedOnFace(objectp, pick.mObjectFace))
+ {
+ media_impl->mouseMove(pick.mUVCoords, gKeyboard->currentMask(TRUE));
+ gViewerWindow->setCursor(media_impl->getLastSetCursor());
+ }
+ else
+ {
+ // This is not the focused face -- set the default cursor.
+ gViewerWindow->setCursor(UI_CURSOR_ARROW);
+ }
- // Set mouse over flag if unset
- if (! LLViewerMediaFocus::getInstance()->getMouseOverFlag())
- {
- LLSelectMgr::getInstance()->setHoverObject(objectp, pick.mObjectFace);
- LLViewerMediaFocus::getInstance()->setMouseOverFlag(true, media_impl);
- LLViewerMediaFocus::getInstance()->setPickInfo(pick);
+ return true;
}
-
- return true;
}
- LLViewerMediaFocus::getInstance()->setMouseOverFlag(false);
+
+ // In all other cases, clear media hover.
+ LLViewerMediaFocus::getInstance()->clearHover();
return false;
}