summaryrefslogtreecommitdiff
path: root/indra/newview/llchatitemscontainerctrl.cpp
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2016-11-11 11:18:31 +0200
committerMnikolenko Productengine <mnikolenko@productengine.com>2016-11-11 11:18:31 +0200
commit51bef9ed464ee82636c5880740e8073a89f25def (patch)
tree4fdf6733c430fe451cad38e36168cd2718abfde7 /indra/newview/llchatitemscontainerctrl.cpp
parentb6e7708d608ee045a204758b2c259da1d4e826cc (diff)
MAINT-6891 Chat longer than "fade after n lines" doesn't show except in chat history
Diffstat (limited to 'indra/newview/llchatitemscontainerctrl.cpp')
-rw-r--r--indra/newview/llchatitemscontainerctrl.cpp26
1 files changed, 26 insertions, 0 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;