From 7a3fc995c3af52004fb1efee8c2f1de55fffef04 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 16 Sep 2010 15:36:23 -0700 Subject: EXP-63 FIX Hint marked as acted upon if hints are disabled while specific UI hint is open --- indra/newview/llhints.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llhints.cpp b/indra/newview/llhints.cpp index bd7fec63e8..bb8f4a995b 100644 --- a/indra/newview/llhints.cpp +++ b/indra/newview/llhints.cpp @@ -360,7 +360,7 @@ void LLHints::hideAll() it != end_it; ++it) { - LLNotifications::instance().cancel(*it); + hide(*it); } } -- cgit v1.2.3 From c46a82c56b5b47497f3adc94ea2ddfdb1d4aa1cf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 16 Sep 2010 16:26:45 -0700 Subject: renamed isProvided() to anyProvided() and fixed partial params (missing mandatory elements) not merging over complete params --- indra/llxuixml/llinitparam.cpp | 2 +- indra/llxuixml/llinitparam.h | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp index dc4d93d38a..2c92539387 100644 --- a/indra/llxuixml/llinitparam.cpp +++ b/indra/llxuixml/llinitparam.cpp @@ -178,7 +178,7 @@ namespace LLInitParam param_handle_t param_handle = it->second->mParamHandle; const Param* param = getParamFromHandle(param_handle); ParamDescriptor::serialize_func_t serialize_func = it->second->mSerializeFunc; - if (serialize_func && param->getProvided()) + if (serialize_func && param->anyProvided()) { // Ensure this param has not already been serialized // Prevents from being serialized as its own tag. diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 610381dcfe..24ce891880 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -287,7 +287,7 @@ namespace LLInitParam void setProvided(bool is_provided) { mIsProvided = is_provided; } protected: - bool getProvided() const { return mIsProvided; } + bool anyProvided() const { return mIsProvided; } Param(class BaseBlock* enclosing_block); @@ -568,7 +568,7 @@ namespace LLInitParam mData.mValue = value; } - bool isProvided() const { return Param::getProvided(); } + bool isProvided() const { return Param::anyProvided(); } static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation) { @@ -795,13 +795,13 @@ namespace LLInitParam bool isProvided() const { // only validate block when it hasn't already passed validation and user has supplied *some* value - if (Param::getProvided() && mData.mValidatedVersion < T::getLastChangeVersion()) + if (Param::anyProvided() && mData.mValidatedVersion < T::getLastChangeVersion()) { // a sub-block is "provided" when it has been filled in enough to be valid mData.mValidated = T::validateBlock(false); mData.mValidatedVersion = T::getLastChangeVersion(); } - return Param::getProvided() && mData.mValidated; + return Param::anyProvided() && mData.mValidated; } // assign block contents to this param-that-is-a-block @@ -852,7 +852,7 @@ namespace LLInitParam { const self_t& src_typed_param = static_cast(src); self_t& dst_typed_param = static_cast(dst); - if (dst_typed_param.T::merge(T::selfBlockDescriptor(), src_typed_param, overwrite || !dst_typed_param.isProvided())) + if (dst_typed_param.T::merge(T::selfBlockDescriptor(), src_typed_param, overwrite)) { dst_typed_param.mData.clearKey(); return true; @@ -909,7 +909,7 @@ namespace LLInitParam } } - bool isProvided() const { return Param::getProvided(); } + bool isProvided() const { return Param::anyProvided(); } static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation) { @@ -1093,7 +1093,7 @@ namespace LLInitParam } } - bool isProvided() const { return Param::getProvided(); } + bool isProvided() const { return Param::anyProvided(); } value_ref_t operator[](S32 index) { return mValues[index]; } value_const_ref_t operator[](S32 index) const { return mValues[index]; } @@ -1736,7 +1736,7 @@ namespace LLInitParam bool isProvided() const { - if (!Param::getProvided()) return false; + if (!Param::anyProvided()) return false; // block has an updated parameter // if cached value is stale, regenerate from params @@ -1803,7 +1803,7 @@ namespace LLInitParam value_assignment_t get() const { // if some parameters were provided, issue warnings on invalid blocks - if (Param::getProvided() && (mData.mValueAge == OLDER_THAN_BLOCK)) + if (Param::anyProvided() && (mData.mValueAge == OLDER_THAN_BLOCK)) { // go ahead and issue warnings at this point if any param is invalid if(block_t::validateBlock(true)) -- cgit v1.2.3 From b24071ca8936035ff42cb361e42cac63593f695e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 16 Sep 2010 16:28:57 -0700 Subject: added ability to have notification ignore variable point to settings.xml variables --- indra/llui/llnotifications.cpp | 91 +++++++++++++++++++++++++++++----- indra/llui/llnotifications.h | 55 +++++++------------- indra/llui/llnotificationslistener.cpp | 7 ++- 3 files changed, 103 insertions(+), 50 deletions(-) diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index bdc094bf47..bd58fe2637 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -55,6 +55,47 @@ void NotificationPriorityValues::declareValues() declare("critical", NOTIFICATION_PRIORITY_CRITICAL); } +LLNotificationForm::FormElementBase::FormElementBase() +: name("name") +{} + +LLNotificationForm::FormIgnore::FormIgnore() +: text("text"), + control("control"), + invert_control("invert_control", false), + save_option("save_option", false) +{} + +LLNotificationForm::FormButton::FormButton() +: index("index"), + text("text"), + ignore("ignore"), + is_default("default"), + type("type") +{ + // set type here so it gets serialized + type = "button"; +} + +LLNotificationForm::FormInput::FormInput() +: type("type"), + width("width", 0) +{} + +LLNotificationForm::FormElement::FormElement() +: button("button"), + input("input") +{} + +LLNotificationForm::FormElements::FormElements() +: elements("") +{} + +LLNotificationForm::Params::Params() +: name("name"), + ignore("ignore"), + form_elements("") +{} // Local channel for persistent notifications // Stores only persistent notifications. @@ -100,12 +141,7 @@ bool filterIgnoredNotifications(LLNotificationPtr notification) LLNotificationFormPtr form = notification->getForm(); // Check to see if the user wants to ignore this alert - if (form->getIgnoreType() != LLNotificationForm::IGNORE_NO) - { - return LLUI::sSettingGroups["ignores"]->getBOOL(notification->getName()); - } - - return true; + return !notification->getForm()->getIgnored(); } bool handleIgnoredNotification(const LLSD& payload) @@ -153,7 +189,8 @@ LLNotificationForm::LLNotificationForm() LLNotificationForm::LLNotificationForm(const std::string& name, const LLNotificationForm::Params& p) -: mIgnore(IGNORE_NO) +: mIgnore(IGNORE_NO), + mInvertSetting(false) { if (p.ignore.isProvided()) { @@ -171,7 +208,16 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLNotifica } BOOL show_notification = TRUE; - LLUI::sSettingGroups["ignores"]->declareBOOL(name, show_notification, "Ignore notification with this name", TRUE); + if (p.ignore.control.isProvided()) + { + mIgnoreSetting = LLUI::sSettingGroups["config"]->getControl(p.ignore.control); + mInvertSetting = p.ignore.invert_control; + } + else + { + LLUI::sSettingGroups["ignores"]->declareBOOL(name, show_notification, "Ignore notification with this name", TRUE); + mIgnoreSetting = LLUI::sSettingGroups["ignores"]->getControl(name); + } } LLParamSDParser parser; @@ -300,6 +346,27 @@ std::string LLNotificationForm::getDefaultOption() return ""; } +LLControlVariablePtr LLNotificationForm::getIgnoreSetting() +{ + return mIgnoreSetting; +} + +bool LLNotificationForm::getIgnored() +{ + if (mIgnore != LLNotificationForm::IGNORE_NO + && mIgnoreSetting) + { + return mIgnoreSetting->getValue().asBoolean() != mInvertSetting; + } + + return false; +} + +void LLNotificationForm::setIgnored(bool ignored) +{ + if (mIgnoreSetting) mIgnoreSetting->setValue(ignored != mInvertSetting); +} + LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Params& p) : mName(p.name), mType(p.type), @@ -545,8 +612,8 @@ void LLNotification::respond(const LLSD& response) if (mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) { - BOOL show_notification = mIgnored ? FALSE : TRUE; - LLUI::sSettingGroups["ignores"]->setBOOL(getName(), show_notification); + bool show_notification = !mIgnored; + mForm->setIgnored(!show_notification); if (mIgnored && mForm->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE) { LLUI::sSettingGroups["ignores"]->setLLSD("Default" + getName(), response); @@ -1294,11 +1361,11 @@ bool LLNotifications::loadTemplates() } if(it->form_ref.form_template.cancel_text.isProvided()) { - replaceFormText(it->form_ref.form, "$cancel_text", it->form_ref.form_template.cancel_text); + replaceFormText(it->form_ref.form, "$canceltext", it->form_ref.form_template.cancel_text); } if(it->form_ref.form_template.ignore_text.isProvided()) { - replaceFormText(it->form_ref.form, "$ignore_text", it->form_ref.form_template.ignore_text); + replaceFormText(it->form_ref.form, "$ignoretext", it->form_ref.form_template.ignore_text); } } addTemplate(it->name, LLNotificationTemplatePtr(new LLNotificationTemplate(*it))); diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index a58e7afe23..ed29e0d83e 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -163,22 +163,19 @@ class LLNotificationForm public: struct FormElementBase : public LLInitParam::Block { - Mandatory name; + Optional name; - FormElementBase() - : name("name") - {} + FormElementBase(); }; struct FormIgnore : public LLInitParam::Block { Optional text; Optional save_option; + Optional control; + Optional invert_control; - FormIgnore() - : text("text"), - save_option("save_option", false) - {} + FormIgnore(); }; struct FormButton : public LLInitParam::Block @@ -190,16 +187,7 @@ public: Mandatory type; - FormButton() - : index("index"), - text("text"), - ignore("ignore"), - is_default("default"), - type("type") - { - // set type here so it gets serialized - type = "button"; - } + FormButton(); }; struct FormInput : public LLInitParam::Block @@ -207,10 +195,7 @@ public: Mandatory type; Optional width; - FormInput() - : type("type"), - width("width", 0) - {} + FormInput(); }; struct FormElement : public LLInitParam::Choice @@ -218,18 +203,13 @@ public: Alternative button; Alternative input; - FormElement() - : button("button"), - input("input") - {} + FormElement(); }; struct FormElements : public LLInitParam::Block { Multiple elements; - FormElements() - : elements("") - {} + FormElements(); }; struct Params : public LLInitParam::Block @@ -238,11 +218,7 @@ public: Optional ignore; Optional form_elements; - Params() - : name("name"), - ignore("ignore"), - form_elements("") - {} + Params(); }; typedef enum e_ignore_type @@ -268,14 +244,19 @@ public: // appends form elements from another form serialized as LLSD void append(const LLSD& sub_form); std::string getDefaultOption(); + LLPointer getIgnoreSetting(); + bool getIgnored(); + void setIgnored(bool ignored); EIgnoreType getIgnoreType() { return mIgnore; } std::string getIgnoreMessage() { return mIgnoreMsg; } private: - LLSD mFormData; - EIgnoreType mIgnore; - std::string mIgnoreMsg; + LLSD mFormData; + EIgnoreType mIgnore; + std::string mIgnoreMsg; + LLPointer mIgnoreSetting; + bool mInvertSetting; }; typedef boost::shared_ptr LLNotificationFormPtr; diff --git a/indra/llui/llnotificationslistener.cpp b/indra/llui/llnotificationslistener.cpp index 44a90398fd..3bbeb3a778 100644 --- a/indra/llui/llnotificationslistener.cpp +++ b/indra/llui/llnotificationslistener.cpp @@ -29,6 +29,7 @@ #include "linden_common.h" #include "llnotificationslistener.h" #include "llnotifications.h" +#include "llnotificationtemplate.h" #include "llsd.h" #include "llui.h" @@ -182,7 +183,11 @@ void LLNotificationsListener::ignore(const LLSD& params) const if (params["name"].isDefined()) { // ["name"] was passed: ignore just that notification - LLUI::sSettingGroups["ignores"]->setBOOL(params["name"], ignore); + LLNotificationTemplatePtr templatep = mNotifications.getTemplate(params["name"]); + if (templatep) + { + templatep->mForm->setIgnored(ignore); + } } else { -- cgit v1.2.3 From d2a0327b6e89ca678e50e58dd685ea80e4c51cb5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 16 Sep 2010 16:29:53 -0700 Subject: popup blocking notifications now handled in all web_browser instances, not just llfloatermediabrowser --- indra/newview/llbrowsernotification.cpp | 18 +- indra/newview/llfloatermediabrowser.cpp | 95 --------- indra/newview/llfloatermediabrowser.h | 6 - indra/newview/llfloaterpreference.cpp | 10 +- indra/newview/llmediactrl.cpp | 216 +++++++++++++++++++-- indra/newview/llmediactrl.h | 8 +- .../skins/default/xui/en/floater_media_browser.xml | 70 ------- .../newview/skins/default/xui/en/notifications.xml | 5 +- .../default/xui/en/panel_preferences_setup.xml | 14 +- 9 files changed, 231 insertions(+), 211 deletions(-) diff --git a/indra/newview/llbrowsernotification.cpp b/indra/newview/llbrowsernotification.cpp index e162527e23..cc54d10944 100644 --- a/indra/newview/llbrowsernotification.cpp +++ b/indra/newview/llbrowsernotification.cpp @@ -36,22 +36,6 @@ using namespace LLNotificationsUI; bool LLBrowserNotification::processNotification(const LLSD& notify) { - LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID()); - - if (notification) - { - LLFloaterMediaBrowser* browserp = dynamic_cast(LLFloaterReg::findInstance("media_browser", notification->getPayload()["source"])); - if (notify["sigtype"].asString() == "add" || notify["sigtype"].asString() == "load") - { - if (browserp) - { - browserp->showNotification(notification); - } - } - else if (notify["sigtype"].asString() == "delete") - { - browserp->hideNotification(); - } - } + // browser notifications are currently handled directly by the LLMediaCtrl instance that spawned them return false; } diff --git a/indra/newview/llfloatermediabrowser.cpp b/indra/newview/llfloatermediabrowser.cpp index ba8128e902..3e99b27f7f 100644 --- a/indra/newview/llfloatermediabrowser.cpp +++ b/indra/newview/llfloatermediabrowser.cpp @@ -144,16 +144,12 @@ void LLFloaterMediaBrowser::draw() BOOL LLFloaterMediaBrowser::postBuild() { mBrowser = getChild("browser"); - mBrowser->setMediaID(mKey); mBrowser->addObserver(this); mAddressCombo = getChild("address"); mAddressCombo->setCommitCallback(onEnterAddress, this); mAddressCombo->sortByName(); - LLButton& notification_close = getChildRef("close_notification"); - notification_close.setClickedCallback(boost::bind(&LLFloaterMediaBrowser::onCloseNotification, this), NULL); - childSetAction("back", onClickBack, this); childSetAction("forward", onClickForward, this); childSetAction("reload", onClickRefresh, this); @@ -250,73 +246,6 @@ void LLFloaterMediaBrowser::setCurrentURL(const std::string& url) getChildView("reload")->setEnabled(TRUE); } -void LLFloaterMediaBrowser::showNotification(LLNotificationPtr notify) -{ - mCurNotification = notify; - - // add popup here - LLSD payload = notify->getPayload(); - - LLNotificationFormPtr formp = notify->getForm(); - LLLayoutPanel& panel = getChildRef("notification_area"); - panel.setVisible(true); - panel.getChild("notification_icon")->setValue(notify->getIcon()); - panel.getChild("notification_text")->setValue(notify->getMessage()); - panel.getChild("notification_text")->setToolTip(notify->getMessage()); - LLNotificationForm::EIgnoreType ignore_type = formp->getIgnoreType(); - LLLayoutPanel& form_elements = panel.getChildRef("form_elements"); - - const S32 FORM_PADDING_HORIZONTAL = 10; - const S32 FORM_PADDING_VERTICAL = 5; - S32 cur_x = FORM_PADDING_HORIZONTAL; - - if (ignore_type != LLNotificationForm::IGNORE_NO) - { - LLCheckBoxCtrl::Params checkbox_p; - checkbox_p.name = "ignore_check"; - checkbox_p.rect = LLRect(cur_x, form_elements.getRect().getHeight() - FORM_PADDING_VERTICAL, cur_x, FORM_PADDING_VERTICAL); - checkbox_p.label = formp->getIgnoreMessage(); - checkbox_p.label_text.text_color = LLColor4::black; - checkbox_p.commit_callback.function = boost::bind(&LLFloaterMediaBrowser::onClickIgnore, this, _1); - - LLCheckBoxCtrl* check = LLUICtrlFactory::create(checkbox_p); - check->setRect(check->getBoundingRect()); - form_elements.addChild(check); - cur_x = check->getRect().mRight + FORM_PADDING_HORIZONTAL; - } - - for (S32 i = 0; i < formp->getNumElements(); i++) - { - LLSD form_element = formp->getElement(i); - if (form_element["type"].asString() == "button") - { - LLButton::Params button_p; - button_p.name = form_element["name"]; - button_p.label = form_element["text"]; - button_p.rect = LLRect(cur_x, form_elements.getRect().getHeight() - FORM_PADDING_VERTICAL, cur_x, FORM_PADDING_VERTICAL); - button_p.commit_callback.function = boost::bind(&LLFloaterMediaBrowser::onClickNotificationButton, this, form_element["name"].asString()); - button_p.auto_resize = true; - - LLButton* button = LLUICtrlFactory::create(button_p); - button->autoResize(); - form_elements.addChild(button); - - cur_x = button->getRect().mRight + FORM_PADDING_HORIZONTAL; - } - } - - - form_elements.reshape(cur_x, form_elements.getRect().getHeight()); - - //LLWeb::loadURL(payload["url"], payload["target"]); -} - -void LLFloaterMediaBrowser::hideNotification() -{ - LLLayoutPanel& panel = getChildRef("notification_area"); - panel.setVisible(FALSE); -} - //static void LLFloaterMediaBrowser::onEnterAddress(LLUICtrl* ctrl, void* user_data) { @@ -449,28 +378,4 @@ void LLFloaterMediaBrowser::openMedia(const std::string& media_url) setCurrentURL(media_url); } -void LLFloaterMediaBrowser::onCloseNotification() -{ - LLNotifications::instance().cancel(mCurNotification); -} - -void LLFloaterMediaBrowser::onClickIgnore(LLUICtrl* ctrl) -{ - bool check = ctrl->getValue().asBoolean(); - if (mCurNotification && mCurNotification->getForm()->getIgnoreType() == LLNotificationForm::IGNORE_SHOW_AGAIN) - { - // question was "show again" so invert value to get "ignore" - check = !check; - } - mCurNotification->setIgnored(check); -} -void LLFloaterMediaBrowser::onClickNotificationButton(const std::string& name) -{ - if (!mCurNotification) return; - - LLSD response = mCurNotification->getResponseTemplate(); - response[name] = true; - - mCurNotification->respond(response); -} diff --git a/indra/newview/llfloatermediabrowser.h b/indra/newview/llfloatermediabrowser.h index e6511c6e85..6498e28045 100644 --- a/indra/newview/llfloatermediabrowser.h +++ b/indra/newview/llfloatermediabrowser.h @@ -56,8 +56,6 @@ public: void buildURLHistory(); std::string getSupportURL(); void setCurrentURL(const std::string& url); - void showNotification(boost::shared_ptr notify); - void hideNotification(); static void onEnterAddress(LLUICtrl* ctrl, void* user_data); static void onClickRefresh(void* user_data); @@ -73,10 +71,6 @@ public: static void onClickSeek(void* user_data); private: - void onCloseNotification(); - void onClickIgnore(LLUICtrl* ctrl); - void onClickNotificationButton(const std::string& name); - LLMediaCtrl* mBrowser; LLComboBox* mAddressCombo; std::string mCurrentURL; diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 50aacc6458..cba91d7e7e 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -798,7 +798,7 @@ void LLFloaterPreference::buildPopupLists() LLScrollListItem* item = NULL; - bool show_popup = LLUI::sSettingGroups["ignores"]->getBOOL(templatep->mName); + bool show_popup = formp->getIgnored(); if (!show_popup) { if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE) @@ -1150,9 +1150,7 @@ void LLFloaterPreference::onClickDisablePopup() for (itor = items.begin(); itor != items.end(); ++itor) { LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata())); - //gSavedSettings.setWarning(templatep->mName, TRUE); - std::string notification_name = templatep->mName; - LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, FALSE); + templatep->mForm->setIgnored(false); } buildPopupLists(); @@ -1166,7 +1164,7 @@ void LLFloaterPreference::resetAllIgnored() { if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) { - LLUI::sSettingGroups["ignores"]->setBOOL(iter->first, TRUE); + iter->second->mForm->setIgnored(true); } } } @@ -1179,7 +1177,7 @@ void LLFloaterPreference::setAllIgnored() { if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) { - LLUI::sSettingGroups["ignores"]->setBOOL(iter->first, FALSE); + iter->second->mForm->setIgnored(false); } } } diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index 16519bc0d5..a2c809884b 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -38,7 +38,6 @@ #include "llviewermedia.h" #include "llviewertexture.h" #include "llviewerwindow.h" -#include "llnotificationsutil.h" #include "llweb.h" #include "llrender.h" #include "llpluginclassmedia.h" @@ -49,6 +48,12 @@ // linden library includes #include "llfocusmgr.h" #include "llsdutil.h" +#include "lllayoutstack.h" +#include "lliconctrl.h" +#include "lltextbox.h" +#include "llbutton.h" +#include "llcheckboxctrl.h" +#include "llnotifications.h" extern BOOL gRestoreGL; @@ -90,7 +95,6 @@ LLMediaCtrl::LLMediaCtrl( const Params& p) : mTextureWidth ( 1024 ), mTextureHeight ( 1024 ), mClearCache(false), - mMediaID(p.media_id), mHomePageMimeType(p.initial_mime_type) { { @@ -177,6 +181,7 @@ void LLMediaCtrl::setTrusted( bool valIn ) // BOOL LLMediaCtrl::handleHover( S32 x, S32 y, MASK mask ) { + if (LLPanel::handleHover(x, y, mask)) return TRUE; convertInputCoords(x, y); if (mMediaSource) @@ -192,6 +197,7 @@ BOOL LLMediaCtrl::handleHover( S32 x, S32 y, MASK mask ) // BOOL LLMediaCtrl::handleScrollWheel( S32 x, S32 y, S32 clicks ) { + if (LLPanel::handleScrollWheel(x, y, clicks)) return TRUE; if (mMediaSource && mMediaSource->hasMedia()) mMediaSource->getMediaPlugin()->scrollEvent(0, clicks, gKeyboard->currentMask(TRUE)); @@ -202,6 +208,7 @@ BOOL LLMediaCtrl::handleScrollWheel( S32 x, S32 y, S32 clicks ) // BOOL LLMediaCtrl::handleMouseUp( S32 x, S32 y, MASK mask ) { + if (LLPanel::handleMouseUp(x, y, mask)) return TRUE; convertInputCoords(x, y); if (mMediaSource) @@ -226,6 +233,7 @@ BOOL LLMediaCtrl::handleMouseUp( S32 x, S32 y, MASK mask ) // BOOL LLMediaCtrl::handleMouseDown( S32 x, S32 y, MASK mask ) { + if (LLPanel::handleMouseDown(x, y, mask)) return TRUE; convertInputCoords(x, y); if (mMediaSource) @@ -245,6 +253,7 @@ BOOL LLMediaCtrl::handleMouseDown( S32 x, S32 y, MASK mask ) // BOOL LLMediaCtrl::handleRightMouseUp( S32 x, S32 y, MASK mask ) { + if (LLPanel::handleRightMouseUp(x, y, mask)) return TRUE; convertInputCoords(x, y); if (mMediaSource) @@ -269,6 +278,7 @@ BOOL LLMediaCtrl::handleRightMouseUp( S32 x, S32 y, MASK mask ) // BOOL LLMediaCtrl::handleRightMouseDown( S32 x, S32 y, MASK mask ) { + if (LLPanel::handleRightMouseDown(x, y, mask)) return TRUE; convertInputCoords(x, y); if (mMediaSource) @@ -288,6 +298,7 @@ BOOL LLMediaCtrl::handleRightMouseDown( S32 x, S32 y, MASK mask ) // BOOL LLMediaCtrl::handleDoubleClick( S32 x, S32 y, MASK mask ) { + if (LLPanel::handleDoubleClick(x, y, mask)) return TRUE; convertInputCoords(x, y); if (mMediaSource) @@ -342,6 +353,85 @@ void LLMediaCtrl::onFocusLost() // BOOL LLMediaCtrl::postBuild () { + LLLayoutStack::Params layout_p; + layout_p.name = "notification_stack"; + layout_p.rect = LLRect(0,getLocalRect().mTop,getLocalRect().mRight, 30); + layout_p.follows.flags = FOLLOWS_ALL; + layout_p.mouse_opaque = false; + layout_p.orientation = "vertical"; + + LLLayoutStack* stackp = LLUICtrlFactory::create(layout_p); + addChild(stackp); + + LLLayoutPanel::Params panel_p; + panel_p.rect = LLRect(0, 30, 800, 0); + panel_p.min_height = 30; + panel_p.name = "notification_area"; + panel_p.visible = false; + panel_p.user_resize = false; + panel_p.background_visible = true; + panel_p.bg_alpha_image.name = "Yellow_Gradient"; + panel_p.auto_resize = false; + LLLayoutPanel* notification_panel = LLUICtrlFactory::create(panel_p); + stackp->addChild(notification_panel); + + panel_p = LLUICtrlFactory::getDefaultParams(); + panel_p.auto_resize = true; + panel_p.mouse_opaque = false; + LLLayoutPanel* dummy_panel = LLUICtrlFactory::create(panel_p); + stackp->addChild(dummy_panel); + + layout_p = LLUICtrlFactory::getDefaultParams(); + layout_p.rect = LLRect(0, 30, 800, 0); + layout_p.follows.flags = FOLLOWS_ALL; + layout_p.orientation = "horizontal"; + stackp = LLUICtrlFactory::create(layout_p); + notification_panel->addChild(stackp); + + panel_p = LLUICtrlFactory::getDefaultParams(); + panel_p.rect.height = 30; + LLLayoutPanel* panel = LLUICtrlFactory::create(panel_p); + stackp->addChild(panel); + + LLIconCtrl::Params icon_p; + icon_p.name = "notification_icon"; + icon_p.rect = LLRect(5, 23, 21, 8); + panel->addChild(LLUICtrlFactory::create(icon_p)); + + LLTextBox::Params text_p; + text_p.rect = LLRect(31, 20, 430, 0); + text_p.text_color = LLColor4::black; + text_p.font = LLFontGL::getFontSansSerif(); + text_p.font.style = "BOLD"; + text_p.name = "notification_text"; + text_p.use_ellipses = true; + panel->addChild(LLUICtrlFactory::create(text_p)); + + panel_p = LLUICtrlFactory::getDefaultParams(); + panel_p.auto_resize = false; + panel_p.user_resize = false; + panel_p.name="form_elements"; + panel_p.rect = LLRect(0, 30, 130, 0); + LLLayoutPanel* form_elements_panel = LLUICtrlFactory::create(panel_p); + stackp->addChild(form_elements_panel); + + panel_p = LLUICtrlFactory::getDefaultParams(); + panel_p.auto_resize = false; + panel_p.user_resize = false; + panel_p.rect = LLRect(0, 30, 25, 0); + LLLayoutPanel* close_panel = LLUICtrlFactory::create(panel_p); + stackp->addChild(close_panel); + + LLButton::Params button_p; + button_p.name = "close_notification"; + button_p.rect = LLRect(5, 23, 21, 7); + button_p.image_color=LLUIColorTable::instance().getColor("DkGray_66"); + button_p.image_unselected.name="Icon_Close_Foreground"; + button_p.image_selected.name="Icon_Close_Press"; + button_p.click_callback.function = boost::bind(&LLMediaCtrl::onCloseNotification, this); + + close_panel->addChild(LLUICtrlFactory::create(button_p)); + setVisibleCallback(boost::bind(&LLMediaCtrl::onVisibilityChange, this, _2)); return TRUE; } @@ -350,6 +440,7 @@ BOOL LLMediaCtrl::postBuild () // BOOL LLMediaCtrl::handleKeyHere( KEY key, MASK mask ) { + if (LLPanel::handleKeyHere(key, mask)) return TRUE; BOOL result = FALSE; if (mMediaSource) @@ -375,6 +466,7 @@ void LLMediaCtrl::handleVisibilityChange ( BOOL new_visibility ) // BOOL LLMediaCtrl::handleUnicodeCharHere(llwchar uni_char) { + if (LLPanel::handleUnicodeCharHere(uni_char)) return TRUE; BOOL result = FALSE; if (mMediaSource) @@ -827,7 +919,15 @@ void LLMediaCtrl::draw() if ( mBorder && mBorder->getVisible() ) mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus( this ) ); - + if (mCurNotification) + { + if (mCurNotification->isCancelled() || mCurNotification->isExpired()) + { + hideNotification(); + } + } + + LLPanel::draw(); // Restore the previous values @@ -938,14 +1038,11 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) // ignore this click and let media plugin handle it break; default: - if(gSavedSettings.getBOOL("MediaEnablePopups")) - { - - LLNotificationsUtil::add("PopupAttempt", - LLSD(), - LLSD().with("source", mMediaID).with("target", target).with("url", url), - boost::bind(&LLMediaCtrl::onPopup, this, _1, _2)); - } + LLNotificationPtr popup_notify = LLNotifications::instance().add("PopupAttempt", + LLSD(), + LLSD().with("target", target).with("url", url), + boost::bind(&LLMediaCtrl::onPopup, this, _1, _2)); + showNotification(popup_notify); break; } }; @@ -1005,3 +1102,100 @@ void LLMediaCtrl::onPopup(const LLSD& notification, const LLSD& response) LLWeb::loadURL(notification["payload"]["url"], notification["payload"]["target"]); } } + +void LLMediaCtrl::onCloseNotification() +{ + LLNotifications::instance().cancel(mCurNotification); +} + +void LLMediaCtrl::onClickIgnore(LLUICtrl* ctrl) +{ + bool check = ctrl->getValue().asBoolean(); + if (mCurNotification && mCurNotification->getForm()->getIgnoreType() == LLNotificationForm::IGNORE_SHOW_AGAIN) + { + // question was "show again" so invert value to get "ignore" + check = !check; + } + mCurNotification->setIgnored(check); +} + +void LLMediaCtrl::onClickNotificationButton(const std::string& name) +{ + if (!mCurNotification) return; + + LLSD response = mCurNotification->getResponseTemplate(); + response[name] = true; + + mCurNotification->respond(response); +} + +void LLMediaCtrl::showNotification(LLNotificationPtr notify) +{ + mCurNotification = notify; + + // add popup here + LLSD payload = notify->getPayload(); + + LLNotificationFormPtr formp = notify->getForm(); + LLLayoutPanel& panel = getChildRef("notification_area"); + panel.setVisible(true); + panel.getChild("notification_icon")->setValue(notify->getIcon()); + panel.getChild("notification_text")->setValue(notify->getMessage()); + panel.getChild("notification_text")->setToolTip(notify->getMessage()); + LLNotificationForm::EIgnoreType ignore_type = formp->getIgnoreType(); + LLLayoutPanel& form_elements = panel.getChildRef("form_elements"); + form_elements.deleteAllChildren(); + + const S32 FORM_PADDING_HORIZONTAL = 10; + const S32 FORM_PADDING_VERTICAL = 3; + S32 cur_x = FORM_PADDING_HORIZONTAL; + + if (ignore_type != LLNotificationForm::IGNORE_NO) + { + LLCheckBoxCtrl::Params checkbox_p; + checkbox_p.name = "ignore_check"; + checkbox_p.rect = LLRect(cur_x, form_elements.getRect().getHeight() - FORM_PADDING_VERTICAL, cur_x, FORM_PADDING_VERTICAL); + checkbox_p.label = formp->getIgnoreMessage(); + checkbox_p.label_text.text_color = LLColor4::black; + checkbox_p.commit_callback.function = boost::bind(&LLMediaCtrl::onClickIgnore, this, _1); + checkbox_p.initial_value = formp->getIgnored(); + + LLCheckBoxCtrl* check = LLUICtrlFactory::create(checkbox_p); + check->setRect(check->getBoundingRect()); + form_elements.addChild(check); + cur_x = check->getRect().mRight + FORM_PADDING_HORIZONTAL; + } + + for (S32 i = 0; i < formp->getNumElements(); i++) + { + LLSD form_element = formp->getElement(i); + if (form_element["type"].asString() == "button") + { + LLButton::Params button_p; + button_p.name = form_element["name"]; + button_p.label = form_element["text"]; + button_p.rect = LLRect(cur_x, form_elements.getRect().getHeight() - FORM_PADDING_VERTICAL, cur_x, FORM_PADDING_VERTICAL); + button_p.click_callback.function = boost::bind(&LLMediaCtrl::onClickNotificationButton, this, form_element["name"].asString()); + button_p.auto_resize = true; + + LLButton* button = LLUICtrlFactory::create(button_p); + button->autoResize(); + form_elements.addChild(button); + + cur_x = button->getRect().mRight + FORM_PADDING_HORIZONTAL; + } + } + + + form_elements.reshape(cur_x, form_elements.getRect().getHeight()); + + //LLWeb::loadURL(payload["url"], payload["target"]); +} + +void LLMediaCtrl::hideNotification() +{ + LLLayoutPanel& panel = getChildRef("notification_area"); + panel.setVisible(FALSE); + + mCurNotification.reset(); +} diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h index 3ba2904003..7008fa893e 100644 --- a/indra/newview/llmediactrl.h +++ b/indra/newview/llmediactrl.h @@ -140,8 +140,9 @@ public: bool getDecoupleTextureSize() { return mDecoupleTextureSize; } void setTextureSize(S32 width, S32 height); - void setMediaID(const std::string& id) { mMediaID = id; } + void showNotification(boost::shared_ptr notify); + void hideNotification(); // over-rides virtual BOOL handleKeyHere( KEY key, MASK mask); @@ -164,6 +165,9 @@ public: private: void onVisibilityChange ( const LLSD& new_visibility ); void onPopup(const LLSD& notification, const LLSD& response); + void onCloseNotification(); + void onClickNotificationButton(const std::string& name); + void onClickIgnore(LLUICtrl* ctrl); const S32 mTextureDepthBytes; LLUUID mMediaTextureID; @@ -185,8 +189,8 @@ public: bool mDecoupleTextureSize; S32 mTextureWidth; S32 mTextureHeight; - std::string mMediaID; bool mClearCache; + boost::shared_ptr mCurNotification; }; #endif // LL_LLMediaCtrl_H diff --git a/indra/newview/skins/default/xui/en/floater_media_browser.xml b/indra/newview/skins/default/xui/en/floater_media_browser.xml index c220124f46..1cb8613eb4 100644 --- a/indra/newview/skins/default/xui/en/floater_media_browser.xml +++ b/indra/newview/skins/default/xui/en/floater_media_browser.xml @@ -200,76 +200,6 @@ name="browser" top="0" width="540" /> - - - - - - - - - -