Merge "GetLineOfGlyph() and GetLineOfCharacter() methods added to the visual model...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller.cpp
index 219d8e5..0796311 100644 (file)
@@ -359,7 +359,7 @@ struct Controller::TextInput
 
       // TODO - multi-line selection
       const Vector<LineRun>& lines = mVisualModel->mLines;
-      float height = lines.Count() ? lines[0].lineSize.height : 0.0f;
+      float height = lines.Count() ? lines[0].ascender + -lines[0].descender : 0.0f;
 
       mDecorator->SetPosition( PRIMARY_SELECTION_HANDLE,   primaryX,   0.0f, height );
       mDecorator->SetPosition( SECONDARY_SELECTION_HANDLE, secondaryX, 0.0f, height );
@@ -438,7 +438,8 @@ struct Controller::TextInput
     const Vector<LineRun>& lines = mVisualModel->mLines;
     for( float totalHeight = 0; lineIndex < lines.Count(); ++lineIndex )
     {
-      totalHeight += lines[lineIndex].lineSize.height;
+      const LineRun& lineRun = lines[lineIndex];
+      totalHeight += lineRun.ascender + -lineRun.descender;
       if( y < totalHeight )
       {
         return lineIndex;
@@ -515,7 +516,7 @@ struct Controller::TextInput
     }
     visualY = 0.0f;
 
-    height = line.lineSize.height;
+    height = line.ascender + -line.descender;
   }
 
   void UpdateCursorPosition()
@@ -559,7 +560,8 @@ struct Controller::TextInput
         lastGlyph = (lineRuns[lineIndex].glyphIndex + lineRuns[lineIndex].numberOfGlyphs);
         if( cursorGlyph < lastGlyph )
         {
-          height = lineRuns[lineIndex].lineSize.height;
+          const LineRun& lineRun = lineRuns[lineIndex];
+          height = lineRun.ascender + -lineRun.descender;
           break;
         }
       }
@@ -651,9 +653,11 @@ struct Controller::Impl
 
     mView.SetVisualModel( mVisualModel );
 
-    // Set the shadow properties to default
+    // Set the text properties to default
+    mVisualModel->SetTextColor( Color::WHITE );
     mVisualModel->SetShadowOffset( Vector2::ZERO );
     mVisualModel->SetShadowColor( Vector4::ZERO );
+    mVisualModel->SetUnderlineEnabled( false );
   }
 
   ~Impl()
@@ -849,6 +853,11 @@ void Controller::GetDefaultFonts( Vector<FontRun>& fonts, Length numberOfCharact
   }
 }
 
+const Vector4& Controller::GetTextColor() const
+{
+  return mImpl->mVisualModel->GetTextColor();
+}
+
 const Vector2& Controller::GetShadowOffset() const
 {
   return mImpl->mVisualModel->GetShadowOffset();
@@ -859,6 +868,21 @@ const Vector4& Controller::GetShadowColor() const
   return mImpl->mVisualModel->GetShadowColor();
 }
 
+const Vector4& Controller::GetUnderlineColor() const
+{
+  return mImpl->mVisualModel->GetUnderlineColor();
+}
+
+bool Controller::IsUnderlineEnabled() const
+{
+  return mImpl->mVisualModel->IsUnderlineEnabled();
+}
+
+void Controller::SetTextColor( const Vector4& textColor )
+{
+  mImpl->mVisualModel->SetTextColor( textColor );
+}
+
 void Controller::SetShadowOffset( const Vector2& shadowOffset )
 {
   mImpl->mVisualModel->SetShadowOffset( shadowOffset );
@@ -869,6 +893,16 @@ void Controller::SetShadowColor( const Vector4& shadowColor )
   mImpl->mVisualModel->SetShadowColor( shadowColor );
 }
 
+void Controller::SetUnderlineColor( const Vector4& color )
+{
+  mImpl->mVisualModel->SetUnderlineColor( color );
+}
+
+void Controller::SetUnderlineEnabled( bool enabled )
+{
+  mImpl->mVisualModel->SetUnderlineEnabled( enabled );
+}
+
 void Controller::EnableTextInput( DecoratorPtr decorator )
 {
   if( !mImpl->mTextInput )