Merge branch 'devel/master' into devel/new_mesh 13/42313/3
authorFrancisco Santos <f1.santos@samsung.com>
Thu, 25 Jun 2015 14:23:06 +0000 (15:23 +0100)
committerFrancisco Santos <f1.santos@samsung.com>
Fri, 26 Jun 2015 12:55:46 +0000 (13:55 +0100)
Conflicts:
automated-tests/src/dali-toolkit/CMakeLists.txt
dali-toolkit/devel-api/shader-effects/distance-field-effect.cpp
dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp
dali-toolkit/internal/atlas-manager/atlas-manager-impl.h
dali-toolkit/internal/atlas-manager/atlas-manager.cpp
dali-toolkit/internal/atlas-manager/atlas-manager.h
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.h
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/internal/text/decorator/text-decorator.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.h
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
dali-toolkit/public-api/controls/control-impl.cpp

Change-Id: I48b90c6c4696dbc7b65659ecf6004a09a17c7ab0

30 files changed:
1  2 
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/utc-Dali-BubbleEmitter.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
build/tizen/configure.ac
build/tizen/dali-toolkit/Makefile.am
dali-toolkit/devel-api/file.list
dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp
dali-toolkit/internal/atlas-manager/atlas-manager-impl.h
dali-toolkit/internal/atlas-manager/atlas-manager.cpp
dali-toolkit/internal/atlas-manager/atlas-manager.h
dali-toolkit/internal/builder/builder-animations.cpp
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp
dali-toolkit/internal/controls/slider/slider-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.h
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/internal/file.list
dali-toolkit/internal/text/decorator/text-decorator.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.h
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control-impl.h

@@@ -11,8 -11,14 +11,9 @@@ SET(TC_SOURCE
     utc-Dali-BloomView.cpp
     utc-Dali-BubbleEmitter.cpp
     utc-Dali-Builder.cpp
 -   utc-Dali-CarouselEffect.cpp
     utc-Dali-CheckBoxButton.cpp
     utc-Dali-CubeTransitionEffect.cpp
 -   utc-Dali-DisplacementEffect.cpp
 -   utc-Dali-DistanceFieldEffect.cpp
+    utc-Dali-EffectsView.cpp
     utc-Dali-GaussianBlurView.cpp
     utc-Dali-JsonParser.cpp
     utc-Dali-KeyInputFocusManager.cpp
@@@ -35,6 -48,9 +36,7 @@@
     utc-Dali-ItemLayout.cpp
     utc-Dali-ItemView.cpp
     utc-Dali-KeyboardFocusManager.cpp
 -   utc-Dali-MaskEffect.cpp
+    utc-Dali-Magnifier.cpp
     utc-Dali-NinePatchMaskEffect.cpp
     utc-Dali-Popup.cpp
     utc-Dali-PushButton.cpp
@@@ -213,28 -202,30 +213,33 @@@ int UtcDaliBubbleEmitterSetBubbleScale(
    ToolkitTestApplication application;
    tet_infoline( " UtcDaliBubbleEmitterSetBubbleScale " );
  
 -  Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
 -  BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
 -
 +  Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
 +  BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 150, Vector2( 5.f, 10.f ));
++  DALI_TEST_CHECK(emitter);
    Actor root = emitter.GetRootActor();
 -  MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
 -  ShaderEffect effect = bubbleMesh.GetShaderEffect();
 -  DALI_TEST_CHECK( effect );
 +  Stage::GetCurrent().Add( root );
++  root.SetPosition( Vector3::ZERO );
++  root.SetParentOrigin( ParentOrigin::CENTER );
++  root.SetAnchorPoint( AnchorPoint::CENTER );
 +
 +  TestGlAbstraction& gl = application.GetGlAbstraction();
 +
 +  Wait(application);
  
 -  Property::Index scalePropertyIndex = effect.GetPropertyIndex( "uDynamicScale" );
    float scaleValue;
 -  (effect.GetProperty(scalePropertyIndex)).Get( scaleValue );
 -  DALI_TEST_EQUALS(scaleValue, 1.f, TEST_LOCATION );
 +  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uDynamicScale", scaleValue ) );
 +  DALI_TEST_EQUALS( scaleValue, 1.f, TEST_LOCATION );
  
    emitter.SetBubbleScale( 2.f );
 -  application.SendNotification();
 -  application.Render();
 -  (effect.GetProperty(scalePropertyIndex)).Get( scaleValue );
 -  DALI_TEST_EQUALS(scaleValue, 2.f, TEST_LOCATION );
 +  Wait(application);
 +  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uDynamicScale", scaleValue ) );
 +  DALI_TEST_EQUALS( scaleValue, 2.f, TEST_LOCATION );
  
    emitter.SetBubbleScale( 0.5f );
 -  application.SendNotification();
 -  application.Render();
 -  (effect.GetProperty(scalePropertyIndex)).Get( scaleValue );
 -  DALI_TEST_EQUALS(scaleValue, 0.5f, TEST_LOCATION );
 +  Wait(application);
 +  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uDynamicScale", scaleValue ) );
 +  DALI_TEST_EQUALS( scaleValue, 0.5f, TEST_LOCATION );
++
    END_TEST;
  }
  
@@@ -284,32 -275,27 +289,36 @@@ int UtcDaliBubbleEmitterSetBlendMode(vo
    ToolkitTestApplication application;
    tet_infoline( " UtcDaliBubbleEmitterSetBlendMode " );
  
 -  Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
 -  BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
 -
 +  Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
 +  BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 150, Vector2( 5.f, 10.f ));
++  DALI_TEST_CHECK(emitter);
    Actor root = emitter.GetRootActor();
 -  MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
 -
 -  BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha;
 +  Stage::GetCurrent().Add( root );
++  root.SetPosition( Vector3::ZERO );
++  root.SetParentOrigin( ParentOrigin::CENTER );
++  root.SetAnchorPoint( AnchorPoint::CENTER );
 +
 +  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
 +  Wait(application);
 +  DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
 +  DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
 +  DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
 +  DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
  
    emitter.SetBlendMode( true );
 -  bubbleMesh.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
 -  DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::SRC_ALPHA );
 -  DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE );
 -  DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ZERO );
 -  DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE );
 +  Wait(application);
 +  DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
 +  DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
 +  DALI_TEST_EQUALS( (GLenum)GL_ZERO, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
 +  DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
  
    emitter.SetBlendMode( false );
 -  bubbleMesh.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
 -  DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::SRC_ALPHA );
 -  DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
 -  DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
 -  DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE_MINUS_SRC_ALPHA );
 +  Wait(application);
 +  DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
 +  DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
 +  DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
 +  DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
 +
    END_TEST;
  }
  
@@@ -356,36 -340,58 +365,39 @@@ int UtcDaliBubbleEmitterEmitBubble(void
    END_TEST;
  }
  
 -int UtcDaliBubbleEmitterStartExplosion(void)
 +int UtcDaliBubbleEmitterRestore(void)
  {
    ToolkitTestApplication application;
 -  tet_infoline( " UtcDaliBubbleEmitterStartExplosion " );
 +  tet_infoline( " UtcDaliBubbleEmitterRestore " );
  
 -  Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
 -  BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
 +  Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
 +  BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 90, Vector2( 5.f, 10.f ));
    Actor root = emitter.GetRootActor();
 -  MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
 -  ShaderEffect effect = bubbleMesh.GetShaderEffect();
 -  DALI_TEST_CHECK( effect );
 -
 -  Property::Index propertyIndex = effect.GetPropertyIndex( "uMagnification" );
 -  float value;
 -  (effect.GetProperty(propertyIndex)).Get( value );
 -  DALI_TEST_EQUALS(value, 1.f, TEST_LOCATION );
 -
 -  emitter.StartExplosion( 0.4, 4.f );
 +  Stage::GetCurrent().Add( root );
++  root.SetPosition( Vector3::ZERO );
++  root.SetParentOrigin( ParentOrigin::CENTER );
++  root.SetAnchorPoint( AnchorPoint::CENTER );
  
 -  Wait(application, 200); // 0.2s
 -  (effect.GetProperty(propertyIndex)).Get( value );
 -  DALI_TEST_CHECK( value >= 2.f );
 +  Actor bubbleMesh = root.GetChildAt( 0 );
 +  Renderer renderer = bubbleMesh.GetRendererAt( 0 );
 +  DALI_TEST_CHECK( renderer );
  
 -  Wait(application, 100); // 0.3s
 -  (effect.GetProperty(propertyIndex)).Get( value );
 -  DALI_TEST_CHECK( value >= 3.f );
 +  TestGlAbstraction& gl = application.GetGlAbstraction();
  
 -  Wait(application, 100); // 0.4s
 -  (effect.GetProperty(propertyIndex)).Get( value );
 -  DALI_TEST_EQUALS(value, 1.f, TEST_LOCATION );
 -  END_TEST;
 -}
 +  float percentageValue;
 +  Vector4 startEndPosValue;
  
 -int UtcDaliBubbleEmitterRestore(void)
 -{
 -  ToolkitTestApplication application;
 -  tet_infoline( " UtcDaliBubbleEmitterRestore " );
 +  Animation animation = Animation::New( 0.5f );
 +  emitter.EmitBubble( animation, Vector2(40.f,40.f), Vector2(-5.f,-5.f), Vector2(30.f,30.f) );
  
 -  Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
 -  BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
 -  Actor root = emitter.GetRootActor();
 -  MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
 -  ShaderEffect effect = bubbleMesh.GetShaderEffect();
 -  DALI_TEST_CHECK( effect );
 +  Wait(application);
  
 -  Property::Index percentagePropertyIndex = effect.GetPropertyIndex( "uPercentage[0]" );
 -  float percentage;
 +  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
 +  DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );
  
 -  Animation animation = Animation::New( 0.5f );
 -  emitter.EmitBubble( animation, Vector2(40.f,40.f), Vector2(-5.f,-5.f), Vector2(30.f,30.f) );
 -  (effect.GetProperty(percentagePropertyIndex)).Get( percentage );
 -  DALI_TEST_EQUALS(percentage, 0.f, TEST_LOCATION );
 +  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
 +  DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
 +  DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );
  
    animation.Play();
    Wait(application, 200);
    application.SendNotification();
    application.Render();
  
 -  (effect.GetProperty(percentagePropertyIndex)).Get( percentage );
 -  DALI_TEST_EQUALS(percentage, 1.f, TEST_LOCATION );
 +  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
 +  DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );
 +
 +  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
 +  DALI_TEST_EQUALS( startEndPosValue,  Vector4::ZERO, TEST_LOCATION );
++
    END_TEST;
  }
@@@ -18,6 -18,8 +18,7 @@@
  #include <iostream>
  #include <stdlib.h>
  #include <dali/integration-api/events/key-event-integ.h>
 -#include <dali/devel-api/actors/mesh-actor.h>
+ #include <dali/integration-api/events/tap-gesture-event.h>
  #include <dali-toolkit-test-suite-utils.h>
  #include <dali-toolkit/dali-toolkit.h>
  #include <dali-toolkit/devel-api/styling/style-manager.h>
Simple merge
Simple merge
Simple merge
@@@ -690,7 -651,8 +690,8 @@@ void AtlasManager::UploadImage( const B
  
  void AtlasManager::GenerateMeshData( ImageId id,
                                       const Vector2& position,
-                                      Toolkit::AtlasManager::Mesh2D& meshData )
 -                                     MeshData& meshData,
++                                     Toolkit::AtlasManager::Mesh2D& meshData,
+                                      bool addReference )
  {
    // Read the atlas Id to use for this image
    SizeType imageId = id - 1u;
@@@ -112,7 -111,8 +112,8 @@@ public
     */
    void GenerateMeshData( ImageId id,
                           const Vector2& position,
-                          Toolkit::AtlasManager::Mesh2D& mesh );
 -                         MeshData& mesh,
++                         Toolkit::AtlasManager::Mesh2D& mesh,
+                          bool addReference );
  
    /**
     * @copydoc Toolkit::AtlasManager::StitchMesh
@@@ -69,15 -69,17 +69,17 @@@ bool AtlasManager::Remove( ImageId id 
  
  void AtlasManager::GenerateMeshData( ImageId id,
                                       const Vector2& position,
-                                      Mesh2D& mesh )
 -                                     MeshData& meshData,
++                                     Mesh2D& mesh,
+                                      bool addReference )
  {
    GetImplementation(*this).GenerateMeshData( id,
                                               position,
-                                              mesh );
 -                                             meshData,
++                                             mesh,
+                                              addReference );
  }
  
 -void AtlasManager::StitchMesh( MeshData& first,
 -                               const MeshData& second,
 +void AtlasManager::StitchMesh( Mesh2D& first,
 +                               const Mesh2D& second,
                                 bool optimize )
  {
    GetImplementation(*this).StitchMesh( first, second, optimize );
@@@ -289,7 -278,8 +290,8 @@@ public
     */
    void GenerateMeshData( ImageId id,
                           const Vector2& position,
-                          Mesh2D& mesh );
 -                         MeshData& mesh,
++                         Mesh2D& mesh,
+                          bool addReference = true );
  
    /**
     * @brief Append second mesh to the first mesh
@@@ -917,40 -931,54 +932,58 @@@ void TextField::OnRelayout( const Vecto
        mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
      }
  
 -    RenderableActor renderableActor;
 -    if( mRenderer )
 -    {
 -      renderableActor = mRenderer->Render( mController->GetView() );
 -    }
 -
 +    RenderText();
      EnableClipping( (Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy), size );
 +  }
 +}
  
 -    if( renderableActor != mRenderableActor )
 -    {
 -      UnparentAndReset( mRenderableActor );
 -      mRenderableActor = renderableActor;
 -    }
 +void TextField::RenderText()
 +{
 +  Actor renderableActor;
 +  if( mRenderer )
 +  {
 +    renderableActor = mRenderer->Render( mController->GetView(), mDepth );
 +  }
  
 -    if( mRenderableActor )
 -    {
 -      const Vector2 offset = mController->GetScrollPosition() + mController->GetAlignmentOffset();
 +  if( renderableActor != mRenderableActor )
 +  {
 +    UnparentAndReset( mRenderableActor );
 +    mRenderableActor = renderableActor;
 +  }
  
 -      mRenderableActor.SetPosition( offset.x, offset.y );
 +  if( mRenderableActor )
 +  {
 +    const Vector2 offset = mController->GetScrollPosition() + mController->GetAlignmentOffset();
  
 -      // Make sure the actor is parented correctly with/without clipping
 -      if( mClipper )
 -      {
 -        mClipper->GetRootActor().Add( mRenderableActor );
 -      }
 -      else
 -      {
 -        Self().Add( mRenderableActor );
 -      }
 +    mRenderableActor.SetPosition( offset.x, offset.y );
 +
 +    // Make sure the actor is parented correctly with/without clipping
 +    if( mClipper )
 +    {
 +      mClipper->GetRootActor().Add( mRenderableActor );
 +    }
 +    else
 +    {
 +      Self().Add( mRenderableActor );
      }
+     for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
+            endIt = mClippingDecorationActors.end();
+          it != endIt;
+          ++it )
+     {
+       Actor actor = *it;
+       if( mClipper )
+       {
+         mClipper->GetRootActor().Add( actor );
+       }
+       else
+       {
+         Self().Add( actor );
+       }
+     }
+     mClippingDecorationActors.clear();
    }
  }
  
@@@ -223,8 -215,9 +228,9 @@@ private: // Dat
    Text::RendererPtr mRenderer;
    Text::DecoratorPtr mDecorator;
    Text::ClipperPtr mClipper; ///< For EXCEED_POLICY_CLIP
+   std::vector<Actor> mClippingDecorationActors;   ///< Decoration actors which need clipping.
  
 -  RenderableActor mRenderableActor;
 +  Actor mRenderableActor;
  
    int mRenderingBackend;
    int mExceedPolicy;
@@@ -510,9 -503,14 +524,14 @@@ void TextLabel::OnStageConnect( Dali::A
    }
  }
  
 -void TextLabel::RequestTextRelayout()
+ void TextLabel::AddDecoration( Actor& actor, bool needsClipping )
+ {
+   // TextLabel does not show decorations
+ }
 +void TextLabel::OnStageConnection( unsigned int depth )
  {
 -  RelayoutRequest();
 +  mDepth = depth;
  }
  
  void TextLabel::TextChanged()
@@@ -93,11 -93,11 +93,16 @@@ private: // From Contro
    virtual float GetHeightForWidth( float width );
  
    /**
+    * @copydoc Text::ControlInterface::AddDecoration()
+    */
+   virtual void AddDecoration( Actor& actor, bool needsClipping );
+   /**
 +   * @copydoc Control::OnStageConnection()
 +   */
 +  virtual void OnStageConnection( unsigned int depth );
 +
 +  /**
     * @copydoc Text::ControlInterface::RequestTextRelayout()
     */
    virtual void RequestTextRelayout();
@@@ -19,8 -19,7 +19,8 @@@
  #include <dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h>
  
  // INTERNAL INCLUDES
- #include <dali-toolkit/public-api/controls/buttons/push-button.h>
+ #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
 +#include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
  #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
  #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
  
@@@ -421,17 -575,17 +576,15 @@@ Dali::Image TextSelectionPopup::GetButt
     // 1. Create the backgrounds for the popup option both normal and pressed.
     // Both containers will be added to a button.
  
-    Toolkit::TableView optionContainer = Toolkit::TableView::New( (showIcons)?2:1 , 1 );
-    optionContainer.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-    optionContainer.SetMinimumSize( Vector2( OPTION_MIN_WIDTH, 0 ) );
+    Toolkit::TableView optionContainer = Toolkit::TableView::New( (showIcons&showCaption)?2:1 , 1 );
 -   optionContainer.SetDrawMode( DrawMode::OVERLAY );
+    optionContainer.SetFitHeight( 0 );
     optionContainer.SetFitWidth( 0 );
  
-    Toolkit::TableView  optionPressedContainer = Toolkit::TableView::New( (showIcons)?2:1 , 1 );
-    optionPressedContainer.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-    optionPressedContainer.SetMinimumSize( Vector2( OPTION_MIN_WIDTH, 0 ) );
+    Toolkit::TableView  optionPressedContainer = Toolkit::TableView::New( (showIcons&showCaption)?2:1 , 1 );
 -   optionPressedContainer.SetDrawMode( DrawMode::OVERLAY );
+    optionPressedContainer.SetFitHeight( 0 );
     optionPressedContainer.SetFitWidth( 0 );
+    optionPressedContainer.SetBackgroundColor( mPressedColor );
  #ifdef DECORATOR_DEBUG
     optionContainer.SetName("optionContainer");
     optionPressedContainer.SetName("optionPressedContainer");
  
     if ( showCaption )
     {
-    Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
-    captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
-    optionContainer.SetFitHeight( 0 );
-    Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
-    pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
-    optionPressedContainer.SetFitHeight( 0 );
-    captionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH );
-    captionTextLabel.SetMaximumSize( Vector2( OPTION_MAX_WIDTH - 2.f * OPTION_MARGIN_WIDTH , FLT_MAX ) ); //todo FLT_MAX Size negotiation feature needed
-    pressedCaptionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH );
-    pressedCaptionTextLabel.SetMaximumSize( Vector2( OPTION_MAX_WIDTH - 2.f * OPTION_MARGIN_WIDTH , FLT_MAX) ); //todo FLT_MAX Size negotiation feature needed
-    optionContainer.AddChild( captionTextLabel, Toolkit::TableView::CellPosition( 1, 0 )  ); // todo Labels need ellipsis or similar
-    optionPressedContainer.AddChild( pressedCaptionTextLabel, Toolkit::TableView::CellPosition( 1, 0 )  ); // todo Labels need ellipsis or similar
+      Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
+      captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
+      captionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+      Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
+      pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
+      pressedCaptionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+      Padding padding;
+      padding.left = 24.0f;
+      padding.right = 24.0f;
+      padding.top = 14.0f;
+      padding.bottom = 14.0f;
+      captionTextLabel.SetPadding( padding );
+      pressedCaptionTextLabel.SetPadding( padding );
+      optionContainer.AddChild( captionTextLabel, Toolkit::TableView::CellPosition(( showIcons&showCaption)?1:0, 0 )  );
+      optionPressedContainer.AddChild( pressedCaptionTextLabel, Toolkit::TableView::CellPosition(( showIcons&showCaption)?1:0, 0 ) );
     }
  
+    // 3. Create the icons
     if ( showIcons )
     {
-      // 3. Create the icons
       ImageActor pressedIcon = ImageActor::New(  iconImage );
       ImageActor icon = ImageActor::New(  iconImage );
-      icon.SetName("image-icon-2014");
 +     icon.SetSortModifier( DECORATION_DEPTH_INDEX - 1 );
 +     pressedIcon.SetSortModifier( DECORATION_DEPTH_INDEX - 1 );
       icon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
       pressedIcon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-      pressedIcon.SetColor( mIconPressedColor );
-      optionContainer.SetFitHeight( 0 );
-      optionPressedContainer.SetFitHeight( 0 );
+      icon.SetColor( mIconColor );
+      if ( showCaption & showIcons )
+      {
+        optionContainer.SetFitHeight( 1 );
+        optionContainer.SetFitWidth( 1 );
+        optionPressedContainer.SetFitHeight( 1 );
+        optionPressedContainer.SetFitWidth( 1 );
+      }
       optionContainer.AddChild( icon, Toolkit::TableView::CellPosition( 0, 0 )  );
       optionPressedContainer.AddChild( pressedIcon, Toolkit::TableView::CellPosition( 0, 0 )  );
       icon.SetPadding( Padding( 10.0f, 10.0f, 10.0f, 10.0f ) );
       pressedIcon.SetPadding( Padding( 10.0f, 10.0f, 10.0f, 10.0f ) );
     }
Simple merge
@@@ -627,12 -673,12 +677,13 @@@ struct Decorator::Impl : public Connect
        mHighlightMeshActor.SetName( "HighlightMeshActor" );
  #endif
        mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-       mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
  
-       Actor parent = mTextControlParent.Self();
-       parent.Add( mHighlightMeshActor );
+       // Add the highlight box telling the controller it needs clipping.
+       mController.AddDecoration( mHighlightMeshActor, true );
      }
+     mHighlightMeshActor.SetPosition( mHighlightPosition.x, mHighlightPosition.y, DISPLAYED_HIGHLIGHT_Z_OFFSET );
 +    */
    }
  
    void UpdateHighlight()
    Timer               mScrollTimer;               ///< Timer used to scroll the text when the grab handle is moved close to the edges.
  
    Layer               mActiveLayer;               ///< Layer for active handles and alike that ensures they are above all else.
 -  ImageActor          mPrimaryCursor;
 -  ImageActor          mSecondaryCursor;
 -  MeshActor           mHighlightMeshActor;        ///< Mesh Actor to display highlight
 +  //ImageActor          mPrimaryCursor;
 +  //ImageActor          mSecondaryCursor;
 +  //MeshActor           mHighlightMeshActor;        ///< Mesh Actor to display highlight
-   TextSelectionPopup  mCopyPastePopup;
+   PopupImpl           mCopyPastePopup;
+   TextSelectionPopup::Buttons mEnabledPopupButtons; /// Bit mask of currently enabled Popup buttons
+   TextSelectionPopupCallbackInterface& mTextSelectionPopupCallbackInterface;
  
    Image               mHandleImages[HANDLE_TYPE_COUNT][HANDLE_IMAGE_TYPE_COUNT];
    Image               mCursorImage;
@@@ -109,24 -65,64 +122,46 @@@ void AtlasGlyphManager::Add( Text::Font
                               const BufferImage& bitmap,
                               Dali::Toolkit::AtlasManager::AtlasSlot& slot )
  {
-   GlyphRecord record;
-   record.mFontId = glyph.fontId;
-   record.mIndex = glyph.index;
    mAtlasManager.Add( bitmap, slot );
+   GlyphRecordEntry record;
+   record.mIndex = glyph.index;
    record.mImageId = slot.mImageId;
-   mGlyphRecords.PushBack( record );
+   record.mCount = 1;
+   // Have glyph records been created for this fontId ?
+   bool foundGlyph = false;
+   for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
+         fontGlyphRecordIt != mFontGlyphRecords.end(); ++fontGlyphRecordIt )
+   {
+     if ( fontGlyphRecordIt->mFontId == fontId )
+     {
+       fontGlyphRecordIt->mGlyphRecords.PushBack( record );
+       foundGlyph = true;
+       break;
+     }
+   }
+   if ( !foundGlyph )
+   {
+     // We need to add a new font entry
+     FontGlyphRecord fontGlyphRecord;
+     fontGlyphRecord.mFontId = fontId;
+     fontGlyphRecord.mGlyphRecords.PushBack( record );
+     mFontGlyphRecords.push_back( fontGlyphRecord );
+   }
 -
 -#ifdef DISPLAY_ATLAS
 -  {
 -    uint32_t atlasCount = mAtlasManager.GetAtlasCount();
 -    if ( atlasCount > mCount )
 -    {
 -      for ( uint32_t i = 0; i < atlasCount; ++i )
 -      {
 -        ImageActor actor = ImageActor::New( mAtlasManager.GetAtlasContainer( i + 1u ) );
 -        actor.SetParentOrigin( Vector3( 0.5f, 0.25f + ( static_cast< float >( i ) * 0.25f ), 0.5f ) );
 -        actor.SetAnchorPoint( AnchorPoint::CENTER );
 -        actor.SetSize( 256.0f, 256.0f );
 -        Stage::GetCurrent().Add( actor );
 -      }
 -    }
 -    mCount = atlasCount;
 -  }
 -#endif
  }
  
  void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
                                            const Vector2& position,
 -                                          MeshData& meshData )
 +                                          Toolkit::AtlasManager::Mesh2D& mesh )
  {
-   mAtlasManager.GenerateMeshData( imageId, position, mesh );
+   // Generate mesh data and tell Atlas Manager not to handle reference counting ( we'll do it )
 -  mAtlasManager.GenerateMeshData( imageId, position, meshData, false );
++  mAtlasManager.GenerateMeshData( imageId, position, mesh, false );
  }
  
 -void AtlasGlyphManager::StitchMesh( MeshData& first,
 -                                    const MeshData& second )
 +void AtlasGlyphManager::StitchMesh( Toolkit::AtlasManager::Mesh2D& first,
 +                                    const Toolkit::AtlasManager::Mesh2D& second )
  {
    mAtlasManager.StitchMesh( first, second );
  }
@@@ -178,28 -209,6 +248,16 @@@ void AtlasGlyphManager::AdjustReference
    }
  }
  
- Pixel::Format AtlasGlyphManager::GetPixelFormat( uint32_t atlasId )
- {
-   return mAtlasManager.GetPixelFormat( atlasId );
- }
 +Material AtlasGlyphManager::GetMaterial( uint32_t atlasId ) const
 +{
 +  return mAtlasManager.GetMaterial( atlasId );
 +}
 +
 +Sampler AtlasGlyphManager::GetSampler( uint32_t atlasId ) const
 +{
 +  return mAtlasManager.GetSampler( atlasId );
 +}
 +
- const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
- {
-   mMetrics.mGlyphCount = mGlyphRecords.Size();
-   mAtlasManager.GetMetrics( mMetrics.mAtlasMetrics );
-   return mMetrics;
- }
  } // namespace Internal
  
  } // namespace Toolkit
@@@ -103,27 -110,12 +110,27 @@@ public
    void SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight );
  
    /**
-    * @copydoc Toolkit::AtlasGlyphManager::Remove
 -   * @copydoc toolkit::AtlasGlyphManager::GetPixelFormat
++   * @copydoc Toolkit::AtlasGlyphManager::GetPixelFormat
     */
-   void Remove( uint32_t imageId );
+   Pixel::Format GetPixelFormat( uint32_t atlasId );
  
    /**
-    * @copydoc Toolkit::AtlasGlyphManager::GetPixelFormat
 -   * @copydoc toolkit::AtlasGlyphManager::GetMetrics
++   * @copydoc toolkit::AtlasGlyphManager::AdjustReferenceCount
 +   */
-   Pixel::Format GetPixelFormat( uint32_t atlasId );
++  void AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta );
 +
 +  /**
 +   * @copydoc Toolkit::AtlasGlyphManager::GetMaterial
 +   */
 +  Material GetMaterial( uint32_t atlasId ) const;
 +
 +  /**
 +   * @copydoc Toolkit::AtlasGlyphManager::GetMaterial
 +   */
 +  Sampler GetSampler( uint32_t atlasId ) const;
 +
 +  /**
 +   * @copydoc Toolkit::AtlasGlyphManager::GetMetrics
     */
    const Toolkit::AtlasGlyphManager::Metrics& GetMetrics();
  
  
  private:
  
 -  Dali::Toolkit::AtlasManager mAtlasManager;
 +  Dali::Toolkit::AtlasManager mAtlasManager;          ///> Atlas Manager created by GlyphManager
-   Vector< GlyphRecord > mGlyphRecords;                ///> Cached glyph information
+   std::vector< FontGlyphRecord > mFontGlyphRecords;
 -  uint32_t mCount;
 -  Toolkit::AtlasGlyphManager::Metrics mMetrics;
 +  Toolkit::AtlasGlyphManager::Metrics mMetrics;       ///> Metrics to pass back on GlyphManager status
 +  Shader mEffectBufferShader;                         ///> Shader used to render drop shadow buffer textures
 +  Shader mShadowShader;                               ///> Shader used to render drop shadow into buffer
  };
  
  } // namespace Internal
@@@ -177,4 -157,4 +184,4 @@@ inline Internal::AtlasGlyphManager& Get
  } // namespace Dali
  
  
-- #endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H__
++ #endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H__
@@@ -133,16 -119,11 +129,21 @@@ const Toolkit::AtlasGlyphManager::Metri
    return GetImplementation(*this).GetMetrics();
  }
  
+ void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta )
+ {
+   GetImplementation(*this).AdjustReferenceCount( fontId, imageId, delta );
+ }
 +Shader AtlasGlyphManager::GetEffectBufferShader() const
 +{
 +  return GetImplementation(*this).GetEffectBufferShader();
 +}
 +
 +Shader AtlasGlyphManager::GetGlyphShadowShader() const
 +{
 +  return GetImplementation(*this).GetGlyphShadowShader();
 +}
 +
  } // namespace Toolkit
  
  } // namespace Dali
@@@ -171,19 -150,14 +168,28 @@@ public
    const Metrics& GetMetrics();
  
    /**
+    * @brief Adjust the reference count for an imageId and remove cache entry if it becomes free
+    *
+    * @param[in] fontId the font this image came from
+    * @param[in] imageId The imageId
+    * @param[in] delta adjustment to make to reference count
+    */
+   void AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta );
++  /**
 +   * @brief Get Shader used for rendering glyph effect buffers
 +   *
 +   * @return Handle of shader needed
 +   */
 +  Shader GetEffectBufferShader() const;
 +
 +  /**
 +   * @brief Get Shader used rendering Glyph Shadows
 +   *
 +   * @return Handle of shader needed
 +   */
 +  Shader GetGlyphShadowShader() const;
 +
  private:
  
    explicit DALI_INTERNAL AtlasGlyphManager(Internal::AtlasGlyphManager *impl);
@@@ -112,7 -125,7 +119,8 @@@ struct AtlasRenderer::Impl : public Con
      AtlasManager::AtlasSlot slot;
      std::vector< MeshRecord > meshContainer;
      Vector< Extent > extents;
+     TextCacheEntry textCacheEntry;
 +    mDepth = static_cast< int >( depth );
  
      float currentUnderlinePosition = ZERO;
      float currentUnderlineThickness = underlineHeight;
          }
  
          const Vector2& position = positions[ i ];
 -        MeshData newMeshData;
 +        AtlasManager::Mesh2D newMesh;
-         mGlyphManager.Cached( glyph.fontId, glyph.index, slot );
  
-         if ( slot.mImageId )
-         {
-           // This glyph already exists so generate mesh data plugging in our supplied position
-           mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
-           mImageIds.PushBack( slot.mImageId );
-         }
-         else
+         if ( !mGlyphManager.Cached( glyph.fontId, glyph.index, slot ) )
          {
            // Select correct size for new atlas if needed....?
            if ( lastFontId != glyph.fontId )
            {
              }
  
              // Locate a new slot for our glyph
-             mGlyphManager.Add( glyph, bitmap, slot );
-             // Generate mesh data for this quad, plugging in our supplied position
-             if ( slot.mImageId )
-             {
-               mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
-               mImageIds.PushBack( slot.mImageId );
-             }
+             mGlyphManager.Add( glyph.fontId, glyph, bitmap, slot );
            }
          }
 -        mGlyphManager.GenerateMeshData( slot.mImageId, position, newMeshData );
+         // Generate mesh data for this quad, plugging in our supplied position
++        mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
+         textCacheEntry.mFontId = glyph.fontId;
+         textCacheEntry.mImageId = slot.mImageId;
+         textCacheEntry.mIndex = glyph.index;
+         mTextCache.PushBack( textCacheEntry );
          // Find an existing mesh data object to attach to ( or create a new one, if we can't find one using the same atlas)
          StitchTextMesh( meshContainer,
 -                        newMeshData,
 +                        newMesh,
                          extents,
                          textColor,
                          position.y + glyph.yBearing,
      }
    }
  
 -  RenderableActor mActor;                             ///< The actor parent which renders the text
 +  Actor mActor;                                       ///< The actor parent which renders the text
    AtlasGlyphManager mGlyphManager;                    ///< Glyph Manager to handle upload and caching
-   Vector< uint32_t > mImageIds;                       ///< A list of imageIDs used by the renderer
    TextAbstraction::FontClient mFontClient;            ///> The font client used to supply glyph information
 -  ShaderEffect mBasicShader;                          ///> Shader used to render L8 glyphs
 -  ShaderEffect mBgraShader;                           ///> Shader used to render BGRA glyphs
 -  ShaderEffect mBasicShadowShader;                    ///> Shader used to render drop shadow into buffer
    std::vector< MaxBlockSize > mBlockSizes;            ///> Maximum size needed to contain a glyph in a block within a new atlas
 -  std::vector< MeshData::FaceIndex > mFace;           ///> Face indices for a quad
 +  std::vector< uint32_t > mFace;                      ///> Face indices for a quad
+   Vector< TextCacheEntry > mTextCache;
 +  Property::Map mQuadVertexFormat;
 +  Property::Map mQuadIndexFormat;
 +  int mDepth;
  };
  
  Text::RendererPtr AtlasRenderer::New()
@@@ -494,14 -412,13 +489,12 @@@ public
            Property::Map map;
  
            Background* back = controlImpl.mImpl->mBackground;
 -          if( back )
 +          if ( back && back->actor && back->actor.GetRendererAt(0).GetMaterial().GetNumberOfSamplers() > 0)
            {
 -            ImageActor imageActor = ImageActor::DownCast( back->actor );
 -            if ( imageActor )
 +            Image image = back->actor.GetRendererAt(0).GetMaterial().GetSamplerAt(0).GetImage();
 +            if ( image )
              {
-               Property::Map imageMap;
-               Scripting::CreatePropertyMap( image, imageMap );
-               map[ "image" ] = imageMap;
 -              Image image = imageActor.GetImage();
+               Scripting::CreatePropertyMap( image, map );
              }
            }