Merge "Note that some Text propeties in devel api can't be changed" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / layouts / layout-engine.cpp
index 148ff58..12f20e4 100644 (file)
@@ -198,6 +198,7 @@ struct Engine::Impl
     LineLayout tmpLineLayout;
 
     const bool isMultiline = mLayout == MULTI_LINE_BOX;
+    const bool isWordLaidOut = parameters.lineWrapMode == Layout::LineWrap::WORD;
 
     // The last glyph to be laid-out.
     const GlyphIndex lastGlyphOfParagraphPlusOne = parameters.startGlyphIndex + parameters.numberOfGlyphs;
@@ -447,7 +448,7 @@ struct Engine::Impl
       if( isMultiline &&
           ( TextAbstraction::WORD_BREAK == wordBreakInfo ) )
       {
-        oneWordLaidOut = true;
+        oneWordLaidOut = isWordLaidOut;
         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "  One word laid-out\n" );
 
         // Current glyph is the last one of the current word.
@@ -1078,10 +1079,12 @@ struct Engine::Impl
               CharacterIndex startIndex,
               Length numberOfCharacters,
               HorizontalAlignment horizontalAlignment,
-              Vector<LineRun>& lines )
+              Vector<LineRun>& lines,
+              float& alignmentOffset )
   {
     const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
 
+    alignmentOffset = MAX_FLOAT;
     // Traverse all lines and align the glyphs.
     for( Vector<LineRun>::Iterator it = lines.Begin(), endIt = lines.End();
          it != endIt;
@@ -1106,6 +1109,9 @@ struct Engine::Impl
       CalculateHorizontalAlignment( size.width,
                                     horizontalAlignment,
                                     line );
+
+      // Updates the alignment offset.
+      alignmentOffset = std::min( alignmentOffset, line.alignmentOffset );
     }
   }
 
@@ -1267,13 +1273,15 @@ void Engine::Align( const Size& size,
                     CharacterIndex startIndex,
                     Length numberOfCharacters,
                     Layout::HorizontalAlignment horizontalAlignment,
-                    Vector<LineRun>& lines )
+                    Vector<LineRun>& lines,
+                    float& alignmentOffset )
 {
   mImpl->Align( size,
                 startIndex,
                 numberOfCharacters,
                 horizontalAlignment,
-                lines );
+                lines,
+                alignmentOffset );
 }
 
 void Engine::SetDefaultLineSpacing( float lineSpacing )