diff options
author | angela <angela@lindenlab.com> | 2009-10-29 00:12:17 +0800 |
---|---|---|
committer | angela <angela@lindenlab.com> | 2009-10-29 00:12:17 +0800 |
commit | 4f4be142b30cd77e23b28d16998323e539933b15 (patch) | |
tree | dd3451389fdd82db9247e79f3bec1ccd013f9e0d /indra | |
parent | ea5a60c80f0243a7e5a6a7fd8357e7c3cd6b5d4d (diff) |
DEV-41714 Display a play/pause control for the inspected face if it contains time-based media
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/lltooltip.cpp | 47 | ||||
-rw-r--r-- | indra/llui/lltooltip.h | 6 | ||||
-rw-r--r-- | indra/newview/llinspectobject.cpp | 8 | ||||
-rw-r--r-- | indra/newview/lltoolpie.cpp | 108 | ||||
-rw-r--r-- | indra/newview/lltoolpie.h | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/strings.xml | 4 |
6 files changed, 164 insertions, 11 deletions
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index c8094f9c7c..93a4adc9b6 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -38,10 +38,11 @@ // Library includes #include "lltextbox.h" #include "lliconctrl.h" +#include "llbutton.h" #include "llmenugl.h" // hideMenus() #include "llui.h" // positionViewNearMouse() #include "llwindow.h" - +#include "lltrans.h" // // Constants // @@ -155,7 +156,9 @@ LLToolTip::Params::Params() visible_time_near("visible_time_near", LLUI::sSettingGroups["config"]->getF32( "ToolTipVisibleTimeNear" )), visible_time_far("visible_time_far", LLUI::sSettingGroups["config"]->getF32( "ToolTipVisibleTimeFar" )), sticky_rect("sticky_rect"), - image("image") + image("image"), + time_based_media("time_based_media", false), + media_playing("media_playing", false) { name = "tooltip"; font = LLFontGL::getFontSansSerif(); @@ -186,28 +189,56 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p) params.allow_html = false; // disallow hyperlinks in tooltips, as they want to spawn their own explanatory tooltips mTextBox = LLUICtrlFactory::create<LLTextBox> (params); addChild(mTextBox); - + + S32 TOOLTIP_ICON_SIZE = 0; + S32 TOOLTIP_PLAYBUTTON_SIZE = 0; if (p.image.isProvided()) { LLIconCtrl::Params icon_params; icon_params.name = "tooltip_icon"; LLRect icon_rect; LLUIImage* imagep = p.image; - const S32 TOOLTIP_ICON_SIZE = (imagep ? imagep->getWidth() : 16); + TOOLTIP_ICON_SIZE = (imagep ? imagep->getWidth() : 16); icon_rect.setOriginAndSize(mPadding, mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE); icon_params.rect = icon_rect; icon_params.follows.flags = FOLLOWS_LEFT | FOLLOWS_BOTTOM; icon_params.image = p.image; icon_params.mouse_opaque = false; - addChild(LLUICtrlFactory::create<LLIconCtrl>(icon_params)); + LLIconCtrl* tooltip_icon = LLUICtrlFactory::create<LLIconCtrl>(icon_params); + addChild(tooltip_icon); // move text over to fit image in mTextBox->translate(TOOLTIP_ICON_SIZE + mPadding, 0); + if (p.click_callback.isProvided()) + { + tooltip_icon->setMouseUpCallback(boost::bind(p.click_callback())); + } } - - if (p.click_callback.isProvided()) + + if (p.time_based_media.isProvided() && p.time_based_media == true) { - setMouseUpCallback(boost::bind(p.click_callback())); + LLButton::Params p_button; + p_button.name(std::string("play_media")); + TOOLTIP_PLAYBUTTON_SIZE = 16; + LLRect button_rect; + button_rect.setOriginAndSize((mPadding +TOOLTIP_ICON_SIZE),mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE); + p_button.rect = button_rect; + p_button.image_selected.name("button_anim_pause.tga"); + p_button.image_unselected.name("button_anim_play.tga"); + p_button.scale_image(true); + mPlayMediaButton = LLUICtrlFactory::create<LLButton>(p_button); + if(p.click_playmedia_callback.isProvided()) + { + mPlayMediaButton->setCommitCallback(boost::bind(p.click_playmedia_callback())); + } + if(p.media_playing.isProvided()) + { + mPlayMediaButton->setToggleState(p.media_playing); + } + addChild(mPlayMediaButton); + + // move text over to fit image in + mTextBox->translate(TOOLTIP_PLAYBUTTON_SIZE + mPadding, 0); } } diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h index 63e7249a12..fa30d5554a 100644 --- a/indra/llui/lltooltip.h +++ b/indra/llui/lltooltip.h @@ -81,6 +81,11 @@ public: Optional<click_callback_t> click_callback; Optional<LLUIImage*> image; + + + Optional<bool> time_based_media; + Optional<bool> media_playing; + Optional<click_callback_t> click_playmedia_callback; Optional<S32> max_width; Optional<S32> padding; Optional<bool> wrap; @@ -101,6 +106,7 @@ public: private: class LLTextBox* mTextBox; + class LLButton* mPlayMediaButton; LLFrameTimer mFadeTimer; LLFrameTimer mVisibleTimer; S32 mMaxWidth; diff --git a/indra/newview/llinspectobject.cpp b/indra/newview/llinspectobject.cpp index 29cca14a7b..81544904e3 100644 --- a/indra/newview/llinspectobject.cpp +++ b/indra/newview/llinspectobject.cpp @@ -106,12 +106,14 @@ private: private: LLUUID mObjectID; + S32 mObjectFace; LLSafeHandle<LLObjectSelection> mObjectSelection; }; LLInspectObject::LLInspectObject(const LLSD& sd) : LLInspect( LLSD() ), // single_instance, doesn't really need key mObjectID(), // set in onOpen() + mObjectFace(0), mObjectSelection() { // can't make the properties request until the widgets are constructed @@ -182,7 +184,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 diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 7c17699bf9..d92bc7efc4 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -732,7 +732,35 @@ BOOL LLToolPie::handleToolTip(S32 local_x, S32 local_y, MASK mask) { tooltip_msg.append( nodep->mName ); } - + + // Does this face have media? + const LLTextureEntry* tep = hover_object->getTE(mHoverPick.mObjectFace); + const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL; + viewer_media_t media_impl = mep ? LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID()) : NULL; + LLPluginClassMedia* media_plugin = NULL; + + bool is_time_based_media = false; + bool is_media_playing = false; + + if (media_impl && (media_impl->hasMedia())) + { + LLStringUtil::format_map_t args; + + media_plugin = media_impl->getMediaPlugin(); + if(media_plugin->pluginSupportsMediaTime()) + { + is_time_based_media = true; + args["[CurrentURL]"] = media_impl->getMediaURL(); + is_media_playing = media_impl->isMediaPlaying(); + } + else + { + is_time_based_media = false; + 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) @@ -743,6 +771,9 @@ BOOL LLToolPie::handleToolTip(S32 local_x, S32 local_y, MASK mask) .message(tooltip_msg) .image(LLUI::getUIImage("Info")) .click_callback(boost::bind(showObjectInspector, hover_object->getID())) + .time_based_media(is_time_based_media) + .media_playing(is_media_playing) + .click_playmedia_callback(boost::bind(playCurrentMedia, mHoverPick)) .visible_time_near(6.f) .visible_time_far(3.f) .wrap(false)); @@ -925,6 +956,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) { @@ -937,6 +982,67 @@ 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); + const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL; + LLPluginClassMedia* media_plugin = NULL; + + if (mep + && 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(); + } + + } + + } + } + +} + + void LLToolPie::handleDeselect() { if( hasMouseCapture() ) diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 5faedbec5a..3cf9cbde55 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -78,6 +78,8 @@ public: static void showAvatarInspector(const LLUUID& avatar_id); static void showObjectInspector(const LLUUID& object_id); + static void showObjectInspector(const LLUUID& object_id, const S32& object_face); + static void playCurrentMedia(const LLPickInfo& info); private: BOOL outsideSlop (S32 x, S32 y, S32 start_x, S32 start_y); BOOL pickLeftMouseDownCallback(); diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 81bc12c33c..afd58a0f01 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -76,6 +76,7 @@ <string name="TooltipTeleportUrl">Click to teleport to this location</string> <string name="TooltipObjectIMUrl">Click to view this object's description</string> <string name="TooltipSLAPP">Click to run the secondlife:// command</string> + <string name="CurrentURL" value=" CurrentURL: [CurrentURL]" /> <!-- ButtonToolTips, llfloater.cpp --> <string name="BUTTON_CLOSE_DARWIN">Close (⌘W)</string> @@ -642,7 +643,7 @@ Sets the script timer to zero float llGetAndResetTime() Returns the script time in seconds and then resets the script timer to zero </string> - <string name="LSLTipText_llSound" translate="false"> + <string name="LSLTipText_llSoplayund" translate="false"> llSound(string sound, float volume, integer queue, integer loop) Plays sound at volume and whether it should loop or not </string> @@ -2194,6 +2195,7 @@ Expected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh <!-- media --> <string name="Multiple Media">Multiple Media</string> + <string name="Play Media">Play/Pause Media</string> <!-- OSMessageBox messages --> <string name="MBCmdLineError"> |