TextView - Reduces the size of the character layout. 87/27587/1
authorVictor Cebollada <v.cebollada@samsung.com>
Tue, 16 Sep 2014 08:25:17 +0000 (09:25 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Tue, 16 Sep 2014 08:25:17 +0000 (09:25 +0100)
* Character's height and advance stores the same values than size -> height and advance removed.
* Character's gradient info stores a color (Vector4) two points (Vector2) and an alpha value (float)
  These parameters are only used for some text-actors when the text is faded-out.
  A new GradientInfo structure has been added and the character only stores a pointer to that struct,
  which is NULL if is not needed.

Change-Id: Iaa09a5a384ed43722fd703ff659459196019fff9
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor-Types.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp
base/dali-toolkit/internal/controls/text-view/relayout-utilities.cpp
base/dali-toolkit/internal/controls/text-view/text-view-character-processor.cpp
base/dali-toolkit/internal/controls/text-view/text-view-processor-types.h
base/dali-toolkit/internal/controls/text-view/text-view-word-processor.cpp

index f4b4948..7cb03fe 100644 (file)
@@ -59,21 +59,17 @@ int UtcDaliTextViewDefaultConstructorDestructor_PT(void)
   DALI_TEST_EQUALS( indices.mCharacterIndex, 0u, TEST_LOCATION );
 
   TextViewProcessor::CharacterLayoutInfo characterLayoutInfo;
-  DALI_TEST_EQUALS( characterLayoutInfo.mHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo.mAdvance, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_EQUALS( characterLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo.mBearing, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo.mOffset, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo.mUnderlineThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo.mUnderlinePosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_CHECK( !characterLayoutInfo.mGlyphActor );
   DALI_TEST_CHECK( characterLayoutInfo.mStyledText.mText.IsEmpty() );
   DALI_TEST_EQUALS( characterLayoutInfo.mColorAlpha, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo.mGradientColor, Vector4::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo.mStartPoint, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo.mEndPoint, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_CHECK( NULL == characterLayoutInfo.mGradientInfo );
   DALI_TEST_CHECK( characterLayoutInfo.mIsVisible );
   DALI_TEST_CHECK( characterLayoutInfo.mSetText );
   DALI_TEST_CHECK( characterLayoutInfo.mSetStyle );
@@ -111,12 +107,10 @@ int UtcDaliTextViewCopyConstructorOperator(void)
   tet_infoline("UtcDaliTextViewCopyConstructorOperator : ");
 
   TextViewProcessor::CharacterLayoutInfo characterLayoutInfo;
-  characterLayoutInfo.mHeight = 1.f;
-  characterLayoutInfo.mAdvance = 1.f;
+  characterLayoutInfo.mSize = Vector2( 1.f, 1.f );
   characterLayoutInfo.mBearing = 1.f;
   characterLayoutInfo.mPosition = Vector3( 1.f, 1.f, 1.f );
   characterLayoutInfo.mOffset = Vector2( 1.f, 1.f );
-  characterLayoutInfo.mSize = Vector2( 1.f, 1.f );
   characterLayoutInfo.mAscender = 1.f;
   characterLayoutInfo.mUnderlineThickness = 1.f;
   characterLayoutInfo.mUnderlinePosition = 1.f;
@@ -124,10 +118,14 @@ int UtcDaliTextViewCopyConstructorOperator(void)
   characterLayoutInfo.mGlyphActor = TextActor::New( "Hello" );
   characterLayoutInfo.mStyledText.mText = Text( "Hello" );
 
+  TextViewProcessor::GradientInfo* info = new TextViewProcessor::GradientInfo();
+  info->mGradientColor = Vector4( 1.f, 1.f, 1.f, 1.f );
+  info->mStartPoint = Vector2( 1.f, 1.f );
+  info->mEndPoint = Vector2( 1.f, 1.f );
+
   characterLayoutInfo.mColorAlpha = 0.f;
-  characterLayoutInfo.mGradientColor = Vector4( 1.f, 1.f, 1.f, 1.f );
-  characterLayoutInfo.mStartPoint = Vector2( 1.f, 1.f );
-  characterLayoutInfo.mEndPoint = Vector2( 1.f, 1.f );
+  characterLayoutInfo.mGradientInfo = info;
+
   characterLayoutInfo.mIsVisible = false;
   characterLayoutInfo.mSetText = false;
   characterLayoutInfo.mSetStyle = false;
@@ -135,8 +133,6 @@ int UtcDaliTextViewCopyConstructorOperator(void)
   TextViewProcessor::CharacterLayoutInfo characterLayoutInfo1;
   characterLayoutInfo1 = characterLayoutInfo;
 
-  DALI_TEST_EQUALS( characterLayoutInfo1.mHeight, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo1.mAdvance, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo1.mBearing, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo1.mPosition, Vector3( 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo1.mOffset, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
@@ -147,16 +143,14 @@ int UtcDaliTextViewCopyConstructorOperator(void)
   DALI_TEST_CHECK( characterLayoutInfo1.mGlyphActor );
   DALI_TEST_EQUALS( characterLayoutInfo1.mStyledText.mText.GetLength(), 5u, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo1.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo1.mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo1.mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo1.mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_CHECK( !characterLayoutInfo1.mIsVisible );
   DALI_TEST_CHECK( !characterLayoutInfo1.mSetText );
   DALI_TEST_CHECK( !characterLayoutInfo1.mSetStyle );
 
   TextViewProcessor::CharacterLayoutInfo characterLayoutInfo2( characterLayoutInfo );
-  DALI_TEST_EQUALS( characterLayoutInfo2.mHeight, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo2.mAdvance, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo2.mBearing, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo2.mPosition, Vector3( 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo2.mOffset, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
@@ -167,9 +161,9 @@ int UtcDaliTextViewCopyConstructorOperator(void)
   DALI_TEST_CHECK( characterLayoutInfo2.mGlyphActor );
   DALI_TEST_EQUALS( characterLayoutInfo2.mStyledText.mText.GetLength(), 5u, TEST_LOCATION );
   DALI_TEST_EQUALS( characterLayoutInfo2.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo2.mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo2.mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_EQUALS( characterLayoutInfo2.mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_CHECK( !characterLayoutInfo2.mIsVisible );
   DALI_TEST_CHECK( !characterLayoutInfo2.mSetText );
   DALI_TEST_CHECK( !characterLayoutInfo2.mSetStyle );
index e625f72..ee43cbd 100644 (file)
@@ -130,12 +130,11 @@ struct UpdateTextInfoTest
 
 void Print( const TextViewProcessor::CharacterLayoutInfo& character )
 {
-  std::cout << "             height : " << character.mHeight << std::endl;
-  std::cout << "            advance : " << character.mAdvance << std::endl;
+  std::cout << "             height : " << character.mSize.height << std::endl;
+  std::cout << "            advance : " << character.mSize.width << std::endl;
   std::cout << "            bearing : " << character.mBearing << std::endl;
-  std::cout << "          mPosition : " << character.mPosition << std::endl;
-  std::cout << "              mSize : " << character.mSize << std::endl;
-  std::cout << "          mAscender : " << character.mAscender << std::endl;
+  std::cout << "           ascender : " << character.mAscender << std::endl;
+  std::cout << "           position : " << character.mPosition << std::endl;
 
   TextActor textActor = TextActor::DownCast( character.mGlyphActor );
   if( textActor )
@@ -226,11 +225,11 @@ bool TestEqual( float x, float y )
 bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1,
                 const TextViewProcessor::CharacterLayoutInfo& character2 )
 {
-  if( !TestEqual( character1.mHeight, character2.mHeight ) )
+  if( !TestEqual( character1.mSize.height, character2.mSize.height ) )
   {
     return false;
   }
-  if( !TestEqual( character1.mAdvance, character2.mAdvance ) )
+  if( !TestEqual( character1.mSize.width, character2.mSize.width ) )
   {
     return false;
   }
@@ -248,15 +247,6 @@ bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1,
     return false;
   }
 
-  if( !TestEqual( character1.mSize.x, character2.mSize.x ) )
-  {
-    return false;
-  }
-  if( !TestEqual( character1.mSize.y, character2.mSize.y ) )
-  {
-    return false;
-  }
-
   if( !TestEqual( character1.mAscender, character2.mAscender ) )
   {
     return false;
@@ -1223,13 +1213,11 @@ int UtcDaliTextViewCreateTextInfo(void)
   //  bearing : 11.9492
   // ascender : 11.9492
 
-  const float WIDTH_10( 9.48351f );
   const float HEIGHT_10( 9.48351f );
   const float ADVANCE_10( 9.48351f );
   const float BEARING_10( 8.53516f );
   const float ASCENDER_10( 8.53516f );
 
-  const float WIDTH_12( 11.3802f );
   const float HEIGHT_12( 11.3802f );
   const float ADVANCE_12( 11.3802f );
   const float BEARING_12( 10.2422f );
@@ -1256,16 +1244,14 @@ int UtcDaliTextViewCreateTextInfo(void)
   // Characters
 
   TextViewProcessor::CharacterLayoutInfo layoutInfo10; // ( [lo wo])
-  layoutInfo10.mHeight = HEIGHT_10;
-  layoutInfo10.mAdvance = ADVANCE_10;
+  layoutInfo10.mSize.height = HEIGHT_10;
+  layoutInfo10.mSize.width = ADVANCE_10;
   layoutInfo10.mBearing = BEARING_10;
-  layoutInfo10.mSize = Size( WIDTH_10, HEIGHT_10 );
   layoutInfo10.mAscender = ASCENDER_10;
   TextViewProcessor::CharacterLayoutInfo layoutInfo12; // ( [Hel], [rld!] and [CR])
-  layoutInfo12.mHeight = HEIGHT_12;
-  layoutInfo12.mAdvance = ADVANCE_12;
+  layoutInfo12.mSize.height = HEIGHT_12;
+  layoutInfo12.mSize.width = ADVANCE_12;
   layoutInfo12.mBearing = BEARING_12;
-  layoutInfo12.mSize = Size( WIDTH_12, HEIGHT_12 );
   layoutInfo12.mAscender = ASCENDER_12;
 
   TextStyle style10;
@@ -1282,7 +1268,7 @@ int UtcDaliTextViewCreateTextInfo(void)
   TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4;
 
   // Hello
-  wordLayout1.mSize = Size( 3.f * WIDTH_12 + 2.f * WIDTH_10, HEIGHT_12 );
+  wordLayout1.mSize = Size( 3.f * ADVANCE_12 + 2.f * ADVANCE_10, HEIGHT_12 );
   wordLayout1.mAscender = ASCENDER_12;
   wordLayout1.mType = TextViewProcessor::NoSeparator;
 
@@ -1298,14 +1284,14 @@ int UtcDaliTextViewCreateTextInfo(void)
   wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
 
   // (white space)
-  wordLayout2.mSize = Size( WIDTH_10, HEIGHT_10 );
+  wordLayout2.mSize = Size( ADVANCE_10, HEIGHT_10 );
   wordLayout2.mAscender = ASCENDER_10;
   wordLayout2.mType = TextViewProcessor::WordSeparator;
   layoutInfo10.mStyledText.mText = Text( " " );
   wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space)
 
   // world!
-  wordLayout3.mSize = Size( 2.f * WIDTH_10 + 4.f * WIDTH_12, HEIGHT_12 );
+  wordLayout3.mSize = Size( 2.f * ADVANCE_10 + 4.f * ADVANCE_12, HEIGHT_12 );
   wordLayout3.mAscender = ASCENDER_12;
   wordLayout3.mType = TextViewProcessor::NoSeparator;
   layoutInfo10.mStyledText.mText = Text( "w" );
@@ -1333,7 +1319,7 @@ int UtcDaliTextViewCreateTextInfo(void)
 
   TextViewProcessor::ParagraphLayoutInfo paragraphLayout1, paragraphLayout2, paragraphLayout3;
 
-  paragraphLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
+  paragraphLayout1.mSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, HEIGHT_12 );
   paragraphLayout1.mAscender = ASCENDER_12;
   paragraphLayout1.mNumberOfCharacters = 13;
   paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
@@ -1351,8 +1337,8 @@ int UtcDaliTextViewCreateTextInfo(void)
   // Text (layout)
   TextViewProcessor::TextLayoutInfo textLayout;
 
-  textLayout.mWholeTextSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, 3.f * HEIGHT_12 );
-  textLayout.mMaxWordWidth = 2.f * WIDTH_10 + 4.f * WIDTH_12;
+  textLayout.mWholeTextSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, 3.f * HEIGHT_12 );
+  textLayout.mMaxWordWidth = 2.f * ADVANCE_10 + 4.f * ADVANCE_12;
   textLayout.mNumberOfCharacters = 14;
   textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout1 );
   textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout2 );
index 68a647e..fab32ca 100644 (file)
@@ -213,9 +213,7 @@ struct CurrentTextActorInfo
   Vector3 position;
   Size size;
   Vector4 color;
-  Vector4 gradientColor;
-  Vector2 startPoint;
-  Vector2 endPoint;
+  TextViewProcessor::GradientInfo* gradientInfo;
 };
 
 void SetVisualParameters( CurrentTextActorInfo& currentTextActorInfo,
@@ -224,9 +222,12 @@ void SetVisualParameters( CurrentTextActorInfo& currentTextActorInfo,
                           const float lineHeight )
 {
   currentTextActorInfo.textActor.SetTextColor( currentTextActorInfo.color );
-  currentTextActorInfo.textActor.SetGradientColor( currentTextActorInfo.gradientColor );
-  currentTextActorInfo.textActor.SetGradientStartPoint( currentTextActorInfo.startPoint );
-  currentTextActorInfo.textActor.SetGradientEndPoint( currentTextActorInfo.endPoint );
+  if( NULL != currentTextActorInfo.gradientInfo )
+  {
+    currentTextActorInfo.textActor.SetGradientColor( currentTextActorInfo.gradientInfo->mGradientColor );
+    currentTextActorInfo.textActor.SetGradientStartPoint( currentTextActorInfo.gradientInfo->mStartPoint );
+    currentTextActorInfo.textActor.SetGradientEndPoint( currentTextActorInfo.gradientInfo->mEndPoint );
+  }
 
   // The italics offset is used in the offscreen rendering. When text is in italics, it may exceed the text-view's boundary
   // due to the trick used to implement it.
@@ -570,7 +571,7 @@ void UpdateAlignment( const TextView::LayoutParameters& layoutParameters,
         characterTableInfo.mPosition.x = positionOffset.x + characterLayoutInfo.mOffset.x;
         characterTableInfo.mPosition.y = positionOffset.y + characterLayoutInfo.mOffset.y;
 
-        positionOffset.x += characterLayoutInfo.mAdvance * relayoutData.mShrinkFactor;
+        positionOffset.x += characterLayoutInfo.mSize.width * relayoutData.mShrinkFactor;
       } // end characters
     } // end words
   } // end paragraphs
@@ -641,8 +642,8 @@ void UpdateLayoutInfoTable( Vector4& minMaxXY,
 
   const float descender = characterLayoutInfo.mSize.height - characterLayoutInfo.mAscender;
 
-  const Toolkit::TextView::CharacterLayoutInfo characterLayoutTableInfo( Size( characterLayoutInfo.mAdvance * relayoutData.mShrinkFactor,
-                                                                               characterLayoutInfo.mHeight * relayoutData.mShrinkFactor ),
+  const Toolkit::TextView::CharacterLayoutInfo characterLayoutTableInfo( Size( characterLayoutInfo.mSize.width * relayoutData.mShrinkFactor,
+                                                                               characterLayoutInfo.mSize.height * relayoutData.mShrinkFactor ),
                                                                          positionOffset,
                                                                          ( TextViewProcessor::ParagraphSeparator == wordLayoutInfo.mType ),
                                                                          false, // VCC set the correct direction if needed.
@@ -651,7 +652,7 @@ void UpdateLayoutInfoTable( Vector4& minMaxXY,
 
   relayoutData.mCharacterLayoutInfoTable.push_back( characterLayoutTableInfo );
 
-  positionOffset.x += characterLayoutInfo.mAdvance * relayoutData.mShrinkFactor;
+  positionOffset.x += characterLayoutInfo.mSize.width * relayoutData.mShrinkFactor;
 }
 
 void CalculateVisibilityForFade( const Internal::TextView::LayoutParameters& layoutParameters,
@@ -812,6 +813,11 @@ void CalculateVisibilityForFade( const Internal::TextView::LayoutParameters& lay
     Vector2 startPoint = Vector2::ZERO;
     Vector2 endPoint = Vector2::ZERO;
 
+    if( NULL == characterLayoutInfo.mGradientInfo )
+    {
+      characterLayoutInfo.mGradientInfo = new TextViewProcessor::GradientInfo();
+    }
+
     if( !( rightFadeOut && leftFadeOut ) )
     {
       // Current implementation can't set gradient parameters for a text-actor exceeding at the same time the left and the right boundaries.
@@ -866,9 +872,9 @@ void CalculateVisibilityForFade( const Internal::TextView::LayoutParameters& lay
       }
     }
 
-    characterLayoutInfo.mGradientColor = gradientColor;
-    characterLayoutInfo.mStartPoint = startPoint;
-    characterLayoutInfo.mEndPoint = endPoint;
+    characterLayoutInfo.mGradientInfo->mGradientColor = gradientColor;
+    characterLayoutInfo.mGradientInfo->mStartPoint = startPoint;
+    characterLayoutInfo.mGradientInfo->mEndPoint = endPoint;
   }
   else
   {
@@ -1203,9 +1209,8 @@ void SetTextVisible( TextView::RelayoutData& relayoutData )
         TextViewProcessor::CharacterLayoutInfo& characterLayoutInfo( *characterLayoutIt );
 
         characterLayoutInfo.mIsVisible = true;
-        characterLayoutInfo.mGradientColor = Vector4::ZERO;
-        characterLayoutInfo.mStartPoint = Vector2::ZERO;
-        characterLayoutInfo.mEndPoint = Vector2::ZERO;
+        delete characterLayoutInfo.mGradientInfo;
+        characterLayoutInfo.mGradientInfo = NULL;
         characterLayoutInfo.mColorAlpha = characterLayoutInfo.mStyledText.mStyle.GetTextColor().a;
       } // end characters
     } // end words
@@ -1538,9 +1543,7 @@ void CreateTextActor( const TextView::VisualParameters& visualParameters,
   currentTextActorInfo.color = style.GetTextColor();
   currentTextActorInfo.color.a = characterLayout.mColorAlpha;
 
-  currentTextActorInfo.gradientColor = characterLayout.mGradientColor;
-  currentTextActorInfo.startPoint = characterLayout.mStartPoint;
-  currentTextActorInfo.endPoint = characterLayout.mEndPoint;
+  currentTextActorInfo.gradientInfo = characterLayout.mGradientInfo;
 
   TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
 
@@ -1599,9 +1602,9 @@ void UpdateTextActorInfoForParagraph( const TextView::VisualParameters& visualPa
 
   TextStyle currentStyle;                // style for the current text-actor.
 
-  Vector4 currentGradientColor;          // gradient color for the current text-actor.
-  Vector2 currentStartPoint;             // start point for the current text-actor.
-  Vector2 currentEndPoint;               // end point for the current text-actor.
+  TextViewProcessor::GradientInfo* currentGradientInfo = NULL; // gradient color for the current text-actor.
+                                                               // start point for the current text-actor.
+                                                               // end point for the current text-actor.
 
   bool currentIsColorGlyph = false;      // Whether current glyph is an emoticon.
 
@@ -1647,15 +1650,25 @@ void UpdateTextActorInfoForParagraph( const TextView::VisualParameters& visualPa
       {
         // Do not create a glyph-actor if it's a white space (without underline) or a new paragraph character.
 
-        // Creates one glyph-actor for each counsecutive group of characters, with the same style, per line, or if it's an emoticon.
+        // Check if the character has the same gradient info than the current one.
+        bool differentGradientInfo = false;
+        if( characterLayout.mGradientInfo && currentGradientInfo )
+        {
+          differentGradientInfo = ( characterLayout.mGradientInfo->mGradientColor != currentGradientInfo->mGradientColor ) ||
+            ( characterLayout.mGradientInfo->mStartPoint != currentGradientInfo->mStartPoint ) ||
+            ( characterLayout.mGradientInfo->mEndPoint != currentGradientInfo->mEndPoint );
+        }
+        else if( ( NULL != currentGradientInfo ) || ( NULL != characterLayout.mGradientInfo ) )
+        {
+          differentGradientInfo = true;
+        }
 
+        // Creates one glyph-actor for each counsecutive group of characters, with the same style, per line, or if it's an emoticon.
         if( !glyphActorCreatedForLine ||
             characterLayout.mIsColorGlyph ||
+            differentGradientInfo ||
             ( characterLayout.mIsColorGlyph != currentIsColorGlyph ) ||
-            ( style != currentStyle ) ||
-            ( characterLayout.mGradientColor != currentGradientColor ) ||
-            ( characterLayout.mStartPoint != currentStartPoint ) ||
-            ( characterLayout.mEndPoint != currentEndPoint ) )
+            ( style != currentStyle ) )
         {
           characterLayout.mSetText = false;
           characterLayout.mSetStyle = false;
@@ -1683,9 +1696,7 @@ void UpdateTextActorInfoForParagraph( const TextView::VisualParameters& visualPa
 
           // Update style to be checked with next characters.
           currentStyle = style;
-          currentGradientColor = characterLayout.mGradientColor;
-          currentStartPoint = characterLayout.mStartPoint;
-          currentEndPoint = characterLayout.mEndPoint;
+          currentGradientInfo = characterLayout.mGradientInfo;
           currentIsColorGlyph = characterLayout.mIsColorGlyph;
 
           characterLayout.mGlyphActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
@@ -1784,6 +1795,7 @@ void UpdateTextActorInfo( const TextView::VisualParameters& visualParameters,
                                      createGlyphActors );
   } // paragraphs
 
+  // Set visual parameters for ellipsis renderable actors.
   for( std::vector<RenderableActor>::iterator it = relayoutData.mEllipsizedGlyphActors.begin(),
          endIt = relayoutData.mEllipsizedGlyphActors.end();
        it != endIt;
index a9b3542..3373ab7 100644 (file)
@@ -34,22 +34,48 @@ namespace TextViewProcessor
 // Layout info.
 /////////////////////
 
+GradientInfo::GradientInfo()
+: mGradientColor(),
+  mStartPoint(),
+  mEndPoint()
+{
+}
+
+GradientInfo::~GradientInfo()
+{
+}
+
+GradientInfo::GradientInfo( const GradientInfo& info )
+: mGradientColor( info.mGradientColor ),
+  mStartPoint( info.mStartPoint ),
+  mEndPoint( info.mEndPoint )
+{
+}
+
+GradientInfo& GradientInfo::operator=( const GradientInfo& info )
+{
+  if( this != &info )
+  {
+    mGradientColor = info.mGradientColor;
+    mStartPoint = info.mStartPoint;
+    mEndPoint = info.mEndPoint;
+  }
+
+  return *this;
+}
+
 CharacterLayoutInfo::CharacterLayoutInfo()
-: mHeight( 0.f ),
-  mAdvance( 0.f ),
+: mSize(),
   mBearing( 0.f ),
-  mPosition(),
-  mOffset(),
-  mSize(),
   mAscender( 0.f ),
   mUnderlineThickness( 0.f ),
   mUnderlinePosition( 0.f ),
+  mPosition(),
+  mOffset(),
   mGlyphActor(),
   mStyledText(),
   mColorAlpha( 1.f ),
-  mGradientColor(),
-  mStartPoint(),
-  mEndPoint(),
+  mGradientInfo( NULL ),
   mIsVisible( true ),
   mSetText( true ),
   mSetStyle( true ),
@@ -59,24 +85,22 @@ CharacterLayoutInfo::CharacterLayoutInfo()
 
 CharacterLayoutInfo::~CharacterLayoutInfo()
 {
+  // Deletes the gradient info.
+  delete mGradientInfo;
 }
 
 CharacterLayoutInfo::CharacterLayoutInfo( const CharacterLayoutInfo& character )
-: mHeight( character.mHeight ),
-  mAdvance( character.mAdvance ),
+: mSize( character.mSize ),
   mBearing( character.mBearing ),
-  mPosition( character.mPosition ),
-  mOffset( character.mOffset ),
-  mSize( character.mSize ),
   mAscender( character.mAscender ),
   mUnderlineThickness( character.mUnderlineThickness ),
   mUnderlinePosition( character.mUnderlinePosition ),
+  mPosition( character.mPosition ),
+  mOffset( character.mOffset ),
   mGlyphActor( character.mGlyphActor ),
   mStyledText( character.mStyledText ),
   mColorAlpha( character.mColorAlpha ),
-  mGradientColor( character.mGradientColor ),
-  mStartPoint( character.mStartPoint ),
-  mEndPoint( character.mEndPoint ),
+  mGradientInfo( ( NULL == character.mGradientInfo ) ? NULL : new GradientInfo( *character.mGradientInfo ) ), // Copies the gradient info.
   mIsVisible( character.mIsVisible ),
   mSetText( character.mSetText ),
   mSetStyle( character.mSetStyle ),
@@ -86,29 +110,47 @@ CharacterLayoutInfo::CharacterLayoutInfo( const CharacterLayoutInfo& character )
 
 CharacterLayoutInfo& CharacterLayoutInfo::operator=( const CharacterLayoutInfo& character )
 {
-  mHeight = character.mHeight;
-  mAdvance = character.mAdvance;
-  mBearing = character.mBearing;
-
-  mPosition = character.mPosition;
-  mOffset = character.mOffset;
   mSize = character.mSize;
   mAscender = character.mAscender;
+  mBearing = character.mBearing;
   mUnderlineThickness = character.mUnderlineThickness;
   mUnderlinePosition = character.mUnderlinePosition;
 
+  mPosition = character.mPosition;
+  mOffset = character.mOffset;
+
+  mGlyphActor = character.mGlyphActor;
   mStyledText = character.mStyledText;
+
   mColorAlpha = character.mColorAlpha;
-  mGradientColor = character.mGradientColor;
-  mStartPoint = character.mStartPoint;
-  mEndPoint = character.mEndPoint;
+
+  // Copies the gradient info.
+  if( NULL == character.mGradientInfo )
+  {
+    // The source doesn't have. Deletes the current one.
+    delete mGradientInfo;
+    mGradientInfo = NULL;
+  }
+  else
+  {
+    // The source has gradient info.
+    if( NULL != mGradientInfo )
+    {
+      // It it has, copy to it.
+      *mGradientInfo = *character.mGradientInfo;
+    }
+    else
+    {
+      // If it doesn't have, create a new one.
+      mGradientInfo = new GradientInfo( *character.mGradientInfo );
+    }
+  }
+
   mIsVisible = character.mIsVisible;
   mSetText = character.mSetText;
   mSetStyle = character.mSetStyle;
   mIsColorGlyph = character.mIsColorGlyph;
 
-  mGlyphActor = character.mGlyphActor;
-
   return *this;
 }
 
index 71fd214..a4d1873 100644 (file)
@@ -87,6 +87,40 @@ struct TextInfoIndices
 };
 
 /**
+ * Stores gradient info.
+ *
+ * Used to fade in/out text-actors.
+ */
+struct GradientInfo
+{
+  /**
+   * Default constructor.
+   *
+   * Initializes all members to their default values.
+   */
+  GradientInfo();
+
+  /**
+   * Default destructor.
+   */
+  ~GradientInfo();
+
+  /**
+   * Copy constructor
+   */
+  GradientInfo( const GradientInfo& info );
+
+  /**
+   * Assignment operator.
+   */
+  GradientInfo& operator=( const GradientInfo& info );
+
+  Vector4                     mGradientColor;  ///< Gradient color.
+  Vector2                     mStartPoint;     ///< Gradient start point.
+  Vector2                     mEndPoint;       ///< Gradient end point.
+};
+
+/**
  * Layout information for a character.
  * It stores the position, size and ascender of its respective text-actor.
  */
@@ -116,30 +150,26 @@ struct CharacterLayoutInfo
    */
   CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
 
-  // Natural size (metrics) of the glyph.
-  float       mHeight;             ///< Natural height of the character.
-  float       mAdvance;            ///< Natural horizontal distance from origin of current character and the next one.
-  float       mBearing;            ///< Natural vertical distance from the baseline to the top of the glyph's bbox.
-
-  // Size of the text-actor (may be modified by a scale factor).
-  Vector3     mPosition;           ///< Position within the text-view
-  Vector2     mOffset;             ///< Alignment and justification offset.
-  Size        mSize;               ///< Size of this character.
+  // Metrics of the glyph.
+  Size        mSize;               ///< Height of the font and advance (the horizontal distance from the origin of the current character and the next one).
+  float       mBearing;            ///< Vertical distance from the baseline to the top of the glyph's boundary box.
   float       mAscender;           ///< Distance from the base line to the top of the line.
   float       mUnderlineThickness; ///< The underline's thickness.
   float       mUnderlinePosition;  ///< The underline's position.
 
-  RenderableActor             mGlyphActor;     ///< Handle to a text-actor.
-  MarkupProcessor::StyledText mStyledText;     ///< Stores the text and its style.
-  float                       mColorAlpha;     ///< Alpha component for the initial text color when text is faded.
-  Vector4                     mGradientColor;  ///< Gradient color.
-  Vector2                     mStartPoint;     ///< Gradient start point.
-  Vector2                     mEndPoint;       ///< Gradient end point.
+  // Position and alignment offset. It depends on the lay-out.
+  Vector3     mPosition;           ///< Position within the text-view
+  Vector2     mOffset;             ///< Alignment and justification offset.
+
+  RenderableActor             mGlyphActor;   ///< Handle to a text-actor.
+  MarkupProcessor::StyledText mStyledText;   ///< Stores the text and its style.
+  float                       mColorAlpha;   ///< Alpha component for the initial text color when text is faded.
+  GradientInfo*               mGradientInfo; ///< Stores gradient info.
 
-  bool                        mIsVisible:1;    ///< Whether the text-actor is visible.
-  bool                        mSetText:1;      ///< Whether a new text needs to be set in the text-actor.
-  bool                        mSetStyle:1;     ///< Whether a new style needs to be set in the text-actor.
-  bool                        mIsColorGlyph:1; ///< Whether this character is an emoticon.
+  bool            mIsVisible:1;    ///< Whether the text-actor is visible.
+  bool            mSetText:1;      ///< Whether a new text needs to be set in the text-actor.
+  bool            mSetStyle:1;     ///< Whether a new style needs to be set in the text-actor.
+  bool            mIsColorGlyph:1; ///< Whether this character is an emoticon.
 };
 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
 
@@ -194,7 +224,7 @@ struct ParagraphLayoutInfo
   /**
    * Default destructor.
    *
-   * Clears all words and deletes all text styles.
+   * Clears all words.
    */
   ~ParagraphLayoutInfo();
 
index 8925f36..b1426c9 100644 (file)
@@ -137,13 +137,19 @@ void CreateWordTextInfo( const MarkupProcessor::StyledTextArray& word,
         ChooseFontFamilyName( styledCharacter );
       }
 
+      // Gets the metrics of the font.
       const Font font = Font::New( FontParameters( styledCharacter.mStyle.GetFontName(), styledCharacter.mStyle.GetFontStyle(), styledCharacter.mStyle.GetFontPointSize() ) );
       const Font::Metrics metrics = font.GetMetrics( character );
       const float ascender = font.GetAscender();
 
-      // Fill Natural size info for current character.
-      characterLayoutInfo.mHeight = font.GetLineHeight();
-      characterLayoutInfo.mAdvance = metrics.GetAdvance();
+      // The font line's height is used as character's height.
+      characterLayoutInfo.mSize.height = font.GetLineHeight();
+
+      // The character's advance is used as charcter's width.
+      characterLayoutInfo.mSize.width = metrics.GetAdvance();
+
+      // The ascender and bearing are used to position correctly glyphs of different font sizes.
+      characterLayoutInfo.mAscender = ascender;
       characterLayoutInfo.mBearing = metrics.GetBearing();
 
       if( character.IsNewLine() && !characterLayoutInfo.mIsColorGlyph )
@@ -151,18 +157,13 @@ void CreateWordTextInfo( const MarkupProcessor::StyledTextArray& word,
         // A new paragraph character doesn't have any width.
         characterLayoutInfo.mSize.width = 0.f;
       }
-      else
-      {
-        // Uses advance as width.
-        characterLayoutInfo.mSize.width = characterLayoutInfo.mAdvance;
-      }
-      characterLayoutInfo.mSize.height = characterLayoutInfo.mHeight;
-      characterLayoutInfo.mAscender = ascender;
 
+      // Set's the underline thickness and position.
+      // Both thickness and position includes the vertical pad adjust used in effects like glow or shadow.
       if( styledCharacter.mStyle.IsUnderlineEnabled() )
       {
-        characterLayoutInfo.mUnderlineThickness = font.GetUnderlineThickness(); // Both thickness and position includes the
-        characterLayoutInfo.mUnderlinePosition = font.GetUnderlinePosition();   // vertical pad adjust used in effects like glow or shadow.
+        characterLayoutInfo.mUnderlineThickness = font.GetUnderlineThickness();
+        characterLayoutInfo.mUnderlinePosition = font.GetUnderlinePosition();
       }
 
       // stores the styled text.