From: Victor Cebollada Date: Mon, 3 Mar 2014 14:58:40 +0000 (+0000) Subject: TextView - Fix for text view processor. Was not creating text-actors in some cases... X-Git-Tag: dali-2014-wk16-release~34 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=7d26cd90a3ff3ea2c9ae1d108e2218b42e9549b0 TextView - Fix for text view processor. Was not creating text-actors in some cases after a new-line character or if a line started by a white space. [Issue#] P140228-02847 [Problem] Some characters are not displayed or displayed in the line above. [Cause] Wrong logic. Some text-actors were not created. [Solution] Fix the logic. Change-Id: I0e25bbb7e676f0b7eec10a5dcba1224aab2f653d --- diff --git a/dali-toolkit/internal/controls/text-view/text-view-processor.cpp b/dali-toolkit/internal/controls/text-view/text-view-processor.cpp index b5800c8..e25f783 100644 --- a/dali-toolkit/internal/controls/text-view/text-view-processor.cpp +++ b/dali-toolkit/internal/controls/text-view/text-view-processor.cpp @@ -1071,6 +1071,7 @@ void InitializeTextActorInfo( TextView::RelayoutData& relayoutData ) std::size_t lineLayoutInfoIndex = 0; // Index to the laid out line info. const std::size_t lineLayoutInfoSize = relayoutData.mLines.size(); // Number or laid out lines. bool lineLayoutEnd = false; // Whether lineLayoutInfoIndex points at the last laid out line. + bool textActorCreatedForLine = false; TextActor currentTextActor; // text-actor used when the edit mode is disabled. TextStyle currentStyle; // style for the current text-actor. @@ -1104,40 +1105,41 @@ void InitializeTextActorInfo( TextView::RelayoutData& relayoutData ) { CharacterLayoutInfo& characterLayout( *characterIt ); + // Check if there is a new line. + const bool newLine = !lineLayoutEnd && ( characterGlobalIndex == relayoutData.mLines[lineLayoutInfoIndex].mCharacterGlobalIndex ); + + if( newLine ) + { + // Point to the next line. + ++lineLayoutInfoIndex; + if( lineLayoutInfoIndex >= lineLayoutInfoSize ) + { + // Arrived at last line. + lineLayoutEnd = true; // Avoids access out of bounds in the relayoutData.mLines vector. + } + textActorCreatedForLine = false; + } + if( !characterLayout.mStyledText.mText.IsEmpty() ) { // Do not create a text-actor if there is no text. - const std::size_t length = characterLayout.mStyledText.mText.GetLength(); - const Character character = characterLayout.mStyledText.mText[0]; + const Character character = characterLayout.mStyledText.mText[0]; // there are only one character per character layout. - if( ( 1 < length ) || - ( ( 1 == length ) && character.IsWhiteSpace() && characterLayout.mStyledText.mStyle.GetUnderline() ) || - ( ( 1 == length ) && !character.IsNewLine() && !character.IsWhiteSpace() ) ) + if( !character.IsWhiteSpace() || // A new line character is also a white space. + ( character.IsWhiteSpace() && characterLayout.mStyledText.mStyle.GetUnderline() ) ) { // Do not create a text-actor if it's a white space (without underline) or a new line character. // Creates one text-actor per each counsecutive group of characters, with the same style, per line. - // Check if there is a new line. - const bool newLine = !lineLayoutEnd && ( characterGlobalIndex == relayoutData.mLines[lineLayoutInfoIndex].mCharacterGlobalIndex ); - - if( ( characterLayout.mStyledText.mStyle != currentStyle ) || + if( !textActorCreatedForLine || + ( characterLayout.mStyledText.mStyle != currentStyle ) || ( characterLayout.mGradientColor != currentGradientColor ) || ( characterLayout.mStartPoint != currentStartPoint ) || - ( characterLayout.mEndPoint != currentEndPoint ) || - newLine ) + ( characterLayout.mEndPoint != currentEndPoint ) ) { // There is a new style or a new line. - if( newLine ) - { - // Point to the next line. - ++lineLayoutInfoIndex; - if( lineLayoutInfoIndex >= lineLayoutInfoSize ) - { - // Arrived at last line. - lineLayoutEnd = true; - } - } + textActorCreatedForLine = true; if( characterLayout.mTextActor ) {