From 1bbd259f2d009a807a09aea15d01d0872f8b1cad Mon Sep 17 00:00:00 2001
From: richard <none@none>
Date: Wed, 6 Jan 2010 11:17:38 -0800
Subject: [PATCH] EXT-3878 - Menus disappear when UI Size is < 1.00 EXT-3647 -
 Auto-scrolling of IMs should resume when user types in chat EXT-3877 -
 Pinning two levels of menus prevents movement using arrow keys EXT-1303 -
 Hyperlink text wraps in the middle of a word

reviewed by James
---
 indra/llrender/llfontgl.cpp      |  2 +-
 indra/llui/llconsole.cpp         |  5 +++
 indra/llui/llmenugl.cpp          | 55 +++++++++++++++++---------------
 indra/newview/llchathistory.cpp  |  6 ++++
 indra/newview/llhudtext.cpp      | 10 ++++++
 indra/newview/llviewerwindow.cpp |  2 +-
 6 files changed, 53 insertions(+), 27 deletions(-)

diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 37a28ac7213..d3497c1c23a 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -562,7 +562,7 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch
 		drawn_x = cur_x;
 	}
 
-	if( clip && end_on_word_boundary && (start_of_last_word != 0) )
+	if( clip && end_on_word_boundary )
 	{
 		i = start_of_last_word;
 	}
diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp
index fa0abd55d02..7248581ec66 100644
--- a/indra/llui/llconsole.cpp
+++ b/indra/llui/llconsole.cpp
@@ -331,6 +331,11 @@ void LLConsole::Paragraph::updateLines(F32 screen_width, const LLFontGL* font, b
 		}
 
 		U32 drawable = font->maxDrawableChars(mParagraphText.c_str()+paragraph_offset, screen_width, line_end - paragraph_offset, TRUE);
+		if (drawable == 0)
+		{
+			// try again without wrapping on word boundaries
+			drawable = font->maxDrawableChars(mParagraphText.c_str()+paragraph_offset, screen_width, line_end - paragraph_offset, FALSE);
+		}
 
 		if (drawable != 0)
 		{
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 2648cbf08db..527c0a1b875 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -1143,37 +1143,41 @@ BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask )
 	if (!branch)
 		return LLMenuItemGL::handleKeyHere(key, mask);
 
-	if (getMenu()->getVisible() && branch->getVisible() && key == KEY_LEFT)
+	// an item is highlighted, my menu is open, and I have an active sub menu or we are in
+	// keyboard navigation mode
+	if (getHighlight() 
+		&& getMenu()->isOpen() 
+		&& (isActive() || LLMenuGL::getKeyboardMode()))
 	{
-		// switch to keyboard navigation mode
-		LLMenuGL::setKeyboardMode(TRUE);
-
-		BOOL handled = branch->clearHoverItem();
-		if (branch->getTornOff())
+		if (branch->getVisible() && key == KEY_LEFT)
 		{
-			((LLFloater*)branch->getParent())->setFocus(FALSE);
-		}
-		if (handled && getMenu()->getTornOff())
-		{
-			((LLFloater*)getMenu()->getParent())->setFocus(TRUE);
-		}
-		return handled;
-	}
+			// switch to keyboard navigation mode
+			LLMenuGL::setKeyboardMode(TRUE);
 
-	if (getHighlight() && 
-		getMenu()->isOpen() && 
-		key == KEY_RIGHT && !branch->getHighlightedItem())
-	{
-		// switch to keyboard navigation mode
-		LLMenuGL::setKeyboardMode(TRUE);
+			BOOL handled = branch->clearHoverItem();
+			if (branch->getTornOff())
+			{
+				((LLFloater*)branch->getParent())->setFocus(FALSE);
+			}
+			if (handled && getMenu()->getTornOff())
+			{
+				((LLFloater*)getMenu()->getParent())->setFocus(TRUE);
+			}
+			return handled;
+		}
 
-		LLMenuItemGL* itemp = branch->highlightNextItem(NULL);
-		if (itemp)
+		if (key == KEY_RIGHT && !branch->getHighlightedItem())
 		{
-			return TRUE;
+			// switch to keyboard navigation mode
+			LLMenuGL::setKeyboardMode(TRUE);
+
+			LLMenuItemGL* itemp = branch->highlightNextItem(NULL);
+			if (itemp)
+			{
+				return TRUE;
+			}
 		}
 	}
-
 	return LLMenuItemGL::handleKeyHere(key, mask);
 }
 
@@ -1431,7 +1435,7 @@ BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask)
 {
 	BOOL menu_open = getBranch()->getVisible();
 	// don't do keyboard navigation of top-level menus unless in keyboard mode, or menu expanded
-	if (getHighlight() && getMenu()->getVisible() && (isActive() || LLMenuGL::getKeyboardMode()))
+	if (getHighlight() && getMenu()->isOpen() && (isActive() || LLMenuGL::getKeyboardMode()))
 	{
 		if (key == KEY_LEFT)
 		{
@@ -2836,6 +2840,7 @@ BOOL LLMenuGL::handleScrollWheel( S32 x, S32 y, S32 clicks )
 	return TRUE;
 }
 
+
 void LLMenuGL::draw( void )
 {
 	if (mNeedsArrange)
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 21cadda6e3e..dac32805752 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -593,6 +593,12 @@ void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_
 		mEditor->appendText(message, FALSE, style_params);
 	}
 	mEditor->blockUndo();
+
+	// automatically scroll to end when receiving chat from myself
+	if (chat.mFromID == gAgentID)
+	{
+		mEditor->setCursorAndScrollToEnd();
+	}
 }
 
 void LLChatHistory::draw()
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 0b5da40be4d..b95e5f53e8f 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -607,6 +607,11 @@ void LLHUDText::addLine(const LLWString &wstr, const LLColor4& color, const LLFo
 			do	
 			{
 				S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wline.length(), TRUE);
+				if (segment_length == 0)
+				{
+					// try again without wrapping on word boundaries
+					segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wline.length(), FALSE);
+				}
 				mTextSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), style, color));
 				line_length += segment_length;
 			}
@@ -643,6 +648,11 @@ void LLHUDText::setLabel(const LLWString &wlabel)
 			do	
 			{
 				S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wstr.length(), TRUE);
+				if (segment_length == 0)
+				{
+					// try again without wrapping on word boundaries
+					segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wstr.length(), FALSE);
+				}
 				mLabelSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), LLFontGL::NORMAL, mColor));
 				line_length += segment_length;
 			}
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 14002531769..83cbc8a1f91 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1897,7 +1897,7 @@ void LLViewerWindow::draw()
 
 	if (!gSavedSettings.getBOOL("RenderUIBuffer"))
 	{
-		LLUI::sDirtyRect = this->getWindowRectRaw();
+		LLUI::sDirtyRect = getWindowRectScaled();
 	}
 
 	// HACK for timecode debugging
-- 
GitLab