Fixed GetHeightForWidth for text label 43/36143/12
authorPaul Wisbey <p.wisbey@samsung.com>
Mon, 2 Mar 2015 18:52:37 +0000 (18:52 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 4 Mar 2015 11:06:24 +0000 (11:06 +0000)
Change-Id: Ie91ab93ea2fa4fc11589baf867f468c5ceb44082

dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/public-api/text/layouts/layout-engine.cpp

index 03dcf44..080967e 100644 (file)
@@ -336,6 +336,16 @@ void TextField::OnInitialize()
   }
 }
 
+Vector3 TextField::GetNaturalSize()
+{
+  return mController->GetNaturalSize();
+}
+
+float TextField::GetHeightForWidth( float width )
+{
+  return mController->GetHeightForWidth( width );
+}
+
 void TextField::OnRelayout( const Vector2& size, ActorSizeContainer& container )
 {
   if( mController->Relayout( size ) )
index 7b013f5..b6b11b1 100644 (file)
@@ -79,6 +79,16 @@ private: // From Control
   virtual void OnInitialize();
 
   /**
+   * @copydoc Control::GetNaturalSize()
+   */
+  virtual Vector3 GetNaturalSize();
+
+  /**
+   * @copydoc Control::GetHeightForWidth()
+   */
+  virtual float GetHeightForWidth( float width );
+
+  /**
    * @copydoc Control::OnInitialize()
    */
   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
index ae65e17..e6a3a63 100644 (file)
@@ -102,6 +102,8 @@ struct LayoutEngine::Impl
       }
 
       visualModel.SetGlyphPositions( &glyphPositions[0], glyphCount );
+
+      visualModel.SetActualSize( Vector2(penX, fontMetrics.height) );
     }
   }
 
@@ -166,11 +168,12 @@ struct LayoutEngine::Impl
           }
           else if( endPenX > boundingBox.width )
           {
-            actualSize.width = ( actualSize.width < endPenX - glyph.advance ) ? endPenX - glyph.advance : actualSize.width;
             break;
           }
         }
 
+        actualSize.width = ( actualSize.width < endPenX ) ? endPenX : actualSize.width;
+
         // If end of text or no whitespace found
         if( glyphCount == j ||
             endIndex == i )