From: Victor Cebollada Date: Tue, 4 Mar 2014 10:33:26 +0000 (+0000) Subject: TextView - Fix for line justification when multiline policy is split by word and... X-Git-Tag: dali-2014-wk16-release~31 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=978940db9ae0537402214626761e9b2b3f2b52c0 TextView - Fix for line justification when multiline policy is split by word and exceed policy is shrink to fit. [Issue#] N/A [Problem] Wrong line justification. [Cause] Shrink factor was not used. [Solution] Use shrink factor. Change-Id: Id7d6fd8a66a767115786f4ade540b91550c917ce Signed-off-by: Paul Wisbey --- diff --git a/dali-toolkit/internal/controls/text-view/relayout-utilities.cpp b/dali-toolkit/internal/controls/text-view/relayout-utilities.cpp index 56f20c6..93aa94e 100644 --- a/dali-toolkit/internal/controls/text-view/relayout-utilities.cpp +++ b/dali-toolkit/internal/controls/text-view/relayout-utilities.cpp @@ -277,6 +277,7 @@ void CalculateSubLineLayout( const float parentWidth, { const TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordIt ); + const float shrunkWordWidth = wordLayoutInfo.mSize.width * shrinkFactor; const bool isWhiteSpace = TextViewProcessor::WordSeparator == wordLayoutInfo.mType; bool splitByCharacter = false; @@ -296,19 +297,19 @@ void CalculateSubLineLayout( const float parentWidth, } case WrapByWordAndSplit: { - splitByCharacter = ( wordLayoutInfo.mSize.width * shrinkFactor > parentWidth ); + splitByCharacter = ( shrunkWordWidth > parentWidth ); break; } case WrapByLineAndSplit: { if( ( 0 != characterIndex ) || - ( ( 0 == characterIndex ) && ( lineOffset + wordLayoutInfo.mSize.width * shrinkFactor > parentWidth ) ) ) + ( ( 0 == characterIndex ) && ( lineOffset + shrunkWordWidth > parentWidth ) ) ) { splitByCharacter = true; } else { - lineOffset += wordLayoutInfo.mSize.width * shrinkFactor; + lineOffset += shrunkWordWidth; splitByCharacter = false; } } @@ -339,7 +340,7 @@ void CalculateSubLineLayout( const float parentWidth, } else { - CalculateLineLength( isWhiteSpace, wordLayoutInfo.mSize.width * shrinkFactor, parentWidth, found, subLineInfo.mLineLength, endWhiteSpaceLength ); + CalculateLineLength( isWhiteSpace, shrunkWordWidth, parentWidth, found, subLineInfo.mLineLength, endWhiteSpaceLength ); if( !found || isFirstCharacter ) { subLineInfo.mMaxCharHeight = std::max( subLineInfo.mMaxCharHeight, wordLayoutInfo.mSize.height ); diff --git a/dali-toolkit/internal/controls/text-view/split-by-word-policies.cpp b/dali-toolkit/internal/controls/text-view/split-by-word-policies.cpp index d6455a8..4b97f03 100644 --- a/dali-toolkit/internal/controls/text-view/split-by-word-policies.cpp +++ b/dali-toolkit/internal/controls/text-view/split-by-word-policies.cpp @@ -249,6 +249,8 @@ void CalculatePositionsForShrinkWhenExceed( TextView::RelayoutData& relayoutData const float parentWidth = relayoutData.mTextViewSize.width; TextViewProcessor::TextLayoutInfo& textLayoutInfo = relayoutData.mTextLayoutInfo; + relayoutData.mLineJustificationInfo.clear(); + // Reset the text height. This value is returned in order to shrink further or not the text. newTextHeight = 0.f; @@ -324,23 +326,20 @@ void CalculatePositionsForShrinkWhenExceed( TextView::RelayoutData& relayoutData ( isFirstCharOfWord && ( wordOffset + wordLayoutInfo.mSize.width * shrinkFactor > parentWidth ) ) ) { isFirstChar = false; - const float minWidth = std::min( parentWidth, textLayoutInfo.mWholeTextSize.width ); // Calculates the line length and the max character height for the current line. TextViewRelayout::SubLineLayoutInfo subLineInfo; subLineInfo.mLineLength = 0.f; subLineInfo.mMaxCharHeight = 0.f; subLineInfo.mMaxAscender = 0.f; - TextViewRelayout::CalculateSubLineLayout( minWidth, + TextViewRelayout::CalculateSubLineLayout( parentWidth, indices, lineLayoutInfo, TextViewRelayout::WrapByWord, shrinkFactor, subLineInfo ); - float justificationOffset = TextViewRelayout::CalculateJustificationOffset( layoutParameters.mLineJustification, minWidth, subLineInfo.mLineLength ); - - characterLayoutInfo.mPosition = Vector3( justificationOffset, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset * shrinkFactor, 0.f ); + characterLayoutInfo.mPosition = Vector3( 0.f, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset * shrinkFactor, 0.f ); newTextHeight += subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset * shrinkFactor; @@ -349,6 +348,15 @@ void CalculatePositionsForShrinkWhenExceed( TextView::RelayoutData& relayoutData lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of line. lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of line. relayoutData.mLines.push_back( lineInfo ); + + + // Stores some info to calculate the line justification in a post-process. + TextView::LineJustificationInfo justificationInfo; + + justificationInfo.mIndices = indices; + justificationInfo.mLineLength = subLineInfo.mLineLength; + + relayoutData.mLineJustificationInfo.push_back( justificationInfo ); } else {