popup blocking notifications now handled in all web_browser instances, not just llfloatermediabrowser

master
Richard Linden 2010-09-16 16:29:53 -07:00
parent b24071ca89
commit d2a0327b6e
9 changed files with 231 additions and 211 deletions

View File

@ -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<LLFloaterMediaBrowser*>(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;
}

View File

@ -144,16 +144,12 @@ void LLFloaterMediaBrowser::draw()
BOOL LLFloaterMediaBrowser::postBuild()
{
mBrowser = getChild<LLMediaCtrl>("browser");
mBrowser->setMediaID(mKey);
mBrowser->addObserver(this);
mAddressCombo = getChild<LLComboBox>("address");
mAddressCombo->setCommitCallback(onEnterAddress, this);
mAddressCombo->sortByName();
LLButton& notification_close = getChildRef<LLButton>("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<LLLayoutPanel>("notification_area");
panel.setVisible(true);
panel.getChild<LLUICtrl>("notification_icon")->setValue(notify->getIcon());
panel.getChild<LLUICtrl>("notification_text")->setValue(notify->getMessage());
panel.getChild<LLUICtrl>("notification_text")->setToolTip(notify->getMessage());
LLNotificationForm::EIgnoreType ignore_type = formp->getIgnoreType();
LLLayoutPanel& form_elements = panel.getChildRef<LLLayoutPanel>("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<LLCheckBoxCtrl>(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<LLButton>(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<LLLayoutPanel>("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);
}

View File

@ -56,8 +56,6 @@ public:
void buildURLHistory();
std::string getSupportURL();
void setCurrentURL(const std::string& url);
void showNotification(boost::shared_ptr<LLNotification> 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;

View File

@ -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);
}
}
}

View File

@ -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<LLLayoutStack>(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<LLLayoutPanel>(panel_p);
stackp->addChild(notification_panel);
panel_p = LLUICtrlFactory::getDefaultParams<LLLayoutPanel>();
panel_p.auto_resize = true;
panel_p.mouse_opaque = false;
LLLayoutPanel* dummy_panel = LLUICtrlFactory::create<LLLayoutPanel>(panel_p);
stackp->addChild(dummy_panel);
layout_p = LLUICtrlFactory::getDefaultParams<LLLayoutStack>();
layout_p.rect = LLRect(0, 30, 800, 0);
layout_p.follows.flags = FOLLOWS_ALL;
layout_p.orientation = "horizontal";
stackp = LLUICtrlFactory::create<LLLayoutStack>(layout_p);
notification_panel->addChild(stackp);
panel_p = LLUICtrlFactory::getDefaultParams<LLLayoutPanel>();
panel_p.rect.height = 30;
LLLayoutPanel* panel = LLUICtrlFactory::create<LLLayoutPanel>(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<LLIconCtrl>(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<LLTextBox>(text_p));
panel_p = LLUICtrlFactory::getDefaultParams<LLLayoutPanel>();
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<LLLayoutPanel>(panel_p);
stackp->addChild(form_elements_panel);
panel_p = LLUICtrlFactory::getDefaultParams<LLLayoutPanel>();
panel_p.auto_resize = false;
panel_p.user_resize = false;
panel_p.rect = LLRect(0, 30, 25, 0);
LLLayoutPanel* close_panel = LLUICtrlFactory::create<LLLayoutPanel>(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<LLButton>(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<LLLayoutPanel>("notification_area");
panel.setVisible(true);
panel.getChild<LLUICtrl>("notification_icon")->setValue(notify->getIcon());
panel.getChild<LLUICtrl>("notification_text")->setValue(notify->getMessage());
panel.getChild<LLUICtrl>("notification_text")->setToolTip(notify->getMessage());
LLNotificationForm::EIgnoreType ignore_type = formp->getIgnoreType();
LLLayoutPanel& form_elements = panel.getChildRef<LLLayoutPanel>("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<LLCheckBoxCtrl>(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<LLButton>(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<LLLayoutPanel>("notification_area");
panel.setVisible(FALSE);
mCurNotification.reset();
}

View File

@ -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<class LLNotification> 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<class LLNotification> mCurNotification;
};
#endif // LL_LLMediaCtrl_H

View File

@ -200,76 +200,6 @@
name="browser"
top="0"
width="540" />
<layout_stack
name="notification_stack"
left="0"
top="0"
width="540"
bottom="-30"
follows="all"
mouse_opaque="false"
orientation="vertical">
<layout_panel
height="30"
min_height="30"
layout="topleft"
name="notification_area"
visible="false"
user_resize="false"
background_visible="true"
bg_alpha_image="Yellow_Gradient"
auto_resize="false"
width="800">
<layout_stack
top="0"
height="30"
width="800"
left="0"
follows="bottom|left|right"
orientation="horizontal">
<layout_panel
height="30">
<icon name="notification_icon"
left="5"
top="7"
width="16"
height="15"/>
<text left_pad="8"
top="10"
height="25"
width="400"
text_color="black"
font="SansSerifSmall"
font.style="BOLD"
name="notification_text"
value="Notification text here"/>
</layout_panel>
<layout_panel
height="30"
width="130"
auto_resize="false"
user_resize="false"
name="form_elements"/>
<layout_panel
height="30"
width="25"
auto_resize="false"
name="close_panel">
<button left="5"
name="close_notification"
width="16"
height="16"
top="8"
image_color="DkGray_66"
image_unselected="Icon_Close_Foreground"
image_selected="Icon_Close_Press"/>
</layout_panel>
</layout_stack>
</layout_panel>
<layout_panel
mouse_opaque="false"
auto_resize="true"/>
</layout_stack>
<button
follows="bottom|left"
height="20"

View File

@ -6461,14 +6461,13 @@ Mute everyone?
<unique/>
<form name="form">
<ignore name="ignore"
text="Enable all pop-ups"/>
control="MediaEnablePopups"
text="Enable all pop-ups"/>
<button default="true"
index="0"
name="open"
text="Open pop-up window"/>
</form>
</notification>

View File

@ -320,7 +320,19 @@
radio_style="false"
width="400"
top_pad="5"/>
<check_box
top_delta="4"
enabled="true"
follows="left|top"
height="14"
initial_value="false"
control_name="MediaEnablePopups"
label="Enable media browser pop-ups"
left_delta="0"
mouse_opaque="true"
name="media_popup_enabled"
width="400"
top_pad="5"/>
<check_box
top_delta="4"
enabled="true"