diff options
| author | richard <none@none> | 2010-01-06 12:23:56 -0800 | 
|---|---|---|
| committer | richard <none@none> | 2010-01-06 12:23:56 -0800 | 
| commit | 49660730308fb6d5301d1617402a353a21e9d9be (patch) | |
| tree | 90887ce7d989a2ceb6a5e5f23aa9b2a123ab5abb | |
| parent | 3b7080a6b112c492a9025ae1a350db0ab4e88e50 (diff) | |
moved clipping logic inside LLFontGL::maxDrawableChars controlled by EWordWrapStyle
fixes regression introduced in 3eef5ce9ae1e6fc62b9b52ce859501dd4e70fadf
reviewed by Brad
| -rw-r--r-- | indra/llrender/llfontgl.cpp | 21 | ||||
| -rw-r--r-- | indra/llrender/llfontgl.h | 8 | ||||
| -rw-r--r-- | indra/llui/llconsole.cpp | 7 | ||||
| -rw-r--r-- | indra/llui/lltextbase.cpp | 7 | ||||
| -rw-r--r-- | indra/newview/llhudtext.cpp | 14 | 
5 files changed, 34 insertions, 23 deletions
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index d3497c1c23..1de1d6ded4 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -472,7 +472,7 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, S32 begin_offset, S32 max_chars  }  // Returns the max number of complete characters from text (up to max_chars) that can be drawn in max_pixels -S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars, BOOL end_on_word_boundary) const +S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars, EWordWrapStyle end_on_word_boundary) const  {  	if (!wchars || !wchars[0] || max_chars == 0)  	{ @@ -562,9 +562,24 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch  		drawn_x = cur_x;  	} -	if( clip && end_on_word_boundary ) +	if( clip )  	{ -		i = start_of_last_word; +		switch (end_on_word_boundary) +		{ +		case ONLY_WORD_BOUNDARIES: +			i = start_of_last_word; +			break; +		case WORD_BOUNDARY_IF_POSSIBLE: +			if (start_of_last_word != 0) +			{ +				i = start_of_last_word; +			} +			break; +		default: +		case ANYWHERE: +			// do nothing +			break; +		}  	}  	return i;  } diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index ea8eee7690..dfa4cf8ce5 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -122,7 +122,13 @@ public:  	// The following are called often, frequently with large buffers, so do not use a string interface  	// Returns the max number of complete characters from text (up to max_chars) that can be drawn in max_pixels -	S32	maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars = S32_MAX, BOOL end_on_word_boundary = FALSE) const; +	typedef enum e_word_wrap_style +	{ +		ONLY_WORD_BOUNDARIES, +		WORD_BOUNDARY_IF_POSSIBLE, +		ANYWHERE +	} EWordWrapStyle ; +	S32	maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars = S32_MAX, EWordWrapStyle end_on_word_boundary = ANYWHERE) const;  	// Returns the index of the first complete characters from text that can be drawn in max_pixels  	// given that the character at start_pos should be the last character (or as close to last as possible). diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index 7248581ec6..f69e935754 100644 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -330,12 +330,7 @@ void LLConsole::Paragraph::updateLines(F32 screen_width, const LLFontGL* font, b  			skip_chars = 0;  		} -		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); -		} +		U32 drawable = font->maxDrawableChars(mParagraphText.c_str()+paragraph_offset, screen_width, line_end - paragraph_offset, LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);  		if (drawable != 0)  		{ diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 7447a984ac..5ebf49c488 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2509,10 +2509,15 @@ S32	LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin  	// set max characters to length of segment, or to first newline  	max_chars = llmin(max_chars, last_char - (mStart + segment_offset)); +	// if no character yet displayed on this line, don't require word wrapping since +	// we can just move to the next line, otherwise insist on it so we make forward progress +	LLFontGL::EWordWrapStyle word_wrap_style = (line_offset == 0)  +		? LLFontGL::WORD_BOUNDARY_IF_POSSIBLE  +		: LLFontGL::ONLY_WORD_BOUNDARIES;  	S32 num_chars = mStyle->getFont()->maxDrawableChars(text.c_str() + segment_offset + mStart,   												(F32)num_pixels,  												max_chars,  -												TRUE); +												word_wrap_style);  	if (num_chars == 0   		&& line_offset == 0  diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index b95e5f53e8..08cf86df4a 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -606,12 +606,7 @@ void LLHUDText::addLine(const LLWString &wstr, const LLColor4& color, const LLFo  			U32 line_length = 0;  			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); -				} +				S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wline.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);  				mTextSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), style, color));  				line_length += segment_length;  			} @@ -647,12 +642,7 @@ void LLHUDText::setLabel(const LLWString &wlabel)  			U32 line_length = 0;  			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); -				} +				S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wstr.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);  				mLabelSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), LLFontGL::NORMAL, mColor));  				line_length += segment_length;  			}  | 
