summaryrefslogtreecommitdiff
path: root/indra/newview/llchatitemscontainerctrl.cpp
diff options
context:
space:
mode:
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;