MAINT-6891 Chat longer than "fade after n lines" doesn't show except in chat history
parent
b6e7708d60
commit
51bef9ed46
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue