summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorYuri Chebotarev <ychebotarev@productengine.com>2009-11-25 13:48:13 +0200
committerYuri Chebotarev <ychebotarev@productengine.com>2009-11-25 13:48:13 +0200
commitc2c83f3535c5a0bc099528580375afc99ad3b020 (patch)
treef54a6fb13ca135ff54a897836281df517aeab2f3 /indra/newview
parent7f7191c1735a2a823943119eec5c1ca160a7bf8d (diff)
EXT-2555 Change look and feel of nearby chat toasts
--HG-- branch : product-engine
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llchatitemscontainerctrl.cpp319
-rw-r--r--indra/newview/llchatitemscontainerctrl.h17
-rw-r--r--indra/newview/llnearbychathandler.cpp25
-rw-r--r--indra/newview/skins/default/colors.xml3
-rw-r--r--indra/newview/skins/default/xui/en/panel_chat_item.xml70
5 files changed, 172 insertions, 262 deletions
diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp
index 8a6935b71b..90956d4aa0 100644
--- a/indra/newview/llchatitemscontainerctrl.cpp
+++ b/indra/newview/llchatitemscontainerctrl.cpp
@@ -44,27 +44,12 @@
#include "llviewercontrol.h"
#include "llagentdata.h"
-/*
-static const S32 BORDER_MARGIN = 2;
-static const S32 PARENT_BORDER_MARGIN = 0;
-
-static const S32 HORIZONTAL_MULTIPLE = 8;
-static const S32 VERTICAL_MULTIPLE = 16;
-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;
-
-#define MAX_CHAT_HISTORY 100
-*/
-
-static const S32 msg_left_offset = 30;
+static const S32 msg_left_offset = 10;
static const S32 msg_right_offset = 10;
-static const S32 msg_height_pad = 2;
-
-//static LLDefaultChildRegistry::Register<LLChatItemsContainerCtrl> t2("chat_items_container");
+static const S32 msg_height_pad = 5;
//*******************************************************************************************************************
-//LLChatItemCtrl
+//LLNearbyChatToastPanel
//*******************************************************************************************************************
LLNearbyChatToastPanel* LLNearbyChatToastPanel::createInstance()
@@ -79,22 +64,22 @@ void LLNearbyChatToastPanel::reshape (S32 width, S32 height, BOOL called_from_p
{
LLPanel::reshape(width, height,called_from_parent);
- // *NOTE: we must check if child items exist because reshape is called from the
- // LLView::initFromParams BEFORE postBuild is called and child controls are not exist yet
- LLPanel* caption = findChild<LLPanel>("msg_caption", false);
- LLChatMsgBox* msg_text = findChild<LLChatMsgBox>("msg_text" ,false);
- if(caption && msg_text)
- {
- LLRect caption_rect = caption->getRect();
- caption_rect.setLeftTopAndSize( 2, height, width - 4, caption_rect.getHeight());
- caption->reshape( width - 4, caption_rect.getHeight(), 1);
- caption->setRect(caption_rect);
-
- LLRect msg_text_rect = msg_text->getRect();
- msg_text_rect.setLeftTopAndSize( msg_left_offset, height - caption_rect.getHeight() , width - msg_left_offset - msg_right_offset, height - caption_rect.getHeight());
- msg_text->reshape( width - msg_left_offset - msg_right_offset, height - caption_rect.getHeight(), 1);
- msg_text->setRect(msg_text_rect);
- }
+ LLUICtrl* msg_text = getChild<LLUICtrl>("msg_text", false);
+ LLUICtrl* icon = getChild<LLUICtrl>("avatar_icon", false);
+
+ LLRect msg_text_rect = msg_text->getRect();
+ LLRect avatar_rect = icon->getRect();
+
+ avatar_rect.setLeftTopAndSize(2,height-2,avatar_rect.getWidth(),avatar_rect.getHeight());
+ icon->setRect(avatar_rect);
+
+
+ msg_text_rect.setLeftTopAndSize( avatar_rect.mRight + msg_left_offset,
+ height - msg_height_pad,
+ width - avatar_rect.mRight - msg_left_offset - msg_right_offset,
+ height - 2*msg_height_pad);
+ msg_text->reshape( msg_text_rect.getWidth(), msg_text_rect.getHeight(), 1);
+ msg_text->setRect(msg_text_rect);
}
BOOL LLNearbyChatToastPanel::postBuild()
@@ -102,37 +87,63 @@ BOOL LLNearbyChatToastPanel::postBuild()
return LLPanel::postBuild();
}
-
-std::string LLNearbyChatToastPanel::appendTime()
+void LLNearbyChatToastPanel::addMessage(LLSD& notification)
{
- time_t utc_time;
- utc_time = time_corrected();
- std::string timeStr ="["+ LLTrans::getString("TimeHour")+"]:["
- +LLTrans::getString("TimeMin")+"] ";
+ std::string messageText = notification["message"].asString(); // UTF-8 line of text
- LLSD substitution;
+ LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
- substitution["datetime"] = (S32) utc_time;
- LLStringUtil::format (timeStr, substitution);
+ std::string color_name = notification["text_color"].asString();
+
+ LLColor4 textColor = LLUIColorTable::instance().getColor(color_name);
+ textColor.mV[VALPHA] =notification["color_alpha"].asReal();
+
+ S32 font_size = notification["font_size"].asInteger();
- return timeStr;
-}
+ LLFontGL* messageFont;
+ switch(font_size)
+ {
+ case 0: messageFont = LLFontGL::getFontSansSerifSmall(); break;
+ default:
+ case 1: messageFont = LLFontGL::getFontSansSerif(); break;
+ case 2: messageFont = LLFontGL::getFontSansSerifBig(); break;
+ }
+ //append text
+ {
+ LLStyle::Params style_params;
+ style_params.color(textColor);
+ std::string font_name = LLFontGL::nameFromFont(messageFont);
+ std::string font_style_size = LLFontGL::sizeFromFont(messageFont);
+ style_params.font.name(font_name);
+ style_params.font.size(font_style_size);
+ int chat_type = notification["chat_type"].asInteger();
+
+ if(notification["chat_style"].asInteger()== CHAT_STYLE_IRC)
+ {
+ messageText = messageText.substr(3);
+ style_params.font.style = "ITALIC";
+ }
+ else if( chat_type == CHAT_TYPE_SHOUT)
+ {
+ style_params.font.style = "BOLD";
+ }
+ else if( chat_type == CHAT_TYPE_WHISPER)
+ {
+ style_params.font.style = "ITALIC";
+ }
+ msg_text->appendText(messageText, TRUE, style_params);
+ }
+
+ snapToMessageHeight();
-void LLNearbyChatToastPanel::addText (const std::string& message , const LLStyle::Params& input_params)
-{
- LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
- msg_text->addText(message , input_params);
- mMessages.push_back(message);
}
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
+ std::string messageText = notification["message"].asString(); // UTF-8 line of text
+ std::string fromName = notification["from"].asString(); // agent or object name
mFromID = notification["from_id"].asUUID(); // agent id or object id
int sType = notification["source"].asInteger();
@@ -140,192 +151,121 @@ void LLNearbyChatToastPanel::init(LLSD& notification)
std::string color_name = notification["text_color"].asString();
- mTextColor = LLUIColorTable::instance().getColor(color_name);
- mTextColor.mV[VALPHA] =notification["color_alpha"].asReal();
+ LLColor4 textColor = LLUIColorTable::instance().getColor(color_name);
+ textColor.mV[VALPHA] =notification["color_alpha"].asReal();
S32 font_size = notification["font_size"].asInteger();
+
+ LLFontGL* messageFont;
switch(font_size)
{
- case 0:
- mFont = LLFontGL::getFontSansSerifSmall();
- break;
+ case 0: messageFont = LLFontGL::getFontSansSerifSmall(); break;
default:
- case 1:
- mFont = LLFontGL::getFontSansSerif();
- break;
- case 2:
- mFont = LLFontGL::getFontSansSerifBig();
- break;
+ case 1: messageFont = LLFontGL::getFontSansSerif(); break;
+ case 2: messageFont = LLFontGL::getFontSansSerifBig(); break;
}
- LLStyle::Params style_params;
- style_params.color(mTextColor);
-// style_params.font(mFont);
- std::string font_name = LLFontGL::nameFromFont(mFont);
- std::string font_style_size = LLFontGL::sizeFromFont(mFont);
- style_params.font.name(font_name);
- style_params.font.size(font_style_size);
+ LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
+
+ msg_text->setText(std::string(""));
std::string str_sender;
if(gAgentID != mFromID)
- str_sender = mFromName;
+ str_sender = fromName;
else
- str_sender = LLTrans::getString("You");;
+ str_sender = LLTrans::getString("You");
- caption->getChild<LLTextBox>("sender_name", false)->setText(str_sender , style_params);
-
- LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
+ str_sender+=" ";
+ //append user name
+ {
+ LLStyle::Params style_params_name;
+
+ LLColor4 userNameColor = LLUIColorTable::instance().getColor("ChatToastUserNameColor");
+
+ style_params_name.color(userNameColor);
+
+ std::string font_name = LLFontGL::nameFromFont(messageFont);
+ std::string font_style_size = LLFontGL::sizeFromFont(messageFont);
+ style_params_name.font.name(font_name);
+ style_params_name.font.size(font_style_size);
+
+ msg_text->appendText(str_sender, FALSE, style_params_name);
+
+ }
- if(notification["chat_style"].asInteger()== CHAT_STYLE_IRC)
+ //append text
{
- if (mFromName.size() > 0)
+ LLStyle::Params style_params;
+ style_params.color(textColor);
+ std::string font_name = LLFontGL::nameFromFont(messageFont);
+ std::string font_style_size = LLFontGL::sizeFromFont(messageFont);
+ style_params.font.name(font_name);
+ style_params.font.size(font_style_size);
+
+ int chat_type = notification["chat_type"].asInteger();
+
+ if(notification["chat_style"].asInteger()== CHAT_STYLE_IRC)
{
+ messageText = messageText.substr(3);
style_params.font.style = "ITALIC";
-
- msg_text->setText(mFromName, style_params);
}
- mText = mText.substr(3);
- style_params.font.style = "ITALIC";
-#define INFINITE_REFLOW_BUG 0
-#if INFINITE_REFLOW_BUG
- // This causes LLTextBase::reflow() to infinite loop until the viewer
- // runs out of memory, throws a bad_alloc exception from std::vector
- // in mLineInfoList, and the main loop catches it and continues.
- // It appears to be caused by addText() adding a line separator in the
- // middle of a line. See EXT-2579, EXT-1949
- msg_text->addText(mText,style_params);
-#else
- msg_text->appendText(mText, FALSE, style_params);
-#endif
- }
- else
- {
- msg_text->setText(mText, style_params);
+ else if( chat_type == CHAT_TYPE_SHOUT)
+ {
+ style_params.font.style = "BOLD";
+ }
+ else if( chat_type == CHAT_TYPE_WHISPER)
+ {
+ style_params.font.style = "ITALIC";
+ }
+ msg_text->appendText(messageText, FALSE, style_params);
}
-
- LLUICtrl* msg_inspector = caption->getChild<LLUICtrl>("msg_inspector");
- if(mSourceType != CHAT_SOURCE_AGENT)
- msg_inspector->setVisible(false);
-
- mMessages.clear();
-
- snapToMessageHeight ();
+ 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;
- notification["chat_type"] = (S32)chat_msg.mChatType;
- notification["chat_style"] = (S32)chat_msg.mChatStyle;
-
- std::string r_color_name="White";
- F32 r_color_alpha = 1.0f;
- LLViewerChat::getChatColor( chat_msg, r_color_name, r_color_alpha);
-
- notification["text_color"] = r_color_name;
- notification["color_alpha"] = r_color_alpha;
-
- notification["font_size"] = (S32)LLViewerChat::getChatFontSize() ;
- init(notification);
-
-}
-
void LLNearbyChatToastPanel::snapToMessageHeight ()
{
LLChatMsgBox* text_box = getChild<LLChatMsgBox>("msg_text", false);
- S32 new_height = text_box->getTextPixelHeight() + msg_height_pad;
+ S32 new_height = llmax (text_box->getTextPixelHeight() + 2*text_box->getVPad() + 2*msg_height_pad, 25);
+
LLRect panel_rect = getRect();
- S32 caption_height = 0;
- LLPanel* caption = getChild<LLPanel>("msg_caption", false);
- caption_height = caption->getRect().getHeight();
-
- panel_rect.setLeftTopAndSize( panel_rect.mLeft, panel_rect.mTop, panel_rect.getWidth(), caption_height + new_height);
+ panel_rect.setLeftTopAndSize( panel_rect.mLeft, panel_rect.mTop, panel_rect.getWidth(), new_height);
- reshape( getRect().getWidth(), caption_height + new_height, 1);
+ reshape( getRect().getWidth(), getRect().getHeight(), 1);
setRect(panel_rect);
}
-
-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);
-
- LLStyle::Params style_params;
- style_params.color(mTextColor);
- style_params.font(mFont);
-
-
- if(mText.length())
- msg_text->setText(mText, style_params);
-
- for(size_t i=0;i<mMessages.size();++i)
- msg_text->addText(mMessages[i] , style_params);
-
- setRect(LLRect(getRect().mLeft, getRect().mTop, getRect().mLeft + width , getRect().mBottom));
- snapToMessageHeight ();
-}
-
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 LLNearbyChatToastPanel::onMouseEnter (S32 x, S32 y, MASK mask)
{
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 LLNearbyChatToastPanel::handleMouseDown (S32 x, S32 y, MASK mask)
{
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");
- S32 local_x = x - msg_inspector->getRect().mLeft - caption->getRect().mLeft;
- S32 local_y = y - msg_inspector->getRect().mBottom - caption->getRect().mBottom;
- if(msg_inspector->pointInView(local_x, local_y))
- {
- LLFloaterReg::showInstance("inspect_avatar", LLSD().insert("avatar_id", mFromID));
- }
- else
- {
- LLFloaterReg::showInstance("nearby_chat",LLSD());
- }
+ LLFloaterReg::showInstance("nearby_chat",LLSD());
return LLPanel::handleMouseDown(x,y,mask);
}
void LLNearbyChatToastPanel::setHeaderVisibility(EShowItemHeader e)
{
- LLPanel* caption = getChild<LLPanel>("msg_caption", false);
-
- LLUICtrl* icon = caption->getChild<LLUICtrl>("avatar_icon", false);
- LLUICtrl* name = caption->getChild<LLUICtrl>("sender_name", false);
-
- icon->setVisible(e == CHATITEMHEADER_SHOW_ONLY_ICON || e==CHATITEMHEADER_SHOW_BOTH);
- name->setVisible(e == CHATITEMHEADER_SHOW_ONLY_NAME || e==CHATITEMHEADER_SHOW_BOTH);
+ LLUICtrl* icon = getChild<LLUICtrl>("avatar_icon", false);
+ if(icon)
+ icon->setVisible(e == CHATITEMHEADER_SHOW_ONLY_ICON || e==CHATITEMHEADER_SHOW_BOTH);
}
@@ -339,11 +279,10 @@ bool LLNearbyChatToastPanel::canAddText ()
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);
+ LLUICtrl* avatar_icon = getChild<LLUICtrl>("avatar_icon", false);
- S32 local_x = x - avatar_icon->getRect().mLeft - caption->getRect().mLeft;
- S32 local_y = y - avatar_icon->getRect().mBottom - caption->getRect().mBottom;
+ S32 local_x = x - avatar_icon->getRect().mLeft;
+ S32 local_y = y - avatar_icon->getRect().mBottom;
//eat message for avatar icon if msg was from object
if(avatar_icon->pointInView(local_x, local_y) && mSourceType != CHAT_SOURCE_AGENT)
@@ -354,9 +293,7 @@ void LLNearbyChatToastPanel::draw()
{
if(mIsDirty)
{
- LLPanel* caption = findChild<LLPanel>("msg_caption", false);
- if(caption)
- caption->getChild<LLAvatarIconCtrl>("avatar_icon", false)->setValue(mFromID);
+ getChild<LLAvatarIconCtrl>("avatar_icon", false)->setValue(mFromID);
mIsDirty = false;
}
LLToastPanelBase::draw();
diff --git a/indra/newview/llchatitemscontainerctrl.h b/indra/newview/llchatitemscontainerctrl.h
index a65bfedd09..0a85c52401 100644
--- a/indra/newview/llchatitemscontainerctrl.h
+++ b/indra/newview/llchatitemscontainerctrl.h
@@ -59,9 +59,8 @@ public:
const LLUUID& getFromID() const { return mFromID;}
- void addText (const std::string& message , const LLStyle::Params& input_params = LLStyle::Params());
- void setMessage (const LLChat& msg);
- void setWidth (S32 width);
+ //void addText (const std::string& message , const LLStyle::Params& input_params = LLStyle::Params());
+ //void setMessage (const LLChat& msg);
void snapToMessageHeight ();
bool canAddText ();
@@ -78,22 +77,16 @@ public:
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
virtual void init(LLSD& data);
+ virtual void addMessage(LLSD& data);
virtual void draw();
-private:
-
- std::string appendTime ();
+ const LLUUID& messageID() const { return mFromID;}
private:
- std::string mText; // UTF-8 line of text
- std::string mFromName; // agent or object name
LLUUID mFromID; // agent id or object id
EChatSourceType mSourceType;
- LLColor4 mTextColor;
- LLFontGL* mFont;
-
+
- std::vector<std::string> mMessages;
bool mIsDirty;
};
diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp
index 74a75d0369..b0b6db682c 100644
--- a/indra/newview/llnearbychathandler.cpp
+++ b/indra/newview/llnearbychathandler.cpp
@@ -52,8 +52,6 @@ using namespace LLNotificationsUI;
LLToastPanelBase* createToastPanel()
{
LLNearbyChatToastPanel* item = LLNearbyChatToastPanel::createInstance();
- static S32 chat_item_width = 304;
- item->setWidth(chat_item_width);
return item;
}
@@ -169,6 +167,29 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification)
//look in pool. if there is any message
if(mStopProcessing)
return;
+
+ /*
+ find last toast and check ID
+ */
+
+ if(m_active_toasts.size())
+ {
+ LLUUID fromID = notification["from_id"].asUUID(); // agent id or object id
+ LLToast* toast = m_active_toasts[0];
+ LLNearbyChatToastPanel* panel = dynamic_cast<LLNearbyChatToastPanel*>(toast->getPanel());
+
+ if(panel && panel->messageID() == fromID && panel->canAddText())
+ {
+ panel->addMessage(notification);
+ toast->reshapeToPanel();
+ toast->resetTimer();
+
+ arrangeToasts();
+ return;
+ }
+ }
+
+
if(m_toast_pool.empty())
{
diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml
index eb8ec00bb9..9be8b4c73f 100644
--- a/indra/newview/skins/default/colors.xml
+++ b/indra/newview/skins/default/colors.xml
@@ -684,5 +684,8 @@
<color
name="SysWellItemSelected"
value="0.3 0.3 0.3 1.0" />
+ <color
+ name="ChatToastUserNameColor"
+ value="1.0 0.3 1.0 1.0" />
</colors>
diff --git a/indra/newview/skins/default/xui/en/panel_chat_item.xml b/indra/newview/skins/default/xui/en/panel_chat_item.xml
index 2b29796f0a..34c6e02684 100644
--- a/indra/newview/skins/default/xui/en/panel_chat_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_chat_item.xml
@@ -2,70 +2,26 @@
<!-- All our XML is utf-8 encoded. -->
<panel
name="instant_message"
- width="300"
+ width="315"
height="180"
follows="all">
- <panel
- width="290"
- height="24"
- background_visible="true"
- background_opaque="false"
- bg_alpha_color="Black"
- left="5"
- name="msg_caption">
- <avatar_icon
- follows="left"
- height="18"
- image_name="Generic_Person"
- layout="topleft"
- left="3"
- mouse_opaque="true"
- name="avatar_icon"
- top="3"
- width="18" />
- <text
- font.style="BOLD"
- height="12"
- layout="topleft"
- left_pad="5"
- top="7"
- text_color="white"
- word_wrap="false"
- use_ellipses="true"
- mouse_opaque="true"
- name="sender_name"
- width="150">
- Jerry Knight
- </text>
- <!-- <icon top="22" left="215" width="15" height="15" follows="top|right"
- image_name="icn_voice-pvtfocus.tga" visible="false" name="msg_inspector" />-->
- <!--<icon top="22" left="215" width="10" height="10" follows="top|right"
- image_name="speaking_indicator.tga" name="msg_icon"/>-->
- <text
- font="SansSerifSmall"
- follows="right|top"
- halign="right"
- height="13"
- layout="topleft"
- right="-10"
- left="205"
- mouse_opaque="true"
- name="msg_time"
- top="8"
- value="23:30"
- width="50"
- word_wrap="true" />
- </panel>
+ <avatar_icon
+ follows="left|top"
+ height="18"
+ image_name="Generic_Person"
+ layout="topleft"
+ left="3"
+ mouse_opaque="true"
+ name="avatar_icon"
+ top="3"
+ width="18" />
<text_chat
- top="-35"
- left="10"
- right="-10"
+ top="5"
+ left="30"
height="120"
- follows="left|right|bottom"
text_color="white"
word_wrap="true"
mouse_opaque="true"
name="msg_text">
- To be or not to be, that is the question. Tis a far far better thing I do than I have ever done. Tis a far far better place I go, than I have ever been.
</text_chat>
</panel>