diff options
author | Rick Pasetto <rick@lindenlab.com> | 2009-12-21 10:44:13 -0800 |
---|---|---|
committer | Rick Pasetto <rick@lindenlab.com> | 2009-12-21 10:44:13 -0800 |
commit | 2ebd9b54af332c653917c2b38000f30817dbe364 (patch) | |
tree | c292dd7e4d093686a2dccdfb3e5fce2c40a0f823 /indra/newview | |
parent | 16ae542f5ae3d00fd5ffe744914af0506bed68c2 (diff) | |
parent | 5d8442f05613a4b7bc2b1ffb88e2450a4de965ea (diff) |
Automated merge with ssh://richard@hg.lindenlab.com/james/gooey
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llchathistory.cpp | 141 | ||||
-rw-r--r-- | indra/newview/llchathistory.h | 22 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_aaa.xml | 10 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/strings.xml | 6 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/widgets/chat_history.xml | 8 |
5 files changed, 153 insertions, 34 deletions
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index ee60df1b4b..7f33a8329c 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -44,6 +44,8 @@ #include "llfloaterreg.h" #include "llmutelist.h" #include "llstylemap.h" +#include "lllayoutstack.h" +#include "llagent.h" #include "llsidetray.h"//for blocked objects panel @@ -311,18 +313,23 @@ protected: LLChatHistory::LLChatHistory(const LLChatHistory::Params& p) -: LLTextEditor(p), -mMessageHeaderFilename(p.message_header), -mMessageSeparatorFilename(p.message_separator), -mLeftTextPad(p.left_text_pad), -mRightTextPad(p.right_text_pad), -mLeftWidgetPad(p.left_widget_pad), -mRightWidgetPad(p.right_widget_pad), -mTopSeparatorPad(p.top_separator_pad), -mBottomSeparatorPad(p.bottom_separator_pad), -mTopHeaderPad(p.top_header_pad), -mBottomHeaderPad(p.bottom_header_pad) +: LLUICtrl(p), + mMessageHeaderFilename(p.message_header), + mMessageSeparatorFilename(p.message_separator), + mLeftTextPad(p.left_text_pad), + mRightTextPad(p.right_text_pad), + mLeftWidgetPad(p.left_widget_pad), + mRightWidgetPad(p.right_widget_pad), + mTopSeparatorPad(p.top_separator_pad), + mBottomSeparatorPad(p.bottom_separator_pad), + mTopHeaderPad(p.top_header_pad), + mBottomHeaderPad(p.bottom_header_pad) { + LLTextEditor::Params editor_params(p); + editor_params.rect = getLocalRect(); + editor_params.follows.flags = FOLLOWS_ALL; + editor_params.enabled = false; // read only + mEditor = LLUICtrlFactory::create<LLTextEditor>(editor_params, this); } LLChatHistory::~LLChatHistory() @@ -330,6 +337,49 @@ LLChatHistory::~LLChatHistory() this->clear(); } +void LLChatHistory::initFromParams(const LLChatHistory::Params& p) +{ + static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); + + LLRect stack_rect = getLocalRect(); + stack_rect.mRight -= scrollbar_size; + LLLayoutStack::Params layout_p; + layout_p.rect = stack_rect; + layout_p.follows.flags = FOLLOWS_ALL; + layout_p.orientation = "vertical"; + layout_p.mouse_opaque = false; + + LLLayoutStack* stackp = LLUICtrlFactory::create<LLLayoutStack>(layout_p, this); + + const S32 NEW_TEXT_NOTICE_HEIGHT = 20; + + LLPanel::Params panel_p; + panel_p.name = "spacer"; + panel_p.background_visible = false; + panel_p.has_border = false; + panel_p.mouse_opaque = false; + stackp->addPanel(LLUICtrlFactory::create<LLPanel>(panel_p), 0, 30, true, false, LLLayoutStack::ANIMATE); + + panel_p.name = "new_text_notice_holder"; + LLRect new_text_notice_rect = getLocalRect(); + new_text_notice_rect.mTop = new_text_notice_rect.mBottom + NEW_TEXT_NOTICE_HEIGHT; + panel_p.rect = new_text_notice_rect; + panel_p.background_opaque = true; + panel_p.background_visible = true; + panel_p.visible = false; + mMoreChatPanel = LLUICtrlFactory::create<LLPanel>(panel_p); + + LLTextBox::Params text_p(p.more_chat_text); + text_p.rect = mMoreChatPanel->getLocalRect(); + text_p.follows.flags = FOLLOWS_ALL; + text_p.name = "more_chat_text"; + mMoreChatText = LLUICtrlFactory::create<LLTextBox>(text_p, mMoreChatPanel); + mMoreChatText->setClickedCallback(boost::bind(&LLChatHistory::onClickMoreText, this)); + + stackp->addPanel(mMoreChatPanel, 0, 0, false, false, LLLayoutStack::ANIMATE); +} + + /*void LLChatHistory::updateTextRect() { static LLUICachedControl<S32> texteditor_border ("UITextEditorBorder", 0); @@ -358,15 +408,49 @@ LLView* LLChatHistory::getHeader(const LLChat& chat,const LLStyle::Params& style return header; } +void LLChatHistory::onClickMoreText() +{ + mEditor->endOfDoc(); +} + void LLChatHistory::clear() { mLastFromName.clear(); - LLTextEditor::clear(); + mEditor->clear(); mLastFromID = LLUUID::null; } void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_chat_history, const LLStyle::Params& input_append_params) { + if (!mEditor->scrolledToEnd() && chat.mFromID != gAgent.getID()) + { + mUnreadChatSources.insert(chat.mFromName); + mMoreChatPanel->setVisible(TRUE); + std::string chatters; + for (unread_chat_source_t::iterator it = mUnreadChatSources.begin(); + it != mUnreadChatSources.end();) + { + chatters += *it; + if (++it != mUnreadChatSources.end()) + { + chatters += ","; + } + } + LLStringUtil::format_map_t args; + args["SOURCES"] = chatters; + + if (mUnreadChatSources.size() == 1) + { + mMoreChatText->setValue(LLTrans::getString("unread_chat_single", args)); + } + else + { + mMoreChatText->setValue(LLTrans::getString("unread_chat_multiple", args)); + } + S32 height = mMoreChatText->getTextPixelHeight() + 5; + mMoreChatPanel->reshape(mMoreChatPanel->getRect().getWidth(), height); + } + LLColor4 txt_color = LLUIColorTable::instance().getColor("White"); LLViewerChat::getChatColor(chat,txt_color); LLFontGL* fontp = LLViewerChat::getChatFont(); @@ -381,7 +465,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_ if (use_plain_text_chat_history) { - appendText("[" + chat.mTimeStr + "] ", getText().size() != 0, style_params); + mEditor->appendText("[" + chat.mTimeStr + "] ", mEditor->getText().size() != 0, style_params); if (utf8str_trim(chat.mFromName).size() != 0) { @@ -391,11 +475,11 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_ LLStyle::Params link_params(style_params); link_params.fillFrom(LLStyleMap::instance().lookupAgent(chat.mFromID)); // Convert the name to a hotlink and add to message. - appendText(chat.mFromName + ": ", false, link_params); + mEditor->appendText(chat.mFromName + ": ", false, link_params); } else { - appendText(chat.mFromName + ": ", false, style_params); + mEditor->appendText(chat.mFromName + ": ", false, style_params); } } } @@ -422,7 +506,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_ else { view = getHeader(chat, style_params); - if (getText().size() == 0) + if (mEditor->getText().size() == 0) p.top_pad = 0; else p.top_pad = mTopHeaderPad; @@ -432,9 +516,9 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_ p.view = view; //Prepare the rect for the view - LLRect target_rect = getDocumentView()->getRect(); + LLRect target_rect = mEditor->getDocumentView()->getRect(); // squeeze down the widget by subtracting padding off left and right - target_rect.mLeft += mLeftWidgetPad + mHPad; + target_rect.mLeft += mLeftWidgetPad + mEditor->getHPad(); target_rect.mRight -= mRightWidgetPad; view->reshape(target_rect.getWidth(), view->getRect().getHeight()); view->setOrigin(target_rect.mLeft, view->getRect().mBottom); @@ -443,7 +527,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_ if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM) header_text += chat.mFromName + ": "; - appendWidget(p, header_text, false); + mEditor->appendWidget(p, header_text, false); mLastFromName = chat.mFromName; mLastFromID = chat.mFromID; mLastMessageTime = new_message_time; @@ -455,10 +539,10 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_ style_params.font.style = "ITALIC"; if (chat.mFromName.size() > 0) - appendText(chat.mFromName + " ", TRUE, style_params); + mEditor->appendText(chat.mFromName + " ", TRUE, style_params); // Ensure that message ends with NewLine, to avoid losing of new lines // while copy/paste from text chat. See EXT-3263. - appendText(chat.mText.substr(4) + NEW_LINE, FALSE, style_params); + mEditor->appendText(chat.mText.substr(4) + NEW_LINE, FALSE, style_params); } else { @@ -469,8 +553,19 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_ // while copy/paste from text chat. See EXT-3263. message += NEW_LINE; } - appendText(message, FALSE, style_params); + mEditor->appendText(message, FALSE, style_params); } - blockUndo(); + mEditor->blockUndo(); +} + +void LLChatHistory::draw() +{ + if (mEditor->scrolledToEnd()) + { + mUnreadChatSources.clear(); + mMoreChatPanel->setVisible(FALSE); + } + + LLUICtrl::draw(); } diff --git a/indra/newview/llchathistory.h b/indra/newview/llchathistory.h index 8ca7dd1d58..260015e2dc 100644 --- a/indra/newview/llchathistory.h +++ b/indra/newview/llchathistory.h @@ -34,10 +34,11 @@ #define LLCHATHISTORY_H_ #include "lltexteditor.h" +#include "lltextbox.h" #include "llviewerchat.h" //Chat log widget allowing addition of a message as a widget -class LLChatHistory : public LLTextEditor +class LLChatHistory : public LLUICtrl { public: struct Params : public LLInitParam::Block<Params, LLTextEditor::Params> @@ -63,6 +64,8 @@ class LLChatHistory : public LLTextEditor //Header bottom padding Optional<S32> bottom_header_pad; + Optional<LLTextBox::Params> more_chat_text; + Params() : message_header("message_header"), message_separator("message_separator"), @@ -73,15 +76,16 @@ class LLChatHistory : public LLTextEditor top_separator_pad("top_separator_pad"), bottom_separator_pad("bottom_separator_pad"), top_header_pad("top_header_pad"), - bottom_header_pad("bottom_header_pad") - { - } + bottom_header_pad("bottom_header_pad"), + more_chat_text("more_chat_text") + {} }; protected: LLChatHistory(const Params&); friend class LLUICtrlFactory; + /*virtual*/ void draw(); /** * Redefinition of LLTextEditor::updateTextRect() to considerate text * left/right padding params. @@ -98,9 +102,13 @@ class LLChatHistory : public LLTextEditor */ LLView* getHeader(const LLChat& chat,const LLStyle::Params& style_params); + void onClickMoreText(); + public: ~LLChatHistory(); + void initFromParams(const Params&); + /** * Appends a widget message. * If last user appended message, concurs with current user, @@ -129,5 +137,11 @@ class LLChatHistory : public LLTextEditor S32 mBottomSeparatorPad; S32 mTopHeaderPad; S32 mBottomHeaderPad; + + LLPanel* mMoreChatPanel; + LLTextBox* mMoreChatText; + LLTextEditor* mEditor; + typedef std::set<std::string> unread_chat_source_t; + unread_chat_source_t mUnreadChatSources; }; #endif /* LLCHATHISTORY_H_ */ diff --git a/indra/newview/skins/default/xui/en/floater_aaa.xml b/indra/newview/skins/default/xui/en/floater_aaa.xml index 6956b73371..cb4cbd229a 100644 --- a/indra/newview/skins/default/xui/en/floater_aaa.xml +++ b/indra/newview/skins/default/xui/en/floater_aaa.xml @@ -15,21 +15,21 @@ title="TEST FLOATER" save_dock_state="true" save_visibility="true" - single_instance="true" + single_instance="true" width="320"> <string name="nudge_parabuild">Nudge 1</string> <string name="test_the_vlt">This string is extracted.</string> <chat_history allow_html="true" bg_readonly_color="ChatHistoryBgColor" - bg_writeable_color="ChatHistoryBgColor" - border_visible="false" + bg_writeable_color="ChatHistoryBgColor" + border_visible="false" follows="all" font="SansSerif" - left="1" + left="1" top="20" layout="topleft" - height="260" + height="260" name="chat_history" parse_highlights="true" text_color="ChatHistoryTextColor" diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index ec4723bd55..1ab2507232 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -2929,4 +2929,10 @@ If you continue to receive this message, contact the [SUPPORT_SITE]. <string name="close_on_no_ability"> You no longer have the ability to be in the chat session. </string> + <string name="unread_chat_single"> + [SOURCES] has said something new + </string>" + <string name="unread_chat_multiple"> + [SOURCES] have said something new + </string>" </strings> diff --git a/indra/newview/skins/default/xui/en/widgets/chat_history.xml b/indra/newview/skins/default/xui/en/widgets/chat_history.xml index 2be37d222a..8785dff2ae 100644 --- a/indra/newview/skins/default/xui/en/widgets/chat_history.xml +++ b/indra/newview/skins/default/xui/en/widgets/chat_history.xml @@ -11,9 +11,13 @@ top_header_pad="17" bottom_header_pad="10" max_length="2147483647" - enabled="false" track_bottom="true" name="chat_history" type="string" word_wrap="true" - font="SansSerif"/> + font="SansSerif"> + <more_chat_text + mouse_opaque="true" + word_wrap="true" + /> +</chat_history> |