summaryrefslogtreecommitdiff
path: root/indra/newview/llchatitemscontainerctrl.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2009-10-01 17:44:44 +0000
committerSteven Bennetts <steve@lindenlab.com>2009-10-01 17:44:44 +0000
commitf05df68656d2abdc38d86cd6746398fa90eb8614 (patch)
tree95f389551a7132b86dd96ff7c55b92674ee16756 /indra/newview/llchatitemscontainerctrl.cpp
parent090977608d3d4e1d6d26689064910221c66f6084 (diff)
merge https://svn.aws.productengine.com/secondlife/export-from-ll/viewer-2-0@1868 https://svn.aws.productengine.com/secondlife/pe/stable-2@1876 -> viewer-2.0.0-3
* Bugs: EXT-1111 EXT-915 EXT-1131 EXT-1200 EXT-1202 EXT-1201 EXT-1205 EXT-1212 EXT-1173 EXT-1229 EXT-1218 EXT-1164 EXT-996 EXT-821 EXT-1030 EXT-1031 EXT-816 * Major Bugs: EXT-1142 (timeout during login due to processing group IMs) * Changes: EXT-1216 (minimize message well)
Diffstat (limited to 'indra/newview/llchatitemscontainerctrl.cpp')
-rw-r--r--indra/newview/llchatitemscontainerctrl.cpp392
1 files changed, 65 insertions, 327 deletions
diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp
index 6fb6552f2d..c2d7e0d935 100644
--- a/indra/newview/llchatitemscontainerctrl.cpp
+++ b/indra/newview/llchatitemscontainerctrl.cpp
@@ -44,6 +44,7 @@
#include "llviewercontrol.h"
#include "llagentdata.h"
+/*
static const S32 BORDER_MARGIN = 2;
static const S32 PARENT_BORDER_MARGIN = 0;
@@ -53,33 +54,27 @@ static const F32 MIN_AUTO_SCROLL_RATE = 120.f;
static const F32 MAX_AUTO_SCROLL_RATE = 500.f;
static const F32 AUTO_SCROLL_RATE_ACCEL = 120.f;
-static const S32 msg_left_offset = 30;
-static const S32 msg_right_offset = 10;
-
#define MAX_CHAT_HISTORY 100
+*/
+static const S32 msg_left_offset = 30;
+static const S32 msg_right_offset = 10;
-static LLDefaultChildRegistry::Register<LLChatItemsContainerCtrl> t2("chat_items_container");
-
-
+//static LLDefaultChildRegistry::Register<LLChatItemsContainerCtrl> t2("chat_items_container");
//*******************************************************************************************************************
//LLChatItemCtrl
//*******************************************************************************************************************
-LLChatItemCtrl* LLChatItemCtrl::createInstance()
+LLNearbyChatToastPanel* LLNearbyChatToastPanel::createInstance()
{
- LLChatItemCtrl* item = new LLChatItemCtrl();
+ LLNearbyChatToastPanel* item = new LLNearbyChatToastPanel();
LLUICtrlFactory::getInstance()->buildPanel(item, "panel_chat_item.xml");
+ item->setFollows(FOLLOWS_NONE);
return item;
}
-void LLChatItemCtrl::draw()
-{
- LLPanel::draw();
-}
-
-void LLChatItemCtrl::reshape (S32 width, S32 height, BOOL called_from_parent )
+void LLNearbyChatToastPanel::reshape (S32 width, S32 height, BOOL called_from_parent )
{
LLPanel::reshape(width, height,called_from_parent);
@@ -101,13 +96,13 @@ void LLChatItemCtrl::reshape (S32 width, S32 height, BOOL called_from_parent )
}
}
-BOOL LLChatItemCtrl::postBuild()
+BOOL LLNearbyChatToastPanel::postBuild()
{
return LLPanel::postBuild();
}
-std::string LLChatItemCtrl::appendTime()
+std::string LLNearbyChatToastPanel::appendTime()
{
time_t utc_time;
utc_time = time_corrected();
@@ -124,48 +119,63 @@ std::string LLChatItemCtrl::appendTime()
-void LLChatItemCtrl::addText (const std::string& message)
+void LLNearbyChatToastPanel::addText (const std::string& message)
{
LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
msg_text->addText(message);
mMessages.push_back(message);
}
-void LLChatItemCtrl::setMessage (const LLChat& msg)
+void LLNearbyChatToastPanel::init(LLSD& notification)
{
LLPanel* caption = getChild<LLPanel>("msg_caption", false);
+ mText = notification["message"].asString(); // UTF-8 line of text
+ mFromName = notification["from"].asString(); // agent or object name
+ mFromID = notification["from_id"].asUUID(); // agent id or object id
+ int sType = notification["source"].asInteger();
+ mSourceType = (EChatSourceType)sType;
+
std::string str_sender;
-
- if(gAgentID != msg.mFromID)
- str_sender = msg.mFromName;
+ if(gAgentID != mFromID)
+ str_sender = mFromName;
else
str_sender = LLTrans::getString("You");;
caption->getChild<LLTextBox>("sender_name", false)->setText(str_sender);
- std::string tt = appendTime();
-
- caption->getChild<LLTextBox>("msg_time", false)->setText(tt);
-
-
- caption->getChild<LLAvatarIconCtrl>("avatar_icon", false)->setValue(msg.mFromID);
+ caption->getChild<LLTextBox>("msg_time", false)->setText(appendTime());
- mOriginalMessage = msg;
LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
- msg_text->setText(msg.mText);
+ msg_text->setText(mText);
LLUICtrl* msg_inspector = caption->getChild<LLUICtrl>("msg_inspector");
- if(mOriginalMessage.mSourceType != CHAT_SOURCE_AGENT)
+ if(mSourceType != CHAT_SOURCE_AGENT)
msg_inspector->setVisible(false);
mMessages.clear();
+ snapToMessageHeight ();
+
+ mIsDirty = true;//will set Avatar Icon in draw
+}
+
+void LLNearbyChatToastPanel::setMessage (const LLChat& chat_msg)
+{
+ LLSD notification;
+ notification["message"] = chat_msg.mText;
+ notification["from"] = chat_msg.mFromName;
+ notification["from_id"] = chat_msg.mFromID;
+ notification["time"] = chat_msg.mTime;
+ notification["source"] = (S32)chat_msg.mSourceType;
+
+ init(notification);
+
}
-void LLChatItemCtrl::snapToMessageHeight ()
+void LLNearbyChatToastPanel::snapToMessageHeight ()
{
LLChatMsgBox* text_box = getChild<LLChatMsgBox>("msg_text", false);
S32 new_height = text_box->getTextPixelHeight();
@@ -184,14 +194,14 @@ void LLChatItemCtrl::snapToMessageHeight ()
}
-void LLChatItemCtrl::setWidth(S32 width)
+void LLNearbyChatToastPanel::setWidth(S32 width)
{
LLChatMsgBox* text_box = getChild<LLChatMsgBox>("msg_text", false);
text_box->reshape(width - msg_left_offset - msg_right_offset,100/*its not magic number, we just need any number*/);
LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
- if(mOriginalMessage.mText.length())
- msg_text->setText(mOriginalMessage.mText);
+ if(mText.length())
+ msg_text->setText(mText);
for(size_t i=0;i<mMessages.size();++i)
msg_text->addText(mMessages[i]);
@@ -200,25 +210,25 @@ void LLChatItemCtrl::setWidth(S32 width)
snapToMessageHeight ();
}
-void LLChatItemCtrl::onMouseLeave (S32 x, S32 y, MASK mask)
+void LLNearbyChatToastPanel::onMouseLeave (S32 x, S32 y, MASK mask)
{
LLPanel* caption = getChild<LLPanel>("msg_caption", false);
LLUICtrl* msg_inspector = caption->getChild<LLUICtrl>("msg_inspector");
msg_inspector->setVisible(false);
}
-void LLChatItemCtrl::onMouseEnter (S32 x, S32 y, MASK mask)
+void LLNearbyChatToastPanel::onMouseEnter (S32 x, S32 y, MASK mask)
{
- if(mOriginalMessage.mSourceType != CHAT_SOURCE_AGENT)
+ if(mSourceType != CHAT_SOURCE_AGENT)
return;
LLPanel* caption = getChild<LLPanel>("msg_caption", false);
LLUICtrl* msg_inspector = caption->getChild<LLUICtrl>("msg_inspector");
msg_inspector->setVisible(true);
}
-BOOL LLChatItemCtrl::handleMouseDown (S32 x, S32 y, MASK mask)
+BOOL LLNearbyChatToastPanel::handleMouseDown (S32 x, S32 y, MASK mask)
{
- if(mOriginalMessage.mSourceType != CHAT_SOURCE_AGENT)
+ if(mSourceType != CHAT_SOURCE_AGENT)
return LLPanel::handleMouseDown(x,y,mask);
LLPanel* caption = getChild<LLPanel>("msg_caption", false);
LLUICtrl* msg_inspector = caption->getChild<LLUICtrl>("msg_inspector");
@@ -226,12 +236,16 @@ BOOL LLChatItemCtrl::handleMouseDown (S32 x, S32 y, MASK mask)
S32 local_y = y - msg_inspector->getRect().mBottom - caption->getRect().mBottom;
if(msg_inspector->pointInView(local_x, local_y))
{
- LLFloaterReg::showInstance("inspect_avatar", mOriginalMessage.mFromID);
+ LLFloaterReg::showInstance("inspect_avatar", mFromID);
+ }
+ else
+ {
+ LLFloaterReg::showInstance("nearby_chat",LLSD());
}
return LLPanel::handleMouseDown(x,y,mask);
}
-void LLChatItemCtrl::setHeaderVisibility(EShowItemHeader e)
+void LLNearbyChatToastPanel::setHeaderVisibility(EShowItemHeader e)
{
LLPanel* caption = getChild<LLPanel>("msg_caption", false);
@@ -243,7 +257,7 @@ void LLChatItemCtrl::setHeaderVisibility(EShowItemHeader e)
}
-bool LLChatItemCtrl::canAddText ()
+bool LLNearbyChatToastPanel::canAddText ()
{
LLChatMsgBox* msg_text = findChild<LLChatMsgBox>("msg_text");
if(!msg_text)
@@ -251,7 +265,7 @@ bool LLChatItemCtrl::canAddText ()
return msg_text->getTextLinesNum()<10;
}
-BOOL LLChatItemCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask)
+BOOL LLNearbyChatToastPanel::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
LLPanel* caption = getChild<LLPanel>("msg_caption", false);
LLUICtrl* avatar_icon = caption->getChild<LLUICtrl>("avatar_icon", false);
@@ -260,296 +274,20 @@ BOOL LLChatItemCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask)
S32 local_y = y - avatar_icon->getRect().mBottom - caption->getRect().mBottom;
//eat message for avatar icon if msg was from object
- if(avatar_icon->pointInView(local_x, local_y) && mOriginalMessage.mSourceType != CHAT_SOURCE_AGENT)
+ if(avatar_icon->pointInView(local_x, local_y) && mSourceType != CHAT_SOURCE_AGENT)
return TRUE;
return LLPanel::handleRightMouseDown(x,y,mask);
}
-
-
-//*******************************************************************************************************************
-//LLChatItemsContainerCtrl
-//*******************************************************************************************************************
-
-LLChatItemsContainerCtrl::LLChatItemsContainerCtrl(const Params& params):LLPanel(params)
-{
- mEShowItemHeader = CHATITEMHEADER_SHOW_BOTH;
-}
-
-
-void LLChatItemsContainerCtrl::addMessage(const LLChat& msg)
-{
- /*
- if(msg.mChatType == CHAT_TYPE_DEBUG_MSG)
- return;
- */
- if(mItems.size() >= MAX_CHAT_HISTORY)
- {
- LLChatItemCtrl* item = mItems[0];
- removeChild(item);
- delete item;
- mItems.erase(mItems.begin());
- }
-
-
- if(mItems.size() > 0
- && msg.mFromID == mItems[mItems.size()-1]->getMessage().mFromID
- && (msg.mTime-mItems[mItems.size()-1]->getMessage().mTime)<60
- && mItems[mItems.size()-1]->canAddText()
- )
- {
- mItems[mItems.size()-1]->addText(msg.mText);
- mItems[mItems.size()-1]->snapToMessageHeight();
- }
- else
- {
- LLChatItemCtrl* item = LLChatItemCtrl::createInstance();
- mItems.push_back(item);
- addChild(item,0);
- item->setWidth(getRect().getWidth() - 16);
- item->setMessage(msg);
- item->snapToMessageHeight();
-
- item->setHeaderVisibility((EShowItemHeader)gSavedSettings.getS32("nearbychat_showicons_and_names"));
-
- item->setVisible(true);
- }
-
- arrange(getRect().getWidth(),getRect().getHeight());
- updateLayout(getRect().getWidth(),getRect().getHeight());
- scrollToBottom();
-}
-
-void LLChatItemsContainerCtrl::scrollToBottom ()
-{
- if(mScrollbar->getVisible())
- {
- mScrollbar->setDocPos(mScrollbar->getDocPosMax());
- onScrollPosChangeCallback(0,0);
- }
-}
-
-void LLChatItemsContainerCtrl::draw()
-{
- LLLocalClipRect clip(getRect());
- LLPanel::draw();
-}
-
-void LLChatItemsContainerCtrl::reshape (S32 width, S32 height, BOOL called_from_parent )
-{
- S32 delta_width = width - getRect().getWidth();
- S32 delta_height = height - getRect().getHeight();
-
- if (delta_width || delta_height || sForceReshape)
- {
- arrange(width, height);
- }
-
- updateBoundingRect();
-}
-
-void LLChatItemsContainerCtrl::arrange (S32 width, S32 height)
+void LLNearbyChatToastPanel::draw()
{
- S32 delta_width = width - getRect().getWidth();
- if(delta_width)//width changed...too bad. now we need to reformat all items
- reformatHistoryScrollItems(width);
-
- calcRecuiredHeight();
-
- show_hide_scrollbar(width,height);
-
- updateLayout(width,height);
-}
-
-void LLChatItemsContainerCtrl::reformatHistoryScrollItems(S32 width)
-{
- for(std::vector<LLChatItemCtrl*>::iterator it = mItems.begin(); it != mItems.end();++it)
- {
- (*it)->setWidth(width);
- }
-}
-
-S32 LLChatItemsContainerCtrl::calcRecuiredHeight ()
-{
- S32 rec_height = 0;
-
- std::vector<LLChatItemCtrl*>::iterator it;
- for(it=mItems.begin(); it!=mItems.end(); ++it)
- {
- rec_height += (*it)->getRect().getHeight();
- }
-
- mInnerRect.setLeftTopAndSize(0,rec_height + BORDER_MARGIN*2,getRect().getWidth(),rec_height + BORDER_MARGIN);
-
- return mInnerRect.getHeight();
-}
-
-
-void LLChatItemsContainerCtrl::updateLayout (S32 width, S32 height)
-{
- S32 panel_top = height - BORDER_MARGIN ;
- S32 panel_width = width;
- if(mScrollbar->getVisible())
- {
- static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
-
- panel_top+=mScrollbar->getDocPos();
- panel_width-=scrollbar_size;
- }
-
-
- //set sizes for first panels and dragbars
- for(size_t i=0;i<mItems.size();++i)
- {
- LLRect panel_rect = mItems[i]->getRect();
- panelSetLeftTopAndSize(mItems[i],panel_rect.mLeft,panel_top,panel_width,panel_rect.getHeight());
- panel_top-=panel_rect.getHeight();
- }
-}
-
-void LLChatItemsContainerCtrl::show_hide_scrollbar (S32 width, S32 height)
-{
- calcRecuiredHeight();
- if(getRecuiredHeight() > height )
- showScrollbar(width, height);
- else
- hideScrollbar(width, height);
-}
-
-void LLChatItemsContainerCtrl::showScrollbar (S32 width, S32 height)
-{
- bool was_visible = mScrollbar->getVisible();
-
- mScrollbar->setVisible(true);
-
- static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
-
- panelSetLeftTopAndSize(mScrollbar,width-scrollbar_size
- ,height-PARENT_BORDER_MARGIN,scrollbar_size,height-2*PARENT_BORDER_MARGIN);
-
- mScrollbar->setPageSize(height);
- mScrollbar->setDocParams(mInnerRect.getHeight(),mScrollbar->getDocPos());
-
- if(was_visible)
- {
- S32 scroll_pos = llmin(mScrollbar->getDocPos(), getRecuiredHeight() - height - 1);
- mScrollbar->setDocPos(scroll_pos);
- updateLayout(width,height);
- return;
- }
-}
-
-void LLChatItemsContainerCtrl::hideScrollbar (S32 width, S32 height)
-{
- if(mScrollbar->getVisible() == false)
- return;
- mScrollbar->setVisible(false);
-
- mScrollbar->setDocPos(0);
-
- if(mItems.size()>0)
- {
- S32 panel_top = height - BORDER_MARGIN; // Top coordinate of the first panel
- S32 diff = panel_top - mItems[0]->getRect().mTop;
- shiftPanels(diff);
- }
-}
-
-//---------------------------------------------------------------------------------
-void LLChatItemsContainerCtrl::panelSetLeftTopAndSize(LLView* panel, S32 left, S32 top, S32 width, S32 height)
-{
- if(!panel)
- return;
- LLRect panel_rect = panel->getRect();
- panel_rect.setLeftTopAndSize( left, top, width, height);
- panel->reshape( width, height, 1);
- panel->setRect(panel_rect);
-}
-
-void LLChatItemsContainerCtrl::panelShiftVertical(LLView* panel,S32 delta)
-{
- if(!panel)
- return;
- panel->translate(0,delta);
-}
-
-void LLChatItemsContainerCtrl::shiftPanels(S32 delta)
-{
- //Arrange panels
- for(std::vector<LLChatItemCtrl*>::iterator it = mItems.begin(); it != mItems.end();++it)
- {
- panelShiftVertical((*it),delta);
- }
-
-}
-
-//---------------------------------------------------------------------------------
-
-void LLChatItemsContainerCtrl::onScrollPosChangeCallback(S32, LLScrollbar*)
-{
- updateLayout(getRect().getWidth(),getRect().getHeight());
-}
-
-BOOL LLChatItemsContainerCtrl::postBuild()
-{
- static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
-
- LLRect scroll_rect;
- scroll_rect.setOriginAndSize(
- getRect().getWidth() - scrollbar_size,
- 1,
- scrollbar_size,
- getRect().getHeight() - 1);
-
-
- LLScrollbar::Params sbparams;
- sbparams.name("scrollable vertical");
- sbparams.rect(scroll_rect);
- sbparams.orientation(LLScrollbar::VERTICAL);
- sbparams.doc_size(mInnerRect.getHeight());
- sbparams.doc_pos(0);
- sbparams.page_size(mInnerRect.getHeight());
- sbparams.step_size(VERTICAL_MULTIPLE);
- sbparams.follows.flags(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM);
- sbparams.change_callback(boost::bind(&LLChatItemsContainerCtrl::onScrollPosChangeCallback, this, _1, _2));
-
- mScrollbar = LLUICtrlFactory::create<LLScrollbar> (sbparams);
- LLView::addChild( mScrollbar );
- mScrollbar->setVisible( true );
- mScrollbar->setFollowsRight();
- mScrollbar->setFollowsTop();
- mScrollbar->setFollowsBottom();
-
- reformatHistoryScrollItems(getRect().getWidth());
- arrange(getRect().getWidth(),getRect().getHeight());
-
- return LLPanel::postBuild();
-}
-BOOL LLChatItemsContainerCtrl::handleMouseDown (S32 x, S32 y, MASK mask)
-{
- return LLPanel::handleMouseDown(x,y,mask);
-}
-BOOL LLChatItemsContainerCtrl::handleKeyHere (KEY key, MASK mask)
-{
- if( mScrollbar->getVisible() && mScrollbar->handleKeyHere( key,mask ) )
- return TRUE;
- return LLPanel::handleKeyHere(key,mask);
-}
-BOOL LLChatItemsContainerCtrl::handleScrollWheel ( S32 x, S32 y, S32 clicks )
-{
- if( mScrollbar->getVisible() && mScrollbar->handleScrollWheel( 0, 0, clicks ) )
- return TRUE;
- return false;
-}
-
-void LLChatItemsContainerCtrl::setHeaderVisibility(EShowItemHeader e)
-{
- if(e == mEShowItemHeader)
- return;
- mEShowItemHeader = e;
- for(std::vector<LLChatItemCtrl*>::iterator it = mItems.begin(); it != mItems.end();++it)
+ if(mIsDirty)
{
- (*it)->setHeaderVisibility(e);
+ LLPanel* caption = findChild<LLPanel>("msg_caption", false);
+ if(caption)
+ caption->getChild<LLAvatarIconCtrl>("avatar_icon", false)->setValue(mFromID);
+ mIsDirty = false;
}
+ LLToastPanelBase::draw();
}