Cleanup LLNotify

Adds support for SUPPRESS_TOAST in payload to skip display of notices and just spew them to chat. (this was requested to be hooked up around last release, I think)
Fixes Singularity->Close All Dialogs breaking notifications such that the skip button would appear when not needed.

Cleans up a buncha dead code and silliness.
Also Cleanup LLGroupNotify because why not?
This commit is contained in:
Inusaito Sayori
2015-02-02 15:44:06 -05:00
parent 43e1aa9c01
commit 4b7bc99291
5 changed files with 194 additions and 386 deletions

View File

@@ -53,11 +53,9 @@
#include "llglheaders.h" #include "llglheaders.h"
#include "llagent.h" #include "llagent.h"
// Globals // Globals
//LLView* gGroupNotifyBoxView = NULL;
const F32 ANIMATION_TIME = 0.333f; const F32 ANIMATION_TIME = 0.333f;
S32 LLGroupNotifyBox::sGroupNotifyBoxCount = 0; static S32 sGroupNotifyBoxCount = 0;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -90,7 +88,7 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
const std::string& inventory_name, const std::string& inventory_name,
const LLSD& inventory_offer) const LLSD& inventory_offer)
: LLPanel("groupnotify", LLGroupNotifyBox::getGroupNotifyRect(), BORDER_YES), : LLPanel("groupnotify", LLGroupNotifyBox::getGroupNotifyRect(), BORDER_YES),
mAnimating(TRUE), mAnimating(true),
mTimer(), mTimer(),
mGroupID(group_id), mGroupID(group_id),
mHasInventory(has_inventory), mHasInventory(has_inventory),
@@ -123,9 +121,6 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
setBackgroundOpaque(TRUE); setBackgroundOpaque(TRUE);
setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") ); setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") );
LLIconCtrl* icon;
LLTextEditor* text;
S32 y = TOP; S32 y = TOP;
S32 x = HPAD + HPAD; S32 x = HPAD + HPAD;
@@ -159,18 +154,9 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
x = HPAD + HPAD; x = HPAD + HPAD;
// TODO: change this to be the group icon. // TODO: change this to be the group icon.
if (!group_insignia.isNull()) LLIconCtrl* icon = new LLIconCtrl(std::string("icon"),
{ LLRect(x, y, x+ICON_WIDTH, y-ICON_WIDTH),
icon = new LLIconCtrl(std::string("icon"), group_insignia.isNull() ? "notify_box_icon.tga" : group_insignia.asString());
LLRect(x, y, x+ICON_WIDTH, y-ICON_WIDTH),
group_insignia.asString());
}
else
{
icon = new LLIconCtrl(std::string("icon"),
LLRect(x, y, x+ICON_WIDTH, y-ICON_WIDTH),
std::string("notify_box_icon.tga"));
}
icon->setMouseOpaque(FALSE); icon->setMouseOpaque(FALSE);
addChild(icon); addChild(icon);
@@ -179,7 +165,7 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
// If we have inventory with this message, leave room for the name. // If we have inventory with this message, leave room for the name.
S32 box_bottom = BTN_TOP + (mHasInventory ? (LINE_HEIGHT + 2*VPAD) : 0); S32 box_bottom = BTN_TOP + (mHasInventory ? (LINE_HEIGHT + 2*VPAD) : 0);
text = new LLViewerTextEditor(std::string("box"), LLTextEditor* text = new LLViewerTextEditor(std::string("box"),
LLRect(x, y, RIGHT, box_bottom), LLRect(x, y, RIGHT, box_bottom),
DB_GROUP_NOTICE_MSG_STR_LEN, DB_GROUP_NOTICE_MSG_STR_LEN,
LLStringUtil::null, LLStringUtil::null,
@@ -217,45 +203,42 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
if (mHasInventory) if (mHasInventory)
{ {
addChild(new NoticeText(std::string("subjecttitle"),LLRect(x,y,x + LABEL_WIDTH,y - LINE_HEIGHT),LLTrans::getString("GroupNotifyAttached"),LLFontGL::getFontSansSerif())); addChild(new NoticeText(std::string("subjecttitle"),LLRect(x,y,x + LABEL_WIDTH,y - LINE_HEIGHT),LLTrans::getString("GroupNotifyAttached"),LLFontGL::getFontSansSerif()));
LLUIImagePtr item_icon = LLInventoryIcon::getIcon(mInventoryOffer->mType, LLUIImagePtr item_icon = LLInventoryIcon::getIcon(mInventoryOffer->mType,
LLInventoryType::IT_TEXTURE, LLInventoryType::IT_TEXTURE,
0, FALSE); 0, FALSE);
x += LABEL_WIDTH + HPAD;
x += LABEL_WIDTH + HPAD; std::stringstream ss;
ss << " " << inventory_name;
LLTextBox *line = new LLTextBox(std::string("object_name"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),ss.str(),LLFontGL::getFontSansSerif());
line->setEnabled(FALSE);
line->setBorderVisible(TRUE);
line->setDisabledColor(LLColor4::blue4);
line->setFontStyle(LLFontGL::NORMAL);
line->setBackgroundVisible(true);
line->setBackgroundColor( semi_transparent );
addChild(line);
std::stringstream ss; icon = new LLIconCtrl(std::string("icon"),
ss << " " << inventory_name; LLRect(x, y, x+16, y-16),
LLTextBox *line = new LLTextBox(std::string("object_name"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),ss.str(),LLFontGL::getFontSansSerif()); item_icon->getName());
line->setEnabled(FALSE); icon->setMouseOpaque(FALSE);
line->setBorderVisible(TRUE); addChild(icon);
line->setDisabledColor(LLColor4::blue4);
line->setFontStyle(LLFontGL::NORMAL);
line->setBackgroundVisible(true);
line->setBackgroundColor( semi_transparent );
addChild(line);
icon = new LLIconCtrl(std::string("icon"),
LLRect(x, y, x+16, y-16),
item_icon->getName());
icon->setMouseOpaque(FALSE);
addChild(icon);
} }
LLButton* btn; mNextBtn = new LLButton(LLTrans::getString("next"),
btn = new LLButton(LLTrans::getString("next"),
LLRect(getRect().getWidth()-26, BOTTOM_PAD + 20, getRect().getWidth()-2, BOTTOM_PAD), LLRect(getRect().getWidth()-26, BOTTOM_PAD + 20, getRect().getWidth()-2, BOTTOM_PAD),
std::string("notify_next.png"), std::string("notify_next.png"),
std::string("notify_next.png"), std::string("notify_next.png"),
LLStringUtil::null, LLStringUtil::null,
boost::bind(&LLGroupNotifyBox::onClickNext, this), boost::bind(&LLGroupNotifyBox::moveToBack, this),
LLFontGL::getFontSansSerif()); LLFontGL::getFontSansSerif());
btn->setToolTip(LLTrans::getString("next")); mNextBtn->setToolTip(LLTrans::getString("next"));
btn->setScaleImage(TRUE); mNextBtn->setScaleImage(TRUE);
addChild(btn); addChild(mNextBtn);
mNextBtn = btn;
S32 btn_width = 80; S32 btn_width = 80;
S32 wide_btn_width = 136; S32 wide_btn_width = 136;
@@ -267,13 +250,12 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
btn_width, btn_width,
BTN_HEIGHT); BTN_HEIGHT);
btn = new LLButton(LLTrans::getString("ok"), btn_rect, LLStringUtil::null, boost::bind(&LLGroupNotifyBox::onClickOk,this)); LLButton* btn = new LLButton(LLTrans::getString("ok"), btn_rect, LLStringUtil::null, boost::bind(&LLGroupNotifyBox::close, this));
addChild(btn, -1); addChild(btn, -1);
setDefaultBtn(btn); setDefaultBtn(btn);
x += btn_width + HPAD; x += btn_width + HPAD;
btn_rect.setOriginAndSize(x, btn_rect.setOriginAndSize(x,
BOTTOM_PAD, BOTTOM_PAD,
wide_btn_width, wide_btn_width,
@@ -292,27 +274,14 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
wide_btn_width, wide_btn_width,
BTN_HEIGHT); BTN_HEIGHT);
std::string btn_lbl(""); mSaveInventoryBtn = new LLButton(LLTrans::getString(is_openable(mInventoryOffer->mType) ? "GroupNotifyOpenAttachment" : "GroupNotifySaveAttachment"), btn_rect, LLStringUtil::null, boost::bind(&LLGroupNotifyBox::onClickSaveInventory,this));
if(is_openable(mInventoryOffer->mType))
{
btn_lbl = LLTrans::getString("GroupNotifyOpenAttachment");
}
else
{
btn_lbl = LLTrans::getString("GroupNotifySaveAttachment");
}
mSaveInventoryBtn = new LLButton(btn_lbl, btn_rect, LLStringUtil::null, boost::bind(&LLGroupNotifyBox::onClickSaveInventory,this));
mSaveInventoryBtn->setVisible(mHasInventory); mSaveInventoryBtn->setVisible(mHasInventory);
addChild(mSaveInventoryBtn); addChild(mSaveInventoryBtn);
} }
sGroupNotifyBoxCount++;
// If this is the only notify box, don't show the next button // If this is the only notify box, don't show the next button
if (sGroupNotifyBoxCount == 1) if (++sGroupNotifyBoxCount == 1)
{ mNextBtn->setVisible(false);
mNextBtn->setVisible(FALSE);
}
} }
@@ -352,7 +321,7 @@ void LLGroupNotifyBox::draw()
} }
else else
{ {
mAnimating = FALSE; mAnimating = false;
LLPanel::draw(); LLPanel::draw();
} }
} }
@@ -363,11 +332,11 @@ void LLGroupNotifyBox::close()
// The group notice dialog may be an inventory offer. // The group notice dialog may be an inventory offer.
// If it has an inventory save button and that button is still enabled // If it has an inventory save button and that button is still enabled
// Then we need to send the inventory declined message // Then we need to send the inventory declined message
if(mHasInventory) if (mHasInventory)
{ {
mInventoryOffer->forceResponse(IOR_DECLINE); mInventoryOffer->forceResponse(IOR_DECLINE);
mInventoryOffer = NULL; mInventoryOffer = NULL;
mHasInventory = FALSE; mHasInventory = false;
} }
gNotifyBoxView->removeChild(this); gNotifyBoxView->removeChild(this);
@@ -384,9 +353,7 @@ void LLGroupNotifyBox::initClass()
//static //static
bool LLGroupNotifyBox::onNewNotification(const LLSD& notify) bool LLGroupNotifyBox::onNewNotification(const LLSD& notify)
{ {
LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID()); if (LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID()))
if (notification)
{ {
const LLSD& payload = notification->getPayload(); const LLSD& payload = notification->getPayload();
// Get the group data // Get the group data
@@ -397,8 +364,7 @@ bool LLGroupNotifyBox::onNewNotification(const LLSD& notify)
return false; return false;
} }
LLGroupNotifyBox* self; gNotifyBoxView->addChild(new LLGroupNotifyBox(payload["subject"].asString(),
self = new LLGroupNotifyBox(payload["subject"].asString(),
payload["message"].asString(), payload["message"].asString(),
payload["sender_name"].asString(), payload["sender_name"].asString(),
payload["group_id"].asUUID(), payload["group_id"].asUUID(),
@@ -407,8 +373,7 @@ bool LLGroupNotifyBox::onNewNotification(const LLSD& notify)
notification->getDate(), notification->getDate(),
payload["inventory_offer"].isDefined(), payload["inventory_offer"].isDefined(),
payload["inventory_name"].asString(), payload["inventory_name"].asString(),
payload["inventory_offer"]); payload["inventory_offer"]));
gNotifyBoxView->addChild(self);
} }
return false; return false;
} }
@@ -424,14 +389,12 @@ void LLGroupNotifyBox::moveToBack()
if (sGroupNotifyBoxCount > 1) if (sGroupNotifyBoxCount > 1)
{ {
LLView* view = gNotifyBoxView->getFirstChild(); LLView* view = gNotifyBoxView->getFirstChild();
if (view && "groupnotify" == view->getName())
if(view && "groupnotify" == view->getName())
{ {
LLGroupNotifyBox* front = (LLGroupNotifyBox*)view; LLGroupNotifyBox* front = static_cast<LLGroupNotifyBox*>(view);
if (front->mNextBtn)
if(front->mNextBtn)
{ {
front->mNextBtn->setVisible(TRUE); front->mNextBtn->setVisible(true);
} }
} }
} }
@@ -452,23 +415,13 @@ LLRect LLGroupNotifyBox::getGroupNotifyRect()
} }
void LLGroupNotifyBox::onClickOk()
{
close();
}
void LLGroupNotifyBox::onClickSaveInventory() void LLGroupNotifyBox::onClickSaveInventory()
{ {
mInventoryOffer->forceResponse(IOR_ACCEPT); mInventoryOffer->forceResponse(IOR_ACCEPT);
mInventoryOffer = NULL; mInventoryOffer = NULL;
mHasInventory = FALSE; mHasInventory = false;
// Each item can only be received once, so disable the button. // Each item can only be received once, so disable the button.
mSaveInventoryBtn->setEnabled(FALSE); mSaveInventoryBtn->setEnabled(FALSE);
} }
void LLGroupNotifyBox::onClickNext()
{
moveToBack();
}

View File

@@ -52,7 +52,6 @@ public:
void close(); void close();
static void initClass(); static void initClass();
static void destroyClass();
static bool onNewNotification(const LLSD& notification); static bool onNewNotification(const LLSD& notification);
protected: protected:
@@ -72,11 +71,6 @@ protected:
/*virtual*/ ~LLGroupNotifyBox(); /*virtual*/ ~LLGroupNotifyBox();
// JC - removed support for clicking in background to dismiss
// the dialogs.
// /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
// /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
// /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
// Animate as sliding onto the screen. // Animate as sliding onto the screen.
@@ -89,15 +83,11 @@ protected:
static LLRect getGroupNotifyRect(); static LLRect getGroupNotifyRect();
// internal handler for button being clicked // internal handler for button being clicked
void onClickOk();
void onClickSaveInventory(); void onClickSaveInventory();
// for "next" button
void onClickNext();
private: private:
// Are we sliding onscreen? // Are we sliding onscreen?
BOOL mAnimating; bool mAnimating;
// Time since this notification was displayed. // Time since this notification was displayed.
// This is an LLTimer not a frame timer because I am concerned // This is an LLTimer not a frame timer because I am concerned
@@ -107,17 +97,9 @@ private:
LLButton* mNextBtn; LLButton* mNextBtn;
LLButton* mSaveInventoryBtn; LLButton* mSaveInventoryBtn;
static S32 sGroupNotifyBoxCount;
LLUUID mGroupID; LLUUID mGroupID;
BOOL mHasInventory; bool mHasInventory;
LLOfferInfo* mInventoryOffer; LLOfferInfo* mInventoryOffer;
}; };
// This view contains the stack of notification windows.
//extern LLView* gGroupNotifyBoxView;
const S32 GROUP_LAYOUT_DEFAULT = 0;
const S32 GROUP_LAYOUT_SCRIPT_DIALOG = 1;
#endif #endif

View File

@@ -69,11 +69,22 @@ const S32 BOTTOM_PAD = VPAD * 3;
// statics // statics
S32 LLNotifyBox::sNotifyBoxCount = 0; S32 sNotifyBoxCount = 0;
const LLFontGL* LLNotifyBox::sFont = NULL; static const LLFontGL* sFont = NULL;
const LLFontGL* LLNotifyBox::sFontSmall = NULL;
std::map<std::string, LLNotifyBox*> LLNotifyBox::sOpenUniqueNotifyBoxes;
void chat_notification(const LLNotificationPtr notification)
{
// TODO: Make a separate archive for these.
if (gSavedSettings.getBOOL("HideNotificationsInChat")) return;
LLChat chat(notification->getMessage());
chat.mSourceType = CHAT_SOURCE_SYSTEM;
// [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0e) | Added: RLVa-0.2.0b
// Notices should already have their contents filtered where necessary
if (rlv_handler_t::isEnabled())
chat.mRlvLocFiltered = chat.mRlvNamesFiltered = true;
// [/RLVa:KB]
LLFloaterChat::getInstance()->addChatHistory(chat);
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// LLNotifyBox // LLNotifyBox
@@ -82,6 +93,7 @@ std::map<std::string, LLNotifyBox*> LLNotifyBox::sOpenUniqueNotifyBoxes;
//static //static
void LLNotifyBox::initClass() void LLNotifyBox::initClass()
{ {
sFont = LLFontGL::getFontSansSerif();
LLNotificationChannel::buildChannel("Notifications", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "notify")); LLNotificationChannel::buildChannel("Notifications", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "notify"));
LLNotificationChannel::buildChannel("NotificationTips", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "notifytip")); LLNotificationChannel::buildChannel("NotificationTips", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "notifytip"));
@@ -96,8 +108,13 @@ bool LLNotifyBox::onNotification(const LLSD& notify)
if (!notification) return false; if (!notification) return false;
if(notify["sigtype"].asString() == "add" || notify["sigtype"].asString() == "change") if (notify["sigtype"].asString() == "add" || notify["sigtype"].asString() == "change")
{ {
if (notification->getPayload().has("SUPPRESS_TOAST"))
{
chat_notification(notification);
return false;
}
//bring existing notification to top //bring existing notification to top
//This getInstance is ugly, as LLNotifyBox is derived from both LLInstanceTracker and LLEventTimer, which also is derived from its own LLInstanceTracker //This getInstance is ugly, as LLNotifyBox is derived from both LLInstanceTracker and LLEventTimer, which also is derived from its own LLInstanceTracker
//Have to explicitly determine which getInstance function to use. //Have to explicitly determine which getInstance function to use.
@@ -108,12 +125,7 @@ bool LLNotifyBox::onNotification(const LLSD& notify)
} }
else else
{ {
bool is_script_dialog = (notification->getName() == "ScriptDialog" || notification->getName() == "ScriptDialogGroup"); gNotifyBoxView->addChild(new LLNotifyBox(notification));
LLNotifyBox* notify_box = new LLNotifyBox(
notification,
is_script_dialog); //layout_script_dialog);
gNotifyBoxView->addChild(notify_box);
} }
} }
else if (notify["sigtype"].asString() == "delete") else if (notify["sigtype"].asString() == "delete")
@@ -129,8 +141,8 @@ bool LLNotifyBox::onNotification(const LLSD& notify)
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
LLNotifyBox::LLNotifyBox(LLNotificationPtr notification, // Singu Note: We could clean a lot of this up by creating derived classes for Notifications and NotificationTips.
BOOL layout_script_dialog) LLNotifyBox::LLNotifyBox(LLNotificationPtr notification)
: LLPanel(notification->getName(), LLRect(), BORDER_NO), : LLPanel(notification->getName(), LLRect(), BORDER_NO),
LLEventTimer(notification->getExpiration() == LLDate() LLEventTimer(notification->getExpiration() == LLDate()
? LLDate(LLDate::now().secondsSinceEpoch() + (F64)gSavedSettings.getF32("NotifyTipDuration")) ? LLDate(LLDate::now().secondsSinceEpoch() + (F64)gSavedSettings.getF32("NotifyTipDuration"))
@@ -138,25 +150,18 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
LLInstanceTracker<LLNotifyBox, LLUUID>(notification->getID()), LLInstanceTracker<LLNotifyBox, LLUUID>(notification->getID()),
mNotification(notification), mNotification(notification),
mIsTip(notification->getType() == "notifytip"), mIsTip(notification->getType() == "notifytip"),
mAnimating(TRUE), mAnimating(gNotifyBoxView->getChildCount() == 0), // Only animate first window
mNextBtn(NULL), mNextBtn(NULL),
mNumOptions(0), mNumOptions(0),
mNumButtons(0), mNumButtons(0),
mAddedDefaultBtn(FALSE), mAddedDefaultBtn(false),
mLayoutScriptDialog(layout_script_dialog),
mUserInputBox(NULL) mUserInputBox(NULL)
{ {
std::string edit_text_name; std::string edit_text_name;
std::string edit_text_contents; std::string edit_text_contents;
// class init
{
sFont = LLFontGL::getFontSansSerif();
sFontSmall = LLFontGL::getFontSansSerifSmall();
}
// setup paramaters // setup paramaters
mMessage = notification->getMessage(); const std::string& message(notification->getMessage());
// initialize // initialize
setFocusRoot(!mIsTip); setFocusRoot(!mIsTip);
@@ -169,19 +174,14 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
// they display the tip in a different color // they display the tip in a different color
mIsCaution = notification->getPriority() >= NOTIFICATION_PRIORITY_HIGH; mIsCaution = notification->getPriority() >= NOTIFICATION_PRIORITY_HIGH;
// Only animate first window
if( gNotifyBoxView->getChildCount() > 0 )
mAnimating = FALSE;
else
mAnimating = TRUE;
LLNotificationFormPtr form(notification->getForm()); LLNotificationFormPtr form(notification->getForm());
mNumOptions = form->getNumElements(); mNumOptions = form->getNumElements();
bool is_textbox = form->getElement("message").isDefined(); bool is_textbox = form->getElement("message").isDefined();
LLRect rect = mIsTip ? getNotifyTipRect(mMessage) bool layout_script_dialog(notification->getName() == "ScriptDialog" || notification->getName() == "ScriptDialogGroup");
LLRect rect = mIsTip ? getNotifyTipRect(message)
: getNotifyRect(is_textbox ? 10 : mNumOptions, layout_script_dialog, mIsCaution); : getNotifyRect(is_textbox ? 10 : mNumOptions, layout_script_dialog, mIsCaution);
setRect(rect); setRect(rect);
setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT)); setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT));
@@ -250,7 +250,7 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
const S32 MAX_LENGTH = 512 + 20 + DB_FIRST_NAME_BUF_SIZE + DB_LAST_NAME_BUF_SIZE + DB_INV_ITEM_NAME_BUF_SIZE; // For script dialogs: add space for title. const S32 MAX_LENGTH = 512 + 20 + DB_FIRST_NAME_BUF_SIZE + DB_LAST_NAME_BUF_SIZE + DB_INV_ITEM_NAME_BUF_SIZE; // For script dialogs: add space for title.
text = new LLTextEditor(std::string("box"), LLRect(x, y, getRect().getWidth()-2, mIsTip ? BOTTOM : BTN_TOP+16), MAX_LENGTH, mMessage, sFont, FALSE); text = new LLTextEditor(std::string("box"), LLRect(x, y, getRect().getWidth()-2, mIsTip ? BOTTOM : BTN_TOP+16), MAX_LENGTH, message, sFont, FALSE);
text->setWordWrap(TRUE); text->setWordWrap(TRUE);
text->setTabStop(FALSE); text->setTabStop(FALSE);
text->setMouseOpaque(FALSE); text->setMouseOpaque(FALSE);
@@ -267,11 +267,9 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
} }
else else
{ {
const S32 BTN_TOP = BOTTOM_PAD + (((mNumOptions-1+2)/3)) * (BTN_HEIGHT+VPAD); const S32 BTN_TOP = BOTTOM_PAD + (((mNumOptions-1+2)/3)) * (BTN_HEIGHT+VPAD);
// Tokenization on \n is handled by LLTextBox // Tokenization on \n is handled by LLTextBox
const S32 MAX_LENGTH = 512 + 20 + const S32 MAX_LENGTH = 512 + 20 +
DB_FIRST_NAME_BUF_SIZE + DB_FIRST_NAME_BUF_SIZE +
DB_LAST_NAME_BUF_SIZE + DB_LAST_NAME_BUF_SIZE +
@@ -280,7 +278,7 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
text = new LLTextEditor(std::string("box"), text = new LLTextEditor(std::string("box"),
LLRect(x, y, getRect().getWidth()-2, mIsTip ? BOTTOM : BTN_TOP+16), LLRect(x, y, getRect().getWidth()-2, mIsTip ? BOTTOM : BTN_TOP+16),
MAX_LENGTH, MAX_LENGTH,
mMessage, message,
sFont, sFont,
FALSE); FALSE);
text->setWordWrap(TRUE); text->setWordWrap(TRUE);
@@ -300,54 +298,39 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
if (mIsTip) if (mIsTip)
{ {
// TODO: Make a separate archive for these. chat_notification(mNotification);
LLChat chat(mMessage);
chat.mSourceType = CHAT_SOURCE_SYSTEM;
// [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0e) | Added: RLVa-0.2.0b
if (rlv_handler_t::isEnabled())
{
// Notices should already have their contents filtered where necessary
chat.mRlvLocFiltered = chat.mRlvNamesFiltered = TRUE;
}
// [/RLVa:KB]
if (!gSavedSettings.getBOOL("HideNotificationsInChat")) {
LLFloaterChat::getInstance(LLSD())->addChatHistory(chat);
}
} }
else else
{ {
LLButton* btn; mNextBtn = new LLButton(std::string("next"),
btn = new LLButton(std::string("next"),
LLRect(getRect().getWidth()-26, BOTTOM_PAD + 20, getRect().getWidth()-2, BOTTOM_PAD), LLRect(getRect().getWidth()-26, BOTTOM_PAD + 20, getRect().getWidth()-2, BOTTOM_PAD),
std::string("notify_next.png"), std::string("notify_next.png"),
std::string("notify_next.png"), std::string("notify_next.png"),
LLStringUtil::null, LLStringUtil::null,
boost::bind(&LLNotifyBox::onClickNext,this), boost::bind(&LLNotifyBox::moveToBack, this, true),
sFont); sFont);
btn->setScaleImage(TRUE); mNextBtn->setScaleImage(TRUE);
btn->setToolTip(LLTrans::getString("next")); mNextBtn->setToolTip(LLTrans::getString("next"));
addChild(btn); addChild(mNextBtn);
mNextBtn = btn;
for (S32 i = 0; i < mNumOptions; i++) for (S32 i = 0; i < mNumOptions; i++)
{ {
LLSD form_element = form->getElement(i); LLSD form_element = form->getElement(i);
std::string element_type = form_element["type"].asString(); std::string element_type = form_element["type"].asString();
if (element_type == "button") if (element_type == "button")
{ {
addButton(form_element["name"].asString(), form_element["text"].asString(), TRUE, form_element["default"].asBoolean()); addButton(form_element["name"].asString(), form_element["text"].asString(), TRUE, form_element["default"].asBoolean(), layout_script_dialog);
} }
else if (element_type == "input") else if (element_type == "input")
{ {
edit_text_contents = form_element["value"].asString(); edit_text_contents = form_element["value"].asString();
edit_text_name = form_element["name"].asString(); edit_text_name = form_element["name"].asString();
} }
} }
if (is_textbox) if (is_textbox)
{ {
S32 button_rows = (layout_script_dialog) ? 2 : 1; S32 button_rows = layout_script_dialog ? 2 : 1;
LLRect input_rect; LLRect input_rect;
input_rect.setOriginAndSize(x, BOTTOM_PAD + button_rows * (BTN_HEIGHT + VPAD), input_rect.setOriginAndSize(x, BOTTOM_PAD + button_rows * (BTN_HEIGHT + VPAD),
@@ -373,23 +356,15 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
if (mNumButtons == 0) if (mNumButtons == 0)
{ {
addButton("OK", "OK", FALSE, TRUE); addButton("OK", "OK", false, true, layout_script_dialog);
mAddedDefaultBtn = TRUE; mAddedDefaultBtn = true;
} }
sNotifyBoxCount++; if (++sNotifyBoxCount <= 0)
if (sNotifyBoxCount <= 0)
{
llwarns << "A notification was mishandled. sNotifyBoxCount = " << sNotifyBoxCount << llendl; llwarns << "A notification was mishandled. sNotifyBoxCount = " << sNotifyBoxCount << llendl;
}
// If this is the only notify box, don't show the next button // If this is the only notify box, don't show the next button
if (sNotifyBoxCount == 1 else if (sNotifyBoxCount == 1 && mNextBtn)
&& mNextBtn) mNextBtn->setVisible(false);
{
mNextBtn->setVisible(FALSE);
}
} }
} }
@@ -399,14 +374,13 @@ LLNotifyBox::~LLNotifyBox()
} }
// virtual // virtual
LLButton* LLNotifyBox::addButton(const std::string& name, const std::string& label, BOOL is_option, BOOL is_default) LLButton* LLNotifyBox::addButton(const std::string& name, const std::string& label, bool is_option, bool is_default, bool layout_script_dialog)
{ {
// make caution notification buttons slightly narrower // make caution notification buttons slightly narrower
// so that 3 of them can fit without overlapping the "next" button // so that 3 of them can fit without overlapping the "next" button
S32 btn_width = mIsCaution? 84 : 90; S32 btn_width = mIsCaution ? 84 : 90;
LLRect btn_rect; LLRect btn_rect;
LLButton* btn;
S32 btn_height= BTN_HEIGHT; S32 btn_height= BTN_HEIGHT;
const LLFontGL* font = sFont; const LLFontGL* font = sFont;
S32 ignore_pad = 0; S32 ignore_pad = 0;
@@ -414,7 +388,7 @@ LLButton* LLNotifyBox::addButton(const std::string& name, const std::string& lab
S32 index = button_index; S32 index = button_index;
S32 x = (HPAD * 4) + 32; S32 x = (HPAD * 4) + 32;
if (mLayoutScriptDialog) if (layout_script_dialog)
{ {
// Add two "blank" option spaces, before the "Ignore" button // Add two "blank" option spaces, before the "Ignore" button
index = button_index + 2; index = button_index + 2;
@@ -422,6 +396,7 @@ LLButton* LLNotifyBox::addButton(const std::string& name, const std::string& lab
{ {
// Ignore button is smaller, less wide // Ignore button is smaller, less wide
btn_height = BTN_HEIGHT_SMALL; btn_height = BTN_HEIGHT_SMALL;
static const LLFontGL* sFontSmall = LLFontGL::getFontSansSerifSmall();
font = sFontSmall; font = sFontSmall;
ignore_pad = 10; ignore_pad = 10;
} }
@@ -432,7 +407,7 @@ LLButton* LLNotifyBox::addButton(const std::string& name, const std::string& lab
btn_width - 2*ignore_pad, btn_width - 2*ignore_pad,
btn_height); btn_height);
btn = new LLButton(name, btn_rect, "", boost::bind(&LLNotifyBox::onClickButton, this, is_option ? name : "")); LLButton* btn = new LLButton(name, btn_rect, "", boost::bind(&LLNotifyBox::onClickButton, this, is_option ? name : ""));
btn->setLabel(label); btn->setLabel(label);
btn->setFont(font); btn->setFont(font);
@@ -445,9 +420,7 @@ LLButton* LLNotifyBox::addButton(const std::string& name, const std::string& lab
addChild(btn, -1); addChild(btn, -1);
if (is_default) if (is_default)
{
setDefaultBtn(btn); setDefaultBtn(btn);
}
mNumButtons++; mNumButtons++;
return btn; return btn;
@@ -486,14 +459,10 @@ void LLNotifyBox::draw()
{ {
// If we are teleporting, stop the timer and restart it when the teleporting completes // If we are teleporting, stop the timer and restart it when the teleporting completes
if (gTeleportDisplay) if (gTeleportDisplay)
{
mEventTimer.stop(); mEventTimer.stop();
}
else if (!mEventTimer.getStarted()) else if (!mEventTimer.getStarted())
{
mEventTimer.start(); mEventTimer.start();
}
F32 display_time = mAnimateTimer.getElapsedTimeF32(); F32 display_time = mAnimateTimer.getElapsedTimeF32();
if (mAnimating && display_time < ANIMATION_TIME) if (mAnimating && display_time < ANIMATION_TIME)
@@ -508,21 +477,18 @@ void LLNotifyBox::draw()
LLUI::translate(0.f, voffset, 0.f); LLUI::translate(0.f, voffset, 0.f);
drawBackground(); drawBackground();
LLPanel::draw(); LLPanel::draw();
LLUI::popMatrix(); LLUI::popMatrix();
} }
else else
{ {
if(mAnimating) if (mAnimating)
{ {
mAnimating = FALSE; mAnimating = false;
if(!mIsTip) if (!mIsTip)
{
// hide everyone behind me once I'm done animating // hide everyone behind me once I'm done animating
gNotifyBoxView->showOnly(this); gNotifyBoxView->showOnly(this);
}
} }
drawBackground(); drawBackground();
LLPanel::draw(); LLPanel::draw();
@@ -531,67 +497,52 @@ void LLNotifyBox::draw()
void LLNotifyBox::drawBackground() const void LLNotifyBox::drawBackground() const
{ {
LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga"); if (LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga"))
if (imagep)
{ {
gGL.getTexUnit(0)->bind(imagep->getImage()); gGL.getTexUnit(0)->bind(imagep->getImage());
// set proper background color depending on whether notify box is a caution or not // set proper background color depending on whether notify box is a caution or not
LLColor4 color = mIsCaution? gColors.getColor("NotifyCautionBoxColor") : gColors.getColor("NotifyBoxColor"); bool has_focus(gFocusMgr.childHasKeyboardFocus(this));
if(gFocusMgr.childHasKeyboardFocus( this )) if (has_focus)
{ {
const S32 focus_width = 2; const S32 focus_width = 2;
color = gColors.getColor("FloaterFocusBorderColor"); static const LLCachedControl<LLColor4> sBorder(gColors, "FloaterFocusBorderColor");
LLColor4 color = sBorder;
gGL.color4fv(color.mV); gGL.color4fv(color.mV);
gl_segmented_rect_2d_tex(-focus_width, getRect().getHeight() + focus_width, gl_segmented_rect_2d_tex(-focus_width, getRect().getHeight() + focus_width,
getRect().getWidth() + focus_width, -focus_width, getRect().getWidth() + focus_width, -focus_width,
imagep->getTextureWidth(), imagep->getTextureHeight(), imagep->getTextureWidth(), imagep->getTextureHeight(),
16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM); 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM);
color = gColors.getColor("ColorDropShadow"); static const LLCachedControl<LLColor4> sDropShadow(gColors, "ColorDropShadow");
gGL.color4fv(color.mV); color = sDropShadow;
gl_segmented_rect_2d_tex(0, getRect().getHeight(), getRect().getWidth(), 0, imagep->getTextureWidth(), imagep->getTextureHeight(), 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM);
if( mIsCaution )
color = gColors.getColor("NotifyCautionBoxColor");
else
color = gColors.getColor("NotifyBoxColor");
gGL.color4fv(color.mV);
gl_segmented_rect_2d_tex(1, getRect().getHeight()-1, getRect().getWidth()-1, 1, imagep->getTextureWidth(), imagep->getTextureHeight(), 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM);
}
else
{
gGL.color4fv(color.mV); gGL.color4fv(color.mV);
gl_segmented_rect_2d_tex(0, getRect().getHeight(), getRect().getWidth(), 0, imagep->getTextureWidth(), imagep->getTextureHeight(), 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM); gl_segmented_rect_2d_tex(0, getRect().getHeight(), getRect().getWidth(), 0, imagep->getTextureWidth(), imagep->getTextureHeight(), 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM);
} }
static const LLCachedControl<LLColor4> sCautionColor(gColors, "NotifyCautionBoxColor");
static const LLCachedControl<LLColor4> sColor(gColors, "NotifyBoxColor");
LLColor4 color = mIsCaution ? sCautionColor : sColor;
gGL.color4fv(color.mV);
gl_segmented_rect_2d_tex(has_focus, getRect().getHeight()-has_focus, getRect().getWidth()-has_focus, has_focus, imagep->getTextureWidth(), imagep->getTextureHeight(), 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM);
} }
} }
void LLNotifyBox::close() void LLNotifyBox::close()
{ {
BOOL isTipTmp = mIsTip;
if (!mIsTip) if (!mIsTip)
{ {
sNotifyBoxCount--; if (LLNotifyBox* front = gNotifyBoxView->getFirstNontipBox())
{
gNotifyBoxView->showOnly(front);
// we're assuming that close is only called by user action (for non-tips), so we then give focus to the next close button
if (LLView* view = front->getDefaultButton())
view->setFocus(true);
gFocusMgr.triggerFocusFlash(); // TODO it's ugly to call this here
}
--sNotifyBoxCount;
} }
die(); die();
if(!isTipTmp)
{
LLNotifyBox * front = gNotifyBoxView->getFirstNontipBox();
if(front)
{
gNotifyBoxView->showOnly(front);
// we're assuming that close is only called by user action (for non-tips),
// so we then give focus to the next close button
if (front->getDefaultButton())
{
front->getDefaultButton()->setFocus(TRUE);
}
gFocusMgr.triggerFocusFlash(); // TODO it's ugly to call this here
}
}
} }
void LLNotifyBox::format(std::string& msg, const LLStringUtil::format_map_t& args) void LLNotifyBox::format(std::string& msg, const LLStringUtil::format_map_t& args)
@@ -622,11 +573,8 @@ BOOL LLNotifyBox::tick()
void LLNotifyBox::setVisible(BOOL visible) void LLNotifyBox::setVisible(BOOL visible)
{ {
// properly set the status of the next button // properly set the status of the next button
if(visible && !mIsTip) if (visible && !mIsTip)
{
mNextBtn->setVisible(sNotifyBoxCount > 1); mNextBtn->setVisible(sNotifyBoxCount > 1);
mNextBtn->setEnabled(sNotifyBoxCount > 1);
}
LLPanel::setVisible(visible); LLPanel::setVisible(visible);
} }
@@ -634,35 +582,30 @@ void LLNotifyBox::moveToBack(bool getfocus)
{ {
// Move this dialog to the back. // Move this dialog to the back.
gNotifyBoxView->sendChildToBack(this); gNotifyBoxView->sendChildToBack(this);
if(!mIsTip && mNextBtn) if (!mIsTip && mNextBtn)
{ {
mNextBtn->setVisible(FALSE); mNextBtn->setVisible(false);
// And enable the next button on the frontmost one, if there is one // And enable the next button on the frontmost one, if there is one
if (gNotifyBoxView->getChildCount() > 0) if (gNotifyBoxView->getChildCount())
{ if (LLNotifyBox* front = gNotifyBoxView->getFirstNontipBox())
LLNotifyBox* front = gNotifyBoxView->getFirstNontipBox();
if (front)
{ {
gNotifyBoxView->showOnly(front); gNotifyBoxView->showOnly(front);
if (getfocus) if (getfocus)
{ {
// if are called from a user interaction // if are called from a user interaction
// we give focus to the next next button // we give focus to the next next button
if (front->mNextBtn != NULL) if (front->mNextBtn)
{ front->mNextBtn->setFocus(true);
front->mNextBtn->setFocus(TRUE);
}
gFocusMgr.triggerFocusFlash(); // TODO: it's ugly to call this here gFocusMgr.triggerFocusFlash(); // TODO: it's ugly to call this here
} }
} }
}
} }
} }
// static // static
LLRect LLNotifyBox::getNotifyRect(S32 num_options, BOOL layout_script_dialog, BOOL is_caution) LLRect LLNotifyBox::getNotifyRect(S32 num_options, bool layout_script_dialog, bool is_caution)
{ {
S32 notify_height = gSavedSettings.getS32("NotifyBoxHeight"); S32 notify_height = gSavedSettings.getS32("NotifyBoxHeight");
if (is_caution) if (is_caution)
@@ -680,15 +623,11 @@ LLRect LLNotifyBox::getNotifyRect(S32 num_options, BOOL layout_script_dialog, BO
const S32 LEFT = RIGHT - NOTIFY_WIDTH; const S32 LEFT = RIGHT - NOTIFY_WIDTH;
if (num_options < 1) if (num_options < 1)
{
num_options = 1; num_options = 1;
}
// Add two "blank" option spaces. // Add two "blank" option spaces.
if (layout_script_dialog) if (layout_script_dialog)
{
num_options += 2; num_options += 2;
}
S32 additional_lines = (num_options-1) / 3; S32 additional_lines = (num_options-1) / 3;
@@ -700,7 +639,6 @@ LLRect LLNotifyBox::getNotifyRect(S32 num_options, BOOL layout_script_dialog, BO
// static // static
LLRect LLNotifyBox::getNotifyTipRect(const std::string &utf8message) LLRect LLNotifyBox::getNotifyTipRect(const std::string &utf8message)
{ {
S32 line_count = 1;
LLWString message = utf8str_to_wstring(utf8message); LLWString message = utf8str_to_wstring(utf8message);
S32 message_len = message.length(); S32 message_len = message.length();
@@ -712,27 +650,24 @@ LLRect LLNotifyBox::getNotifyTipRect(const std::string &utf8message)
const llwchar* start = wchars; const llwchar* start = wchars;
const llwchar* end; const llwchar* end;
S32 total_drawn = 0; S32 total_drawn = 0;
BOOL done = FALSE; bool done = false;
S32 line_count;
do for (line_count = 2; !done; ++line_count)
{ {
line_count++; for (end = start; *end != 0 && *end != '\n'; end++);
for (end=start; *end != 0 && *end != '\n'; end++) if (*end == 0)
;
if( *end == 0 )
{ {
end = wchars + message_len; end = wchars + message_len;
done = TRUE; done = true;
} }
S32 remaining = end - start; for (S32 remaining = end - start; remaining;)
while( remaining )
{ {
S32 drawn = sFont->maxDrawableChars( start, (F32)text_area_width, remaining, LLFontGL::WORD_BOUNDARY_IF_POSSIBLE ); S32 drawn = sFont->maxDrawableChars(start, (F32)text_area_width, remaining, LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);
if( 0 == drawn ) if (0 == drawn)
{ {
drawn = 1; // Draw at least one character, even if it doesn't all fit. (avoids an infinite loop) drawn = 1; // Draw at least one character, even if it doesn't all fit. (avoids an infinite loop)
} }
@@ -740,10 +675,10 @@ LLRect LLNotifyBox::getNotifyTipRect(const std::string &utf8message)
total_drawn += drawn; total_drawn += drawn;
start += drawn; start += drawn;
remaining -= drawn; remaining -= drawn;
if( total_drawn < message_len ) if (total_drawn < message_len)
{ {
if( (wchars[ total_drawn ] != '\n') ) if (wchars[ total_drawn ] != '\n')
{ {
// wrap because line was too long // wrap because line was too long
line_count++; line_count++;
@@ -751,19 +686,18 @@ LLRect LLNotifyBox::getNotifyTipRect(const std::string &utf8message)
} }
else else
{ {
done = TRUE; done = true;
} }
} }
total_drawn++; // for '\n' total_drawn++; // for '\n'
end++; start = ++end;
start = end; }
} while( !done );
const S32 MIN_NOTIFY_HEIGHT = 72; const S32 MIN_NOTIFY_HEIGHT = 72;
const S32 MAX_NOTIFY_HEIGHT = 600; const S32 MAX_NOTIFY_HEIGHT = 600;
S32 notify_height = llceil((F32) (line_count+1) * sFont->getLineHeight()); S32 notify_height = llceil((F32) (line_count+1) * sFont->getLineHeight());
if(gOverlayBar) if (gOverlayBar)
{ {
notify_height += gOverlayBar->getBoundingRect().mTop; notify_height += gOverlayBar->getBoundingRect().mTop;
} }
@@ -799,18 +733,12 @@ void LLNotifyBox::onClickButton(const std::string name)
} }
void LLNotifyBox::onClickNext()
{
moveToBack(true);
}
LLNotifyBoxView::LLNotifyBoxView(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows) LLNotifyBoxView::LLNotifyBoxView(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows)
: LLUICtrl(name,rect,mouse_opaque,NULL,follows) : LLUICtrl(name,rect,mouse_opaque,NULL,follows)
{ {
} }
LLNotifyBox * LLNotifyBoxView::getFirstNontipBox() const LLNotifyBox* LLNotifyBoxView::getFirstNontipBox() const
{ {
// *TODO: Don't make assumptions like this! // *TODO: Don't make assumptions like this!
// assumes every child is a notify box // assumes every child is a notify box
@@ -819,50 +747,41 @@ LLNotifyBox * LLNotifyBoxView::getFirstNontipBox() const
iter++) iter++)
{ {
// hack! *TODO: Integrate llnotify and llgroupnotify // hack! *TODO: Integrate llnotify and llgroupnotify
if(isGroupNotifyBox(*iter)) if (isGroupNotifyBox(*iter))
{
continue; continue;
}
LLNotifyBox* box = static_cast<LLNotifyBox*>(*iter);
LLNotifyBox* box = (LLNotifyBox*)(*iter); if (!box->isTip() && !box->isDead())
if(!box->isTip() && !box->isDead())
{
return box; return box;
}
} }
return NULL; return NULL;
} }
void LLNotifyBoxView::showOnly(LLView * view) void LLNotifyBoxView::showOnly(LLView* view)
{ {
if(view) // assumes that the argument is actually a child
{ if (!dynamic_cast<LLNotifyBox*>(view)) return;
// assumes that the argument is actually a child
LLNotifyBox * shown = dynamic_cast<LLNotifyBox*>(view);
if(!shown)
{
return ;
}
// make every other notification invisible // make every other notification invisible
for(child_list_const_iter_t iter = getChildList()->begin(); for(child_list_const_iter_t iter = getChildList()->begin();
iter != getChildList()->end(); iter != getChildList()->end();
iter++) iter++)
{ {
if(isGroupNotifyBox(*iter)) if (view == (*iter)) continue;
{ LLView* view(*iter);
continue; if (isGroupNotifyBox(view) && !view->getVisible())
} continue;
if (!static_cast<LLNotifyBox*>(view)->isTip())
LLNotifyBox * box = (LLNotifyBox*)(*iter); view->setVisible(false);
if(box != view && box->getVisible() && !box->isTip())
{
box->setVisible(FALSE);
}
}
shown->setVisible(TRUE);
sendChildToFront(shown);
} }
view->setVisible(true);
sendChildToFront(view);
}
void LLNotifyBoxView::deleteAllChildren()
{
LLUICtrl::deleteAllChildren();
sNotifyBoxCount = 0;
} }
void LLNotifyBoxView::purgeMessagesMatching(const Matcher& matcher) void LLNotifyBoxView::purgeMessagesMatching(const Matcher& matcher)
@@ -874,13 +793,11 @@ void LLNotifyBoxView::purgeMessagesMatching(const Matcher& matcher)
iter != notification_queue.end(); iter != notification_queue.end();
iter++) iter++)
{ {
if(isGroupNotifyBox(*iter)) if (isGroupNotifyBox(*iter))
{
continue; continue;
}
LLNotifyBox* notification = (LLNotifyBox*)*iter; LLNotifyBox* notification = static_cast<LLNotifyBox*>(*iter);
if(matcher.matches(notification->getNotification())) if (matcher.matches(notification->getNotification()))
{ {
removeChild(notification); removeChild(notification);
} }
@@ -889,11 +806,6 @@ void LLNotifyBoxView::purgeMessagesMatching(const Matcher& matcher)
bool LLNotifyBoxView::isGroupNotifyBox(const LLView* view) const bool LLNotifyBoxView::isGroupNotifyBox(const LLView* view) const
{ {
if (view->getName() == "groupnotify") return view->getName() == "groupnotify";
{
return TRUE ;
}
return FALSE ;
} }

View File

@@ -37,7 +37,6 @@
#include "llpanel.h" #include "llpanel.h"
#include "lleventtimer.h" #include "lleventtimer.h"
#include "llnotifications.h" #include "llnotifications.h"
#include <vector>
class LLButton; class LLButton;
class LLNotifyBoxTemplate; class LLNotifyBoxTemplate;
@@ -51,16 +50,12 @@ class LLNotifyBox :
public LLInstanceTracker<LLNotifyBox, LLUUID> public LLInstanceTracker<LLNotifyBox, LLUUID>
{ {
public: public:
typedef void (*notify_callback_t)(S32 option, void* data);
typedef std::vector<std::string> option_list_t;
static void initClass(); static void initClass();
static void destroyClass();
BOOL isTip() const { return mIsTip; } bool isTip() const { return mIsTip; }
BOOL isCaution() const { return mIsCaution; } bool isCaution() const { return mIsCaution; }
/*virtual*/ void setVisible(BOOL visible); /*virtual*/ void setVisible(BOOL visible);
void stopAnimation() { mAnimating = FALSE; } void stopAnimation() { mAnimating = false; }
void close(); void close();
@@ -69,11 +64,11 @@ public:
static void format(std::string& msg, const LLStringUtil::format_map_t& args); static void format(std::string& msg, const LLStringUtil::format_map_t& args);
protected: protected:
LLNotifyBox(LLNotificationPtr notification, BOOL layout_script_dialog); LLNotifyBox(LLNotificationPtr notification);
/*virtual*/ ~LLNotifyBox(); /*virtual*/ ~LLNotifyBox();
LLButton* addButton(std::string const &name, const std::string& label, BOOL is_option, BOOL is_default); LLButton* addButton(const std::string& name, const std::string& label, bool is_option, bool is_default, bool layout_script_dialog);
/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
@@ -86,30 +81,23 @@ protected:
// Returns the rect, relative to gNotifyView, where this // Returns the rect, relative to gNotifyView, where this
// notify box should be placed. // notify box should be placed.
static LLRect getNotifyRect(S32 num_options, BOOL layout_script_dialog, BOOL is_caution); static LLRect getNotifyRect(S32 num_options, bool layout_script_dialog, bool is_caution);
static LLRect getNotifyTipRect(const std::string &message); static LLRect getNotifyTipRect(const std::string &message);
// internal handler for button being clicked // internal handler for button being clicked
void onClickButton(const std::string name); void onClickButton(const std::string name);
// for "next" button
void onClickNext();
//static LLNotifyBox* findExistingNotify(LLPointer<LLNotifyBoxTemplate> notify_template, const LLString::format_map_t& args);
private: private:
static bool onNotification(const LLSD& notify); static bool onNotification(const LLSD& notify);
void drawBackground() const; void drawBackground() const;
protected: protected:
std::string mMessage;
LLTextEditor *mUserInputBox; LLTextEditor *mUserInputBox;
LLNotificationPtr mNotification; LLNotificationPtr mNotification;
BOOL mIsTip; bool mIsTip;
BOOL mIsCaution; // is this a caution notification? bool mIsCaution; // is this a caution notification?
BOOL mAnimating; // Are we sliding onscreen? bool mAnimating; // Are we sliding onscreen?
// Time since this notification was displayed. // Time since this notification was displayed.
// This is an LLTimer not a frame timer because I am concerned // This is an LLTimer not a frame timer because I am concerned
@@ -120,34 +108,19 @@ protected:
S32 mNumOptions; S32 mNumOptions;
S32 mNumButtons; S32 mNumButtons;
BOOL mAddedDefaultBtn; bool mAddedDefaultBtn;
BOOL mLayoutScriptDialog;
// Used for callbacks
struct InstanceAndS32
{
LLNotifyBox* mSelf;
std::string mButtonName;
};
static S32 sNotifyBoxCount;
static const LLFontGL* sFont;
static const LLFontGL* sFontSmall;
typedef std::map<std::string, LLNotifyBox*> unique_map_t;
static unique_map_t sOpenUniqueNotifyBoxes;
}; };
class LLNotifyBoxView : public LLUICtrl class LLNotifyBoxView : public LLUICtrl
{ {
public: public:
LLNotifyBoxView(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows=FOLLOWS_NONE); LLNotifyBoxView(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows=FOLLOWS_NONE);
void showOnly(LLView * ctrl); void showOnly(LLView* ctrl);
LLNotifyBox * getFirstNontipBox() const; LLNotifyBox* getFirstNontipBox() const;
/*virtual*/ void deleteAllChildren();
class Matcher struct Matcher
{ {
public:
Matcher(){} Matcher(){}
virtual ~Matcher() {} virtual ~Matcher() {}
virtual bool matches(const LLNotificationPtr) const = 0; virtual bool matches(const LLNotificationPtr) const = 0;
@@ -157,7 +130,7 @@ public:
void purgeMessagesMatching(const Matcher& matcher); void purgeMessagesMatching(const Matcher& matcher);
private: private:
bool isGroupNotifyBox(const LLView* view) const ; bool isGroupNotifyBox(const LLView* view) const;
}; };
// This view contains the stack of notification windows. // This view contains the stack of notification windows.

View File

@@ -366,7 +366,6 @@ BOOL handle_check_pose(void* userdata) {
} }
void handle_close_all_notifications(void*);
void handle_open_message_log(void*); void handle_open_message_log(void*);
// </edit> // </edit>
@@ -3690,17 +3689,6 @@ void handle_open_message_log(void*)
LLFloaterMessageLog::show(); LLFloaterMessageLog::show();
} }
void handle_close_all_notifications(void*)
{
LLView::child_list_t child_list(*(gNotifyBoxView->getChildList()));
for(LLView::child_list_iter_t iter = child_list.begin();
iter != child_list.end();
iter++)
{
gNotifyBoxView->removeChild(*iter);
}
}
void handle_fake_away_status(void*) void handle_fake_away_status(void*)
{ {
bool fake_away = gSavedSettings.getBOOL("FakeAway"); bool fake_away = gSavedSettings.getBOOL("FakeAway");
@@ -8796,7 +8784,7 @@ class SinguCloseAllDialogs : public view_listener_t
{ {
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{ {
handle_close_all_notifications(NULL); gNotifyBoxView->deleteAllChildren();
return true; return true;
} }
}; };