Merge "Text Renderer - Fix the actor hierarchy." into devel/master
authorPaul Wisbey <p.wisbey@samsung.com>
Fri, 15 Jul 2016 14:47:29 +0000 (07:47 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 15 Jul 2016 14:47:30 +0000 (07:47 -0700)
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp

index 8e3e0cf..2300b50 100644 (file)
@@ -639,8 +639,13 @@ int utcDaliTextEditorEvent02(void)
   CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
   DALI_TEST_CHECK( camera );
 
-  Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u );
-  DALI_TEST_CHECK( renderer );
+  // The offscreen root actor has a container with all the actors which contain the text renderers.
+  Actor container = offscreenRoot.GetChildAt( 1u );
+  for( unsigned int index = 0; index < container.GetChildCount(); ++index )
+  {
+    Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
+    DALI_TEST_CHECK( renderer );
+  }
 
   // Move the cursor and check the position changes.
   Vector3 position1 = cursor.GetCurrentPosition();
@@ -762,8 +767,13 @@ int utcDaliTextEditorEvent03(void)
   CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
   DALI_TEST_CHECK( camera );
 
-  Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u );
-  DALI_TEST_CHECK( renderer );
+  // The offscreen root actor has a container with all the actors which contain the text renderers.
+  Actor container = offscreenRoot.GetChildAt( 1u );
+  for( unsigned int index = 0; index < container.GetChildCount(); ++index )
+  {
+    Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
+    DALI_TEST_CHECK( renderer );
+  }
 
   Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
   DALI_TEST_CHECK( highlight );
index a072343..911a06e 100644 (file)
@@ -867,8 +867,13 @@ int utcDaliTextFieldEvent02(void)
   CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
   DALI_TEST_CHECK( camera );
 
-  Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u );
-  DALI_TEST_CHECK( renderer );
+  // The offscreen root actor has a container with all the actors which contain the text renderers.
+  Actor container = offscreenRoot.GetChildAt( 1u );
+  for( unsigned int index = 0; index < container.GetChildCount(); ++index )
+  {
+    Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
+    DALI_TEST_CHECK( renderer );
+  }
 
   // Move the cursor and check the position changes.
   Vector3 position1 = cursor.GetCurrentPosition();
@@ -991,8 +996,13 @@ int utcDaliTextFieldEvent03(void)
   CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
   DALI_TEST_CHECK( camera );
 
-  Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u );
-  DALI_TEST_CHECK( renderer );
+  // The offscreen root actor has a container with all the actors which contain the text renderers.
+  Actor container = offscreenRoot.GetChildAt( 1u );
+  for( unsigned int index = 0; index < container.GetChildCount(); ++index )
+  {
+    Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
+    DALI_TEST_CHECK( renderer );
+  }
 
   Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
   DALI_TEST_CHECK( highlight );
index 437758c..5ba07ce 100644 (file)
@@ -176,7 +176,6 @@ struct AtlasRenderer::Impl
     TextCacheEntry textCacheEntry;
     mDepth = depth;
 
-    const Vector2& actorSize( view.GetControlSize() );
     const Vector2& textSize( view.GetLayoutSize() );
     const Vector2 halfTextSize( textSize * 0.5f );
     const Vector2& shadowOffset( view.GetShadowOffset() );
@@ -393,6 +392,15 @@ struct AtlasRenderer::Impl
     // For each MeshData object, create a mesh actor and add to the renderable actor
     if( !meshContainer.empty() )
     {
+      if( !mActor )
+      {
+        // Create a container actor to act as a common parent for text and shadow, to avoid color inheritence issues.
+        mActor = Actor::New();
+        mActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+        mActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+        mActor.SetSize( textSize );
+      }
+
       for( std::vector< MeshRecord >::iterator it = meshContainer.begin(),
               endIt = meshContainer.end();
             it != endIt; ++it )
@@ -401,8 +409,12 @@ struct AtlasRenderer::Impl
 
         Actor actor = CreateMeshActor( meshRecord, textSize );
 
+        // Whether the actor has renderers.
+        const bool hasRenderer = actor.GetRendererCount() > 0u;
+
         // Create an effect if necessary
-        if( style == STYLE_DROP_SHADOW )
+        if( hasRenderer &&
+            ( style == STYLE_DROP_SHADOW ) )
         {
           // Change the color of the vertices.
           for( Vector<AtlasManager::Vertex2D>::Iterator vIt =  meshRecord.mMesh.mVertices.Begin(),
@@ -415,39 +427,22 @@ struct AtlasRenderer::Impl
             vertex.mColor = shadowColor;
           }
 
-          // Create a container actor to act as a common parent for text and shadow, to avoid color inheritence issues.
-          Actor containerActor = Actor::New();
-          containerActor.SetParentOrigin( ParentOrigin::CENTER );
-          containerActor.SetSize( actorSize );
-
           Actor shadowActor = CreateMeshActor( meshRecord, textSize );
 #if defined(DEBUG_ENABLED)
           shadowActor.SetName( "Text Shadow renderable actor" );
 #endif
           // Offset shadow in x and y
           shadowActor.RegisterProperty("uOffset", shadowOffset );
-          if( actor.GetRendererCount() )
-          {
-            Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) );
-            int depthIndex = renderer.GetProperty<int>(Dali::Renderer::Property::DEPTH_INDEX);
-            renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 );
-            containerActor.Add( shadowActor );
-            containerActor.Add( actor );
-#if defined(DEBUG_ENABLED)
-            containerActor.SetName("TextContainer");
-#endif
-            actor = containerActor;
-          }
+          Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) );
+          int depthIndex = renderer.GetProperty<int>(Dali::Renderer::Property::DEPTH_INDEX);
+          renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 );
+          mActor.Add( shadowActor );
         }
 
-        if( mActor )
+        if( hasRenderer )
         {
           mActor.Add( actor );
         }
-        else
-        {
-          mActor = actor;
-        }
       }
     }
 #if defined(DEBUG_ENABLED)