From 11fc2da6fa5fba0bb659dd97f8533e4529aece06 Mon Sep 17 00:00:00 2001 From: angela Date: Thu, 12 Nov 2009 21:20:18 +0800 Subject: make color and font affecting both nearby chat and toasts --- indra/newview/llchatitemscontainerctrl.cpp | 57 +++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 9 deletions(-) (limited to 'indra/newview/llchatitemscontainerctrl.cpp') diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index 63b9fd8e66..d2e3247250 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -120,10 +120,10 @@ std::string LLNearbyChatToastPanel::appendTime() -void LLNearbyChatToastPanel::addText (const std::string& message) +void LLNearbyChatToastPanel::addText (const std::string& message , const LLStyle::Params& input_params) { LLChatMsgBox* msg_text = getChild("msg_text", false); - msg_text->addText(message); + msg_text->addText(message , input_params); mMessages.push_back(message); } @@ -134,9 +134,34 @@ void LLNearbyChatToastPanel::init(LLSD& notification) 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 color_name = notification["text_color"].asString(); + + mTextColor = LLUIColorTable::instance().getColor(color_name); + mTextColor.mV[VALPHA] =notification["color_alpha"].asReal(); + + S32 font_size = notification["font_size"].asInteger(); + switch(font_size) + { + case 0: + mFont = LLFontGL::getFontSansSerifSmall(); + break; + default: + case 1: + mFont = LLFontGL::getFontSansSerif(); + break; + case 2: + mFont = LLFontGL::getFontSansSerifBig(); + break; + } + + LLStyle::Params style_params; + style_params.color(mTextColor); + style_params.font(mFont); + std::string str_sender; if(gAgentID != mFromID) @@ -144,13 +169,13 @@ void LLNearbyChatToastPanel::init(LLSD& notification) else str_sender = LLTrans::getString("You");; - caption->getChild("sender_name", false)->setText(str_sender); + caption->getChild("sender_name", false)->setText(str_sender , style_params); - caption->getChild("msg_time", false)->setText(appendTime()); + caption->getChild("msg_time", false)->setText(appendTime() , style_params ); LLChatMsgBox* msg_text = getChild("msg_text", false); - msg_text->setText(mText); + msg_text->setText(mText, style_params); LLUICtrl* msg_inspector = caption->getChild("msg_inspector"); if(mSourceType != CHAT_SOURCE_AGENT) @@ -171,7 +196,15 @@ void LLNearbyChatToastPanel::setMessage (const LLChat& chat_msg) notification["from_id"] = chat_msg.mFromID; notification["time"] = chat_msg.mTime; notification["source"] = (S32)chat_msg.mSourceType; - + + 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); } @@ -201,11 +234,17 @@ void LLNearbyChatToastPanel::setWidth(S32 width) text_box->reshape(width - msg_left_offset - msg_right_offset,100/*its not magic number, we just need any number*/); LLChatMsgBox* msg_text = getChild("msg_text", false); + + LLStyle::Params style_params; + style_params.color(mTextColor); + style_params.font(mFont); + + if(mText.length()) - msg_text->setText(mText); + msg_text->setText(mText, style_params); for(size_t i=0;iaddText(mMessages[i]); + msg_text->addText(mMessages[i] , style_params); setRect(LLRect(getRect().mLeft, getRect().mTop, getRect().mLeft + width , getRect().mBottom)); snapToMessageHeight (); -- cgit v1.2.3 From 1baf1d218644ac5dc00d9b41119a1ef168c709a2 Mon Sep 17 00:00:00 2001 From: angela Date: Mon, 16 Nov 2009 20:46:40 +0800 Subject: fix chat format for /me --- indra/newview/llchatitemscontainerctrl.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'indra/newview/llchatitemscontainerctrl.cpp') diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index d2e3247250..1cc6b2beef 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -173,10 +173,28 @@ void LLNearbyChatToastPanel::init(LLSD& notification) caption->getChild("msg_time", false)->setText(appendTime() , style_params ); - LLChatMsgBox* msg_text = getChild("msg_text", false); - msg_text->setText(mText, style_params); + + if(notification["chat_style"].asInteger()== CHAT_STYLE_IRC) + { + if (mFromName.size() > 0) + { + style_params.italic= true; + + msg_text->setText(mFromName, style_params); + } + mText = mText.substr(3); + style_params.underline = true; + msg_text->addText(mText,style_params); + } + else + { + msg_text->setText(mText, style_params); + } + + + LLUICtrl* msg_inspector = caption->getChild("msg_inspector"); if(mSourceType != CHAT_SOURCE_AGENT) msg_inspector->setVisible(false); @@ -196,6 +214,8 @@ void LLNearbyChatToastPanel::setMessage (const LLChat& chat_msg) 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; -- cgit v1.2.3 From 0098bf40ea73078e2164ae55a8fa2f9049d0d4e9 Mon Sep 17 00:00:00 2001 From: angela Date: Tue, 17 Nov 2009 16:33:49 +0800 Subject: undo the changes for LLStyle params; add sizeFromFont in LLFontGL ; use font.style, font.name and font.size params for font creating --- indra/newview/llchatitemscontainerctrl.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'indra/newview/llchatitemscontainerctrl.cpp') diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index 1cc6b2beef..b1dee46d2e 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -160,10 +160,14 @@ void LLNearbyChatToastPanel::init(LLSD& notification) LLStyle::Params style_params; style_params.color(mTextColor); - style_params.font(mFont); - - std::string str_sender; +// 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); + std::string str_sender; + if(gAgentID != mFromID) str_sender = mFromName; else @@ -180,12 +184,12 @@ void LLNearbyChatToastPanel::init(LLSD& notification) { if (mFromName.size() > 0) { - style_params.italic= true; + style_params.font.style = "ITALIC"; msg_text->setText(mFromName, style_params); } mText = mText.substr(3); - style_params.underline = true; + style_params.font.style = "UNDERLINE"; msg_text->addText(mText,style_params); } else -- cgit v1.2.3 From 1804fce466ff242e63f995bc47178e1514c5a59d Mon Sep 17 00:00:00 2001 From: Yuri Chebotarev Date: Tue, 17 Nov 2009 13:52:16 +0200 Subject: fix4 normal task EXT-2521 Remove timestamp and fake voice indicator from nearby chat toasts --HG-- branch : product-engine --- indra/newview/llchatitemscontainerctrl.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/llchatitemscontainerctrl.cpp') diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index d2e3247250..244c7b1794 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -171,9 +171,6 @@ void LLNearbyChatToastPanel::init(LLSD& notification) caption->getChild("sender_name", false)->setText(str_sender , style_params); - caption->getChild("msg_time", false)->setText(appendTime() , style_params ); - - LLChatMsgBox* msg_text = getChild("msg_text", false); msg_text->setText(mText, style_params); -- cgit v1.2.3 From a46794bcff15b70ab4e5e04ce12d118579b72245 Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 18 Nov 2009 14:27:58 -0800 Subject: EXT-2579 Fix memory leak/bloat due to /me IRC-style emotes. Pending review with Richard/Leyla --- indra/newview/llchatitemscontainerctrl.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/newview/llchatitemscontainerctrl.cpp') diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index 997aed4277..56b7520bd5 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -188,7 +188,17 @@ void LLNearbyChatToastPanel::init(LLSD& notification) } mText = mText.substr(3); style_params.font.style = "UNDERLINE"; +#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 { -- cgit v1.2.3 From 203490e2a0915c5ce59ccacba420388327f9143b Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 18 Nov 2009 14:29:01 -0800 Subject: Change /me emote formatting to pure italics, not underlined. Review pending with Richard/Leyla --- indra/newview/llchatitemscontainerctrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llchatitemscontainerctrl.cpp') diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index 56b7520bd5..8a6935b71b 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -187,7 +187,7 @@ void LLNearbyChatToastPanel::init(LLSD& notification) msg_text->setText(mFromName, style_params); } mText = mText.substr(3); - style_params.font.style = "UNDERLINE"; + style_params.font.style = "ITALIC"; #define INFINITE_REFLOW_BUG 0 #if INFINITE_REFLOW_BUG // This causes LLTextBase::reflow() to infinite loop until the viewer -- cgit v1.2.3