summaryrefslogtreecommitdiff
path: root/indra/newview/lltoastpanel.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2013-03-13 15:15:15 -0400
committerOz Linden <oz@lindenlab.com>2013-03-13 15:15:15 -0400
commit75722baf295aff7927bff3c70cdf0ec27399cb37 (patch)
treea7a3fccc7bfebb4605c561e34ac66ad3c478368e /indra/newview/lltoastpanel.cpp
parent5c68b2456e8603322a1f12694c196246752bab53 (diff)
parentd348deb7049cbaef7c228000525c7ee5a265464c (diff)
merge changes for latest viewer-development
Diffstat (limited to 'indra/newview/lltoastpanel.cpp')
-rw-r--r--indra/newview/lltoastpanel.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/indra/newview/lltoastpanel.cpp b/indra/newview/lltoastpanel.cpp
index c33fde99c5..a30f841980 100644
--- a/indra/newview/lltoastpanel.cpp
+++ b/indra/newview/lltoastpanel.cpp
@@ -58,6 +58,25 @@ const LLUUID& LLToastPanel::getID()
return mNotification->id();
}
+S32 LLToastPanel::computeSnappedToMessageHeight(LLTextBase* message, S32 maxLineCount)
+{
+ S32 heightDelta = 0;
+ S32 maxTextHeight = message->getFont()->getLineHeight() * maxLineCount;
+
+ LLRect messageRect = message->getRect();
+ S32 oldTextHeight = messageRect.getHeight();
+
+ //Knowing the height is set to max allowed, getTextPixelHeight returns needed text height
+ //Perhaps we need to pass maxLineCount as parameter to getTextPixelHeight to avoid previous reshape.
+ S32 requiredTextHeight = message->getTextBoundingRect().getHeight();
+ S32 newTextHeight = llmin(requiredTextHeight, maxTextHeight);
+
+ heightDelta = newTextHeight - oldTextHeight;
+ S32 new_panel_height = llmax(getRect().getHeight() + heightDelta, MIN_PANEL_HEIGHT);
+
+ return new_panel_height;
+}
+
//snap to the message height if it is visible
void LLToastPanel::snapToMessageHeight(LLTextBase* message, S32 maxLineCount)
{
@@ -69,22 +88,13 @@ void LLToastPanel::snapToMessageHeight(LLTextBase* message, S32 maxLineCount)
//Add message height if it is visible
if (message->getVisible())
{
- S32 heightDelta = 0;
- S32 maxTextHeight = message->getDefaultFont()->getLineHeight() * maxLineCount;
-
- LLRect messageRect = message->getRect();
- S32 oldTextHeight = messageRect.getHeight();
-
- //Knowing the height is set to max allowed, getTextPixelHeight returns needed text height
- //Perhaps we need to pass maxLineCount as parameter to getTextPixelHeight to avoid previous reshape.
- S32 requiredTextHeight = message->getTextBoundingRect().getHeight();
- S32 newTextHeight = llmin(requiredTextHeight, maxTextHeight);
-
- //Calculate last delta height deducting previous heightDelta
- heightDelta = newTextHeight - oldTextHeight - heightDelta;
+ S32 new_panel_height = computeSnappedToMessageHeight(message, maxLineCount);
//reshape the panel with new height
- reshape( getRect().getWidth(), llmax(getRect().getHeight() + heightDelta, MIN_PANEL_HEIGHT));
+ if (new_panel_height != getRect().getHeight())
+ {
+ reshape( getRect().getWidth(), new_panel_height);
+ }
}
}
@@ -98,7 +108,7 @@ LLToastPanel* LLToastPanel::buidPanelFromNotification(
if ("notifytip" == notification->getType())
{
// if it is online/offline notification
- if ("FriendOffline" == notification->getName() || "FriendOnline" == notification->getName())
+ if ("FriendOnlineOffline" == notification->getName())
{
res = new LLPanelOnlineStatus(notification);
}