Refactor TextLabel to use text visual
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / visual-model-impl.cpp
index 138ce54..1b114c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ VisualModelPtr VisualModel::New()
 }
 
 void VisualModel::CreateCharacterToGlyphTable( CharacterIndex startIndex,
+                                               GlyphIndex startGlyphIndex,
                                                Length numberOfCharacters )
 {
   if( 0u == numberOfCharacters )
@@ -72,7 +73,6 @@ void VisualModel::CreateCharacterToGlyphTable( CharacterIndex startIndex,
   // 2) Traverse the glyphs and set the glyph indices per character.
 
   // Index to the glyph.
-  const GlyphIndex startGlyphIndex = updateCurrentBuffer ? *( mCharactersToGlyph.Begin() + startIndex ) : 0u;
   GlyphIndex glyphIndex = startGlyphIndex;
   CharacterIndex characterIndex = startIndex;
   const CharacterIndex lastCharacterIndexPlusOne = startIndex + numberOfCharacters;
@@ -115,6 +115,7 @@ void VisualModel::CreateCharacterToGlyphTable( CharacterIndex startIndex,
 }
 
 void VisualModel::CreateGlyphsPerCharacterTable( CharacterIndex startIndex,
+                                                 GlyphIndex startGlyphIndex,
                                                  Length numberOfCharacters )
 {
   if( 0u == numberOfCharacters )
@@ -146,14 +147,12 @@ void VisualModel::CreateGlyphsPerCharacterTable( CharacterIndex startIndex,
 
   // 2) Traverse the glyphs and set the number of glyphs per character.
 
-  // The glyph index.
-  const GlyphIndex glyphIndex = updateCurrentBuffer  ? *( mCharactersToGlyph.Begin() + startIndex ) : 0u;
   Length traversedCharacters = 0;
 
   // The number of 'characters per glyph' equal to zero.
   Length zeroCharactersPerGlyph = 0u;
 
-  for( Vector<Length>::ConstIterator it = mCharactersPerGlyph.Begin() + glyphIndex,
+  for( Vector<Length>::ConstIterator it = mCharactersPerGlyph.Begin() + startGlyphIndex,
          endIt = mCharactersPerGlyph.End();
        ( it != endIt ) && ( traversedCharacters < numberOfCharacters );
        ++it )
@@ -391,6 +390,11 @@ float VisualModel::GetUnderlineHeight() const
   return mUnderlineHeight;
 }
 
+Length VisualModel::GetNumberOfUnderlineRuns() const
+{
+  return mUnderlineRuns.Count();
+}
+
 void VisualModel::ClearCaches()
 {
   mCachedLineIndex = 0u;
@@ -411,7 +415,8 @@ VisualModel::VisualModel()
   mTextColor( Color::BLACK ),
   mShadowColor( Color::BLACK ),
   mUnderlineColor( Color::BLACK ),
-  mShadowOffset( Vector2::ZERO ),
+  mControlSize(),
+  mShadowOffset(),
   mUnderlineHeight( 0.0f ),
   mNaturalSize(),
   mLayoutSize(),