TextView - Fix for line justification when multiline policy is split by word and... 30/17230/1
authorVictor Cebollada <v.cebollada@samsung.com>
Tue, 4 Mar 2014 10:33:26 +0000 (10:33 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 5 Mar 2014 18:23:13 +0000 (18:23 +0000)
[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 <p.wisbey@samsung.com>
dali-toolkit/internal/controls/text-view/relayout-utilities.cpp
dali-toolkit/internal/controls/text-view/split-by-word-policies.cpp

index 56f20c6..93aa94e 100644 (file)
@@ -277,6 +277,7 @@ void CalculateSubLineLayout( const float parentWidth,
     {
       const TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordIt );
 
     {
       const TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordIt );
 
+      const float shrunkWordWidth = wordLayoutInfo.mSize.width * shrinkFactor;
       const bool isWhiteSpace = TextViewProcessor::WordSeparator == wordLayoutInfo.mType;
 
       bool splitByCharacter = false;
       const bool isWhiteSpace = TextViewProcessor::WordSeparator == wordLayoutInfo.mType;
 
       bool splitByCharacter = false;
@@ -296,19 +297,19 @@ void CalculateSubLineLayout( const float parentWidth,
         }
         case WrapByWordAndSplit:
         {
         }
         case WrapByWordAndSplit:
         {
-          splitByCharacter = ( wordLayoutInfo.mSize.width * shrinkFactor > parentWidth );
+          splitByCharacter = ( shrunkWordWidth > parentWidth );
           break;
         }
         case WrapByLineAndSplit:
         {
           if( ( 0 != characterIndex ) ||
           break;
         }
         case WrapByLineAndSplit:
         {
           if( ( 0 != characterIndex ) ||
-              ( ( 0 == characterIndex ) && ( lineOffset + wordLayoutInfo.mSize.width * shrinkFactor > parentWidth ) ) )
+              ( ( 0 == characterIndex ) && ( lineOffset + shrunkWordWidth > parentWidth ) ) )
           {
             splitByCharacter = true;
           }
           else
           {
           {
             splitByCharacter = true;
           }
           else
           {
-            lineOffset += wordLayoutInfo.mSize.width * shrinkFactor;
+            lineOffset += shrunkWordWidth;
             splitByCharacter = false;
           }
         }
             splitByCharacter = false;
           }
         }
@@ -339,7 +340,7 @@ void CalculateSubLineLayout( const float parentWidth,
       }
       else
       {
       }
       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 );
         if( !found || isFirstCharacter )
         {
           subLineInfo.mMaxCharHeight = std::max( subLineInfo.mMaxCharHeight, wordLayoutInfo.mSize.height );
index d6455a8..4b97f03 100644 (file)
@@ -249,6 +249,8 @@ void CalculatePositionsForShrinkWhenExceed( TextView::RelayoutData& relayoutData
   const float parentWidth = relayoutData.mTextViewSize.width;
   TextViewProcessor::TextLayoutInfo& textLayoutInfo = relayoutData.mTextLayoutInfo;
 
   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;
 
   // 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;
               ( 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;
 
             // 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 );
 
                                                       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;
 
 
             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 );
             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
           {
           }
           else
           {