From: Paul Wisbey
Date: Thu, 24 Mar 2016 13:39:58 +0000 (-0700)
Subject: Merge "Fix for text renderer. Set the right size in order to cull the actor correctly...
X-Git-Tag: dali_1.1.28~6
X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=0f60c9d852e981b0a43a46763e074518af297cfe;hp=cb79ad02730f356835bcb061e1cc92d3bfe70c0d
Merge "Fix for text renderer. Set the right size in order to cull the actor correctly." into devel/master
---
diff --git a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
index f4692dc..7d17847 100644
--- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
+++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
@@ -176,7 +176,8 @@ struct AtlasRenderer::Impl
mDepth = depth;
const Vector2& actorSize( view.GetControlSize() );
- const Vector2 halfActorSize( actorSize * 0.5f );
+ const Vector2& textSize( view.GetActualSize() );
+ const Vector2 halfTextSize( textSize * 0.5f );
const Vector2& shadowOffset( view.GetShadowOffset() );
const Vector4& shadowColor( view.GetShadowColor() );
const bool underlineEnabled( view.IsUnderlineEnabled() );
@@ -323,7 +324,7 @@ struct AtlasRenderer::Impl
}
// Move the origin (0,0) of the mesh to the center of the actor
- const Vector2 position = *( positionsBuffer + i ) - halfActorSize;
+ const Vector2 position = *( positionsBuffer + i ) - halfTextSize;
// Generate mesh data for this quad, plugging in our supplied position
AtlasManager::Mesh2D newMesh;
@@ -395,7 +396,7 @@ struct AtlasRenderer::Impl
{
MeshRecord& meshRecord = *it;
- Actor actor = CreateMeshActor( meshRecord, actorSize );
+ Actor actor = CreateMeshActor( meshRecord, textSize );
// Create an effect if necessary
if( style == STYLE_DROP_SHADOW )
@@ -416,7 +417,7 @@ struct AtlasRenderer::Impl
containerActor.SetParentOrigin( ParentOrigin::CENTER );
containerActor.SetSize( actorSize );
- Actor shadowActor = CreateMeshActor( meshRecord, actorSize );
+ Actor shadowActor = CreateMeshActor( meshRecord, textSize );
#if defined(DEBUG_ENABLED)
shadowActor.SetName( "Text Shadow renderable actor" );
#endif
@@ -427,8 +428,6 @@ struct AtlasRenderer::Impl
Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) );
int depthIndex = renderer.GetProperty(Dali::Renderer::Property::DEPTH_INDEX);
renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 );
- shadowActor.SetParentOrigin( ParentOrigin::CENTER );
- shadowActor.SetSize( actorSize );
containerActor.Add( shadowActor );
containerActor.Add( actor );
actor = containerActor;
@@ -498,7 +497,11 @@ struct AtlasRenderer::Impl
actor.SetName( "Text renderable actor" );
#endif
actor.AddRenderer( renderer );
- actor.SetParentOrigin( ParentOrigin::CENTER ); // Keep all of the origins aligned
+
+ // Keep all of the origins aligned
+ actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
actor.SetSize( actorSize );
actor.RegisterProperty("uOffset", Vector2::ZERO );
return actor;
diff --git a/dali-toolkit/internal/text/text-view-interface.h b/dali-toolkit/internal/text/text-view-interface.h
index 409f9d7..5f4f1b5 100644
--- a/dali-toolkit/internal/text/text-view-interface.h
+++ b/dali-toolkit/internal/text/text-view-interface.h
@@ -65,6 +65,14 @@ public:
virtual const Vector2& GetControlSize() const = 0;
/**
+ * @brief Retrieves the text's actual size after it has been laid out.
+ *
+ * @return The text's size. Note that this may be larger than the control size,
+ * in the case where text is scrolling/clipped.
+ */
+ virtual const Vector2& GetActualSize() const = 0;
+
+ /**
* Retrieves the number of glyphs.
*
* @return The number of glyphs.
diff --git a/dali-toolkit/internal/text/text-view.cpp b/dali-toolkit/internal/text/text-view.cpp
index 2921700..caee1f8 100644
--- a/dali-toolkit/internal/text/text-view.cpp
+++ b/dali-toolkit/internal/text/text-view.cpp
@@ -65,6 +65,16 @@ const Vector2& View::GetControlSize() const
return Vector2::ZERO;
}
+const Vector2& View::GetActualSize() const
+{
+ if ( mImpl->mVisualModel )
+ {
+ return mImpl->mVisualModel->GetActualSize();
+ }
+
+ return Vector2::ZERO;
+}
+
Length View::GetNumberOfGlyphs() const
{
if( mImpl->mVisualModel )
diff --git a/dali-toolkit/internal/text/text-view.h b/dali-toolkit/internal/text/text-view.h
index 899474d..e58693c 100644
--- a/dali-toolkit/internal/text/text-view.h
+++ b/dali-toolkit/internal/text/text-view.h
@@ -61,6 +61,11 @@ public:
virtual const Vector2& GetControlSize() const;
/**
+ * @copydoc Dali::Toolkit::Text::ViewInterface::GetActualSize()
+ */
+ virtual const Vector2& GetActualSize() const;
+
+ /**
* @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfGlyphs()
*/
virtual Length GetNumberOfGlyphs() const;