diff options
| author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2016-11-11 11:18:31 +0200 | 
|---|---|---|
| committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2016-11-11 11:18:31 +0200 | 
| commit | 51bef9ed464ee82636c5880740e8073a89f25def (patch) | |
| tree | 4fdf6733c430fe451cad38e36168cd2718abfde7 | |
| parent | b6e7708d608ee045a204758b2c259da1d4e826cc (diff) | |
MAINT-6891 Chat longer than "fade after n lines" doesn't show except in chat history
| -rw-r--r-- | indra/newview/llchatitemscontainerctrl.cpp | 26 | ||||
| -rw-r--r-- | indra/newview/llfloaterimnearbychathandler.cpp | 10 | 
2 files changed, 35 insertions, 1 deletions
| diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index cfc62c07b6..f5721fb348 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -240,6 +240,32 @@ void LLFloaterIMNearbyChatToastPanel::init(LLSD& notification)  		}  	} +	S32 chars_in_line = mMsgText->getRect().getWidth() / messageFont->getWidth("c"); +	S32 max_lines = notification["available_height"].asInteger() / (mMsgText->getTextPixelHeight() + 4); +	S32 new_line_chars = std::count(messageText.begin(), messageText.end(), '\n'); +	S32 lines_count = (messageText.size() - new_line_chars) / chars_in_line + new_line_chars + 1; + +	//Remove excessive chars if message is not fit in available height. MAINT-6891 +	if(lines_count > max_lines) +	{ +		while(lines_count > max_lines) +		{ +			std::size_t nl_pos = messageText.rfind('\n'); +			if (nl_pos != std::string::npos) +			{ +				nl_pos = nl_pos > messageText.length() - chars_in_line? nl_pos : messageText.length() - chars_in_line; +				messageText.erase(messageText.begin() + nl_pos, messageText.end()); +			} +			else +			{ +				messageText.erase(messageText.end() - chars_in_line, messageText.end()); +			} +			new_line_chars = std::count(messageText.begin(), messageText.end(), '\n'); +			lines_count = (messageText.size() - new_line_chars) / chars_in_line + new_line_chars; +		} +		messageText += " ..."; +	} +  	//append text  	{  		LLStyle::Params style_params; diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp index 9fd731ed56..4cd91c53d8 100644 --- a/indra/newview/llfloaterimnearbychathandler.cpp +++ b/indra/newview/llfloaterimnearbychathandler.cpp @@ -285,6 +285,14 @@ void LLFloaterIMNearbyChatScreenChannel::addChat(LLSD& chat)  	if(mStopProcessing)  		return; +	if (mFloaterSnapRegion == NULL) +	{ +		mFloaterSnapRegion = gViewerWindow->getRootView()->getChildView("floater_snap_region"); +	} +	LLRect channel_rect; +	mFloaterSnapRegion->localRectToOtherView(mFloaterSnapRegion->getLocalRect(), &channel_rect, gFloaterView); +	chat["available_height"] = channel_rect.getHeight() - channel_rect.mBottom - gSavedSettings.getS32("ToastGap") - 110;; +  	/*      find last toast and check ID  	*/ @@ -380,7 +388,7 @@ void LLFloaterIMNearbyChatScreenChannel::arrangeToasts()  		setFollows(FOLLOWS_ALL);  	} -	LLRect	toast_rect;	 +	LLRect	toast_rect;  	updateRect();  	LLRect channel_rect; | 
