diff options
| author | andreykproductengine <akleshchev@productengine.com> | 2017-04-06 21:29:43 +0300 | 
|---|---|---|
| committer | andreykproductengine <akleshchev@productengine.com> | 2017-04-06 21:29:43 +0300 | 
| commit | b7c909367e2cf022588413accae9d2dc6bd8cf34 (patch) | |
| tree | 3998b5942bc65045bcd2cb657991dce1995205fc | |
| parent | 49481ef80ce8f132dc7e56ec550a1461787e59e4 (diff) | |
MAINT-7267 Fixed UI missing last symbol of string on hi-res monitors.
| -rw-r--r-- | indra/llui/lltextbase.cpp | 37 | ||||
| -rw-r--r-- | indra/llui/lltextbase.h | 11 | ||||
| -rw-r--r-- | indra/newview/llexpandabletextbox.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llviewertexteditor.cpp | 4 | 
4 files changed, 33 insertions, 21 deletions
| diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index f3a99dcef2..c570285856 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1505,8 +1505,8 @@ void LLTextBase::reflow()  		segment_set_t::iterator seg_iter = mSegments.begin();  		S32 seg_offset = 0;  		S32 line_start_index = 0; -		const S32 text_available_width = mVisibleTextRect.getWidth() - mHPad;  // reserve room for margin -		S32 remaining_pixels = text_available_width; +		const F32 text_available_width = mVisibleTextRect.getWidth() - mHPad;  // reserve room for margin +		F32 remaining_pixels = text_available_width;  		S32 line_count = 0;  		// find and erase line info structs starting at start_index and going to end of document @@ -1532,14 +1532,15 @@ void LLTextBase::reflow()  			S32 cur_index = segment->getStart() + seg_offset;  			// ask segment how many character fit in remaining space -			S32 character_count = segment->getNumChars(getWordWrap() ? llmax(0, remaining_pixels) : S32_MAX, +			S32 character_count = segment->getNumChars(getWordWrap() ? llmax(0, ll_round(remaining_pixels)) : S32_MAX,  														seg_offset,   														cur_index - line_start_index,   														S32_MAX,  														line_count - seg_line_offset); -			S32 segment_width, segment_height; -			bool force_newline = segment->getDimensions(seg_offset, character_count, segment_width, segment_height); +			F32 segment_width; +			S32 segment_height; +			bool force_newline = segment->getDimensionsF32(seg_offset, character_count, segment_width, segment_height);  			// grow line height as necessary based on reported height of this segment  			line_height = llmax(line_height, segment_height);  			remaining_pixels -= segment_width; @@ -1548,11 +1549,13 @@ void LLTextBase::reflow()  			S32 last_segment_char_on_line = segment->getStart() + seg_offset; -			S32 text_actual_width = text_available_width - remaining_pixels; +			// Note: make sure text will fit in width - use ceil, but also make sure +			// ceil is used only once per line +			S32 text_actual_width = llceil(text_available_width - remaining_pixels);  			S32 text_left = getLeftOffset(text_actual_width);  			LLRect line_rect(text_left,   							cur_top,  -							text_left + text_actual_width,  +							text_left + text_actual_width,  							cur_top - line_height);  			// if we didn't finish the current segment... @@ -3066,7 +3069,15 @@ boost::signals2::connection LLTextBase::setIsObjectBlockedCallback(const is_bloc  LLTextSegment::~LLTextSegment()  {} -bool LLTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const { width = 0; height = 0; return false;} +bool LLTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const { width = 0; height = 0; return false; } +bool LLTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const +{ +	F32 fwidth = 0; +	bool result = getDimensionsF32(first_char, num_chars, fwidth, height); +	width = ll_round(fwidth); +	return result; +} +  S32	LLTextSegment::getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const { return 0; }  S32	LLTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const { return 0; }  void LLTextSegment::updateLayout(const LLTextBase& editor) {} @@ -3314,7 +3325,7 @@ void LLNormalTextSegment::setToolTip(const std::string& tooltip)  	mTooltip = tooltip;  } -bool LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const +bool LLNormalTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const  {  	height = 0;  	width = 0; @@ -3323,7 +3334,7 @@ bool LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& widt  		height = mFontHeight;  		const LLWString &text = getWText();  		// if last character is a newline, then return true, forcing line break -		width = mStyle->getFont()->getWidth(text.c_str(), mStart + first_char, num_chars); +		width = mStyle->getFont()->getWidthF32(text.c_str(), mStart + first_char, num_chars);  	}  	return false;  } @@ -3491,7 +3502,7 @@ LLInlineViewSegment::~LLInlineViewSegment()  	mView->die();  } -bool LLInlineViewSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const +bool LLInlineViewSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const  {  	if (first_char == 0 && num_chars == 0)  	{ @@ -3578,7 +3589,7 @@ LLLineBreakTextSegment::LLLineBreakTextSegment(LLStyleConstSP style,S32 pos):LLT  LLLineBreakTextSegment::~LLLineBreakTextSegment()  {  } -bool LLLineBreakTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const +bool LLLineBreakTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const  {  	width = 0;  	height = mFontHeight; @@ -3607,7 +3618,7 @@ LLImageTextSegment::~LLImageTextSegment()  static const S32 IMAGE_HPAD = 3; -bool LLImageTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const +bool LLImageTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const  {  	width = 0;  	height = mStyle->getFont()->getLineHeight(); diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index c7b6203445..5fdde445ef 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -61,8 +61,9 @@ public:  		mEnd(end)  	{}  	virtual ~LLTextSegment(); +	bool						getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; -	virtual bool				getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; +	virtual bool				getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;  	virtual S32					getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const;  	/** @@ -126,7 +127,7 @@ public:  	LLNormalTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible = TRUE);  	virtual ~LLNormalTextSegment(); -	/*virtual*/ bool				getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; +	/*virtual*/ bool				getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;  	/*virtual*/ S32					getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const;  	/*virtual*/ S32					getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const;  	/*virtual*/ F32					draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect); @@ -212,7 +213,7 @@ public:  	LLInlineViewSegment(const Params& p, S32 start, S32 end);  	~LLInlineViewSegment(); -	/*virtual*/ bool		getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; +	/*virtual*/ bool		getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;  	/*virtual*/ S32			getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const;  	/*virtual*/ void		updateLayout(const class LLTextBase& editor);  	/*virtual*/ F32			draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect); @@ -236,7 +237,7 @@ public:  	LLLineBreakTextSegment(LLStyleConstSP style,S32 pos);  	LLLineBreakTextSegment(S32 pos);  	~LLLineBreakTextSegment(); -	bool		getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; +	/*virtual*/ bool		getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;  	S32			getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const;  	F32			draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect); @@ -249,7 +250,7 @@ class LLImageTextSegment : public LLTextSegment  public:  	LLImageTextSegment(LLStyleConstSP style,S32 pos,class LLTextBase& editor);  	~LLImageTextSegment(); -	bool		getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; +	/*virtual*/ bool		getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;  	S32			getNumChars(S32 num_pixels, S32 segment_offset, S32 char_offset, S32 max_chars, S32 line_ind) const;  	F32			draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect); diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp index 314b859cea..711a87dc99 100644 --- a/indra/newview/llexpandabletextbox.cpp +++ b/indra/newview/llexpandabletextbox.cpp @@ -44,7 +44,7 @@ public:  		mExpanderLabel(more_text)  	{} -	/*virtual*/ bool	getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const  +	/*virtual*/ bool	getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const   	{  		// more label always spans width of text box  		if (num_chars == 0) diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 9e09971ced..7d2d6e25c7 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -176,7 +176,7 @@ public:  		mToolTip = inv_item->getName() + '\n' + inv_item->getDescription();  	} -	/*virtual*/ bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const +	/*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const  	{  		if (num_chars == 0)  		{ @@ -185,7 +185,7 @@ public:  		}  		else  		{ -			width = EMBEDDED_ITEM_LABEL_PADDING + mImage->getWidth() + mStyle->getFont()->getWidth(mLabel.c_str()); +			width = EMBEDDED_ITEM_LABEL_PADDING + mImage->getWidth() + mStyle->getFont()->getWidthF32(mLabel.c_str());  			height = llmax(mImage->getHeight(), mStyle->getFont()->getLineHeight());  		}  		return false; | 
