diff options
Diffstat (limited to 'indra/newview/llchathistory.cpp')
-rw-r--r-- | indra/newview/llchathistory.cpp | 105 |
1 files changed, 60 insertions, 45 deletions
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 4ce3b50ed5..cd0456b308 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -33,11 +33,9 @@ #include "llviewerprecompiledheaders.h" #include "llchathistory.h" #include "llpanel.h" -#include "lltextbox.h" #include "lluictrlfactory.h" #include "llscrollcontainer.h" #include "llavatariconctrl.h" - #include "llimview.h" #include "llcallingcard.h" //for LLAvatarTracker #include "llagentdata.h" @@ -185,11 +183,10 @@ public: mSourceType = CHAT_SOURCE_SYSTEM; } - LLTextBox* userName = getChild<LLTextBox>("user_name"); + LLTextEditor* userName = getChild<LLTextEditor>("user_name"); - LLUIColor color = style_params.color; - userName->setReadOnlyColor(color); - userName->setColor(color); + userName->setReadOnlyColor(style_params.readonly_color()); + userName->setColor(style_params.color()); if(!chat.mFromName.empty()) { @@ -203,7 +200,7 @@ public: } - LLTextBox* timeBox = getChild<LLTextBox>("time_box"); + LLUICtrl* timeBox = getChild<LLUICtrl>("time_box"); timeBox->setValue(chat.mTimeStr); LLAvatarIconCtrl* icon = getChild<LLAvatarIconCtrl>("avatar_icon"); @@ -334,20 +331,14 @@ LLView* LLChatHistory::getHeader(const LLChat& chat,const LLStyle::Params& style return header; } -void LLChatHistory::appendWidgetMessage(const LLChat& chat, const LLStyle::Params& input_append_params) +void LLChatHistory::clear() { - LLView* view = NULL; - std::string view_text = "\n[" + chat.mTimeStr + "] "; - if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM) - view_text += chat.mFromName + ": "; - - - LLInlineViewSegment::Params p; - p.force_newline = true; - p.left_pad = mLeftWidgetPad; - p.right_pad = mRightWidgetPad; + mLastFromName.clear(); + LLTextEditor::clear(); +} - +void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_chat_history, const LLStyle::Params& input_append_params) +{ LLColor4 txt_color = LLUIColorTable::instance().getColor("White"); LLViewerChat::getChatColor(chat,txt_color); LLFontGL* fontp = LLViewerChat::getChatFont(); @@ -360,39 +351,63 @@ void LLChatHistory::appendWidgetMessage(const LLChat& chat, const LLStyle::Param style_params.font.size(font_size); style_params.font.style(input_append_params.font.style); - + std::string header_text = "[" + chat.mTimeStr + "] "; + if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM) + header_text += chat.mFromName + ": "; - if (mLastFromName == chat.mFromName) + if (use_plain_text_chat_history) { - view = getSeparator(); - p.top_pad = mTopSeparatorPad; - p.bottom_pad = mBottomSeparatorPad; + appendText(header_text, getText().size() != 0, style_params); } else { - view = getHeader(chat,style_params); - if (getText().size() == 0) - p.top_pad = 0; + LLView* view = NULL; + LLInlineViewSegment::Params p; + p.force_newline = true; + p.left_pad = mLeftWidgetPad; + p.right_pad = mRightWidgetPad; + + if (mLastFromName == chat.mFromName) + { + view = getSeparator(); + p.top_pad = mTopSeparatorPad; + p.bottom_pad = mBottomSeparatorPad; + } else - p.top_pad = mTopHeaderPad; - p.bottom_pad = mBottomHeaderPad; - + { + view = getHeader(chat, style_params); + if (getText().size() == 0) + p.top_pad = 0; + else + p.top_pad = mTopHeaderPad; + p.bottom_pad = mBottomHeaderPad; + + } + p.view = view; + + //Prepare the rect for the view + LLRect target_rect = getDocumentView()->getRect(); + // squeeze down the widget by subtracting padding off left and right + target_rect.mLeft += mLeftWidgetPad + mHPad; + target_rect.mRight -= mRightWidgetPad; + view->reshape(target_rect.getWidth(), view->getRect().getHeight()); + view->setOrigin(target_rect.mLeft, view->getRect().mBottom); + + appendWidget(p, header_text, false); + mLastFromName = chat.mFromName; } - p.view = view; - - //Prepare the rect for the view - LLRect target_rect = getDocumentView()->getRect(); - // squeeze down the widget by subtracting padding off left and right - target_rect.mLeft += mLeftWidgetPad + mHPad; - target_rect.mRight -= mRightWidgetPad; - view->reshape(target_rect.getWidth(), view->getRect().getHeight()); - view->setOrigin(target_rect.mLeft, view->getRect().mBottom); - - appendWidget(p, view_text, false); - - //Append the text message - appendText(chat.mText, FALSE, style_params); + //Handle IRC styled /me messages. + std::string prefix = chat.mText.substr(0, 4); + if (prefix == "/me " || prefix == "/me'") + { + style_params.font.style = "ITALIC"; - mLastFromName = chat.mFromName; + if (chat.mFromName.size() > 0) + appendText(chat.mFromName + " ", TRUE, style_params); + appendText(chat.mText.substr(4), FALSE, style_params); + } + else + appendText(chat.mText, FALSE, style_params); blockUndo(); } + |