summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llchatitemscontainerctrl.cpp26
-rw-r--r--indra/newview/llfloaterimnearbychathandler.cpp10
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;