diff options
author | angela <angela@lindenlab.com> | 2009-10-30 17:59:47 +0800 |
---|---|---|
committer | angela <angela@lindenlab.com> | 2009-10-30 17:59:47 +0800 |
commit | e5c96332defcc64defb25f62a26d4f114627a2e0 (patch) | |
tree | a15b8c2ad8109eec6f5e614cddaf194f505ab96d /indra | |
parent | c1dcf8d80917ae246c85343365c472059ae54018 (diff) |
media inspector adding current url, secure browsing and home page button
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/lltooltip.cpp | 36 | ||||
-rw-r--r-- | indra/llui/lltooltip.h | 4 | ||||
-rw-r--r-- | indra/newview/llinspectobject.cpp | 117 | ||||
-rw-r--r-- | indra/newview/lltoolpie.cpp | 55 | ||||
-rw-r--r-- | indra/newview/lltoolpie.h | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/inspect_object.xml | 27 |
6 files changed, 217 insertions, 24 deletions
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index 2a30eb4b5b..34501ae080 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -158,6 +158,7 @@ LLToolTip::Params::Params() sticky_rect("sticky_rect"), image("image"), time_based_media("time_based_media", false), + web_based_media("web_based_media", false), media_playing("media_playing", false) { name = "tooltip"; @@ -173,7 +174,8 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p) mPadding(p.padding), mTextBox(NULL), mInfoButton(NULL), - mPlayMediaButton(NULL) + mPlayMediaButton(NULL), + mHomePageButton(NULL) { LLTextBox::Params params; params.initial_value = "tip_text"; @@ -246,6 +248,28 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p) mTextBox->translate(TOOLTIP_PLAYBUTTON_SIZE + mPadding, 0); } + if (p.web_based_media.isProvided() && p.web_based_media == true) + { + LLButton::Params p_w_button; + p_w_button.name(std::string("home_page")); + TOOLTIP_PLAYBUTTON_SIZE = 16; + LLRect button_rect; + button_rect.setOriginAndSize((mPadding +TOOLTIP_ICON_SIZE+ mPadding ), mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE); + p_w_button.rect = button_rect; + p_w_button.image_unselected.name("map_home.tga"); + p_w_button.scale_image(true); + + mHomePageButton = LLUICtrlFactory::create<LLButton>(p_w_button); + if(p.click_homepage_callback.isProvided()) + { + mHomePageButton->setCommitCallback(boost::bind(p.click_homepage_callback())); + } + addChild(mHomePageButton); + + // move text over to fit image in + mTextBox->translate(TOOLTIP_PLAYBUTTON_SIZE + mPadding, 0); + } + if (p.click_callback.isProvided()) { setMouseUpCallback(boost::bind(p.click_callback())); @@ -297,7 +321,8 @@ void LLToolTip::setVisible(BOOL visible) BOOL LLToolTip::handleHover(S32 x, S32 y, MASK mask) { //mInfoButton->setFlashing(true); - mInfoButton->setHighlight(true); + if(mInfoButton) + mInfoButton->setHighlight(true); LLPanel::handleHover(x, y, mask); if (mHasClickCallback) @@ -310,7 +335,8 @@ BOOL LLToolTip::handleHover(S32 x, S32 y, MASK mask) void LLToolTip::onMouseLeave(S32 x, S32 y, MASK mask) { //mInfoButton->setFlashing(true); - mInfoButton->setHighlight(false); + if(mInfoButton) + mInfoButton->setHighlight(false); LLUICtrl::onMouseLeave(x, y, mask); } @@ -444,7 +470,9 @@ void LLToolTipMgr::show(const LLToolTip::Params& params) && LLUI::getMouseIdleTime() > params.delay_time) // the mouse has been still long enough { bool tooltip_changed = mLastToolTipParams.message() != params.message() - || mLastToolTipParams.pos() != params.pos(); + || mLastToolTipParams.pos() != params.pos() + || mLastToolTipParams.time_based_media() != params.time_based_media() + || mLastToolTipParams.web_based_media() != params.web_based_media(); bool tooltip_shown = mToolTip && mToolTip->getVisible() diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h index a81876eac1..4a5f60f93d 100644 --- a/indra/llui/lltooltip.h +++ b/indra/llui/lltooltip.h @@ -84,8 +84,10 @@ public: Optional<bool> time_based_media; + Optional<bool> web_based_media; Optional<bool> media_playing; Optional<click_callback_t> click_playmedia_callback; + Optional<click_callback_t> click_homepage_callback; Optional<S32> max_width; Optional<S32> padding; Optional<bool> wrap; @@ -108,6 +110,8 @@ private: class LLTextBox* mTextBox; class LLButton* mInfoButton; class LLButton* mPlayMediaButton; + class LLButton* mHomePageButton; + LLFrameTimer mFadeTimer; LLFrameTimer mVisibleTimer; S32 mMaxWidth; diff --git a/indra/newview/llinspectobject.cpp b/indra/newview/llinspectobject.cpp index 81544904e3..050a61c79b 100644 --- a/indra/newview/llinspectobject.cpp +++ b/indra/newview/llinspectobject.cpp @@ -35,10 +35,12 @@ // Viewer #include "llinspect.h" +#include "llmediaentry.h" #include "llnotifications.h" // *TODO: Eliminate, add LLNotificationsUtil wrapper #include "llselectmgr.h" #include "llslurl.h" #include "llviewermenu.h" // handle_object_touch(), handle_buy() +#include "llviewermedia.h" #include "llviewerobjectlist.h" // to select the requested object // Linden libraries @@ -92,8 +94,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(); @@ -107,14 +111,16 @@ private: private: LLUUID mObjectID; S32 mObjectFace; + viewer_media_t mMediaImpl; LLSafeHandle<LLObjectSelection> mObjectSelection; }; LLInspectObject::LLInspectObject(const LLSD& sd) : LLInspect( LLSD() ), // single_instance, doesn't really need key - mObjectID(), // set in onOpen() + mObjectID(NULL), // set in onOpen() mObjectFace(0), - mObjectSelection() + mObjectSelection(NULL), + mMediaImpl(NULL) { // can't make the properties request until the widgets are constructed // as it might return immediately, so do it in postBuild. @@ -141,7 +147,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(); @@ -219,6 +225,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; + + const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL; + if(!mep) + return; + + mMediaImpl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID()); } } @@ -249,6 +266,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; + + const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL; + if(!mep) + return; + + mMediaImpl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID()); + + updateMediaCurrentURL(); + updateSecureBrowsing(); } void LLInspectObject::hideButtons() @@ -387,6 +428,40 @@ void LLInspectObject::updateDescription(LLSelectNode* nodep) } } +void LLInspectObject::updateMediaCurrentURL() +{ + LLTextBox* textbox = getChild<LLTextBox>("object_media_url"); + std::string media_url = ""; + textbox->setValue(media_url); + textbox->setToolTip(media_url); + + if(mMediaImpl.notNull() && mMediaImpl->hasMedia()) + { + LLStringUtil::format_map_t args; + 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); + textbox->setText(media_url); + textbox->setToolTip(media_url); + } + } + else + { + textbox->setText(media_url); + textbox->setToolTip(media_url); + } +} + void LLInspectObject::updateCreator(LLSelectNode* nodep) { // final information for display @@ -459,6 +534,40 @@ 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); +} + + void LLInspectObject::onClickBuy() { handle_buy(); diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 2ba4d97674..304f1dffaf 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -734,6 +734,7 @@ BOOL LLToolPie::handleToolTip(S32 local_x, S32 local_y, MASK mask) } bool is_time_based_media = false; + bool is_web_based_media = false; bool is_media_playing = false; // Does this face have media? @@ -756,12 +757,14 @@ BOOL LLToolPie::handleToolTip(S32 local_x, S32 local_y, MASK mask) { 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)); @@ -781,8 +784,10 @@ BOOL LLToolPie::handleToolTip(S32 local_x, S32 local_y, MASK mask) .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_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)); @@ -1030,8 +1035,8 @@ void LLToolPie::playCurrentMedia(const LLPickInfo& info) LLPluginClassMedia* media_plugin = NULL; - if (gSavedSettings.getBOOL("MediaOnAPrimUI")) - { +// if (gSavedSettings.getBOOL("MediaOnAPrimUI")) +// { viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID()); if(media_impl.notNull() && media_impl->hasMedia()) @@ -1052,10 +1057,52 @@ void LLToolPie::playCurrentMedia(const LLPickInfo& info) } } - } +// } } +// 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() { diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 3cf9cbde55..3660c68552 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -80,6 +80,8 @@ public: static void showObjectInspector(const LLUUID& object_id); static void showObjectInspector(const LLUUID& object_id, const S32& object_face); static void playCurrentMedia(const LLPickInfo& info); + static void VisitHomePage(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/inspect_object.xml b/indra/newview/skins/default/xui/en/inspect_object.xml index 76b6e2c173..fe492e0ae8 100644 --- a/indra/newview/skins/default/xui/en/inspect_object.xml +++ b/indra/newview/skins/default/xui/en/inspect_object.xml @@ -84,6 +84,17 @@ This is a really long description for an object being as how it is at least 80 c </text> <!-- Overlapping buttons for all default actions. Show "Buy" if for sale, "Sit" if can sit, etc. --> + <text + follows="all" + height="15" + left_delta="0" + name="object_media_url" + top_pad="-5" + width="291" + max_length = "50" + use_ellipses="true" + word_wrap="true"/> + <button follows="top|left" font="SansSerif" @@ -139,24 +150,16 @@ This is a really long description for an object being as how it is at least 80 c top_delta="0" width="75" /> <icon - name="secure_icon" + name="secure_browsing" image_name="map_infohub.tga" left_delta="80" width="16" height="16" - top_delta="0" + top_delta="2" + tool_tip="Secure Browsing" follows="left|top"/> - <!-- <text - follows="left|top" - height="30" - left_delta="20" - name="object_media_url" - top_pad="-20" - width="150" - use_ellipses="true" - word_wrap="true"> - non-overlapping buttons here --> + <!-- non-overlapping buttons here --> <menu_button follows="top|left" height="18" |