Fixes for text related actors after new size negotiation. 49/37649/3
authorVictor Cebollada <v.cebollada@samsung.com>
Wed, 1 Apr 2015 15:07:14 +0000 (16:07 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Thu, 2 Apr 2015 10:20:28 +0000 (11:20 +0100)
Change-Id: I25a3d08a02cbff1a96be5951630bc5e054b24295
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/internal/text/clipping/text-clipper.cpp
dali-toolkit/internal/text/decorator/text-decorator.cpp
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
dali-toolkit/public-api/controls/default-controls/solid-color-actor.cpp

index 133fa09..6f3f565 100644 (file)
@@ -438,23 +438,26 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
    // 1. Create the backgrounds for the popup option both normal and pressed.
    // Both containers will be added to a button.
    Actor optionContainer = Actor::New();
+   optionContainer.SetRelayoutEnabled( true );
+   optionContainer.SetResizePolicy( FIXED, ALL_DIMENSIONS );
    optionContainer.SetDrawMode( DrawMode::OVERLAY );
-   //optionContainer.SetParentOrigin( ParentOrigin::CENTER );
    optionContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
 
    ImageActor optionPressedContainer = Toolkit::CreateSolidColorActor( mBackgroundPressedColor );
+   optionPressedContainer.SetResizePolicy( FIXED, ALL_DIMENSIONS );
    optionPressedContainer.SetDrawMode( DrawMode::OVERLAY );
-   //optionPressedContainer.SetParentOrigin( ParentOrigin::CENTER );
    optionPressedContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
 
    // 2. Add text.
    Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
+   captionTextLabel.SetResizePolicy( FIXED, ALL_DIMENSIONS );
    captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
-   optionContainer.Add( captionTextLabel );
+   // optionContainer.Add( captionTextLabel ); Temporary removed.
 
    Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
+   pressedCaptionTextLabel.SetResizePolicy( FIXED, ALL_DIMENSIONS );
    pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
-   optionPressedContainer.Add( pressedCaptionTextLabel );
+   // optionPressedContainer.Add( pressedCaptionTextLabel ); Temporary removed.
 
    // Calculates the icon/text position.
    float iconTextOffsetY = 0.0f;
@@ -500,8 +503,8 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
    textSize.width = std::min( textSize.width, OPTION_MAX_WIDTH - 2.f * OPTION_MARGIN_WIDTH );
 
    // Set the size to the text. Text will be ellipsized if exceeds the max width.
-   captionTextLabel.SetSize( textSize );
-   pressedCaptionTextLabel.SetSize( textSize );
+   captionTextLabel.SetPreferredSize( textSize.GetVectorXY() );
+   pressedCaptionTextLabel.SetPreferredSize( textSize.GetVectorXY() );
 
    // 4. Calculate the size of option.
 
@@ -510,13 +513,13 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
    const Vector2 optionSize( std::min( OPTION_MAX_WIDTH, std::max( OPTION_MIN_WIDTH, std::max( textSize.width, OPTION_ICON_SIZE.width ) + 2.f * OPTION_MARGIN_WIDTH ) ),
                              DEFAULT_POPUP_MAX_SIZE.height - mNinePatchMargins.z - mNinePatchMargins.w );
 
-   optionContainer.SetSize( optionSize );
-   optionPressedContainer.SetSize( optionSize );
+   optionContainer.SetPreferredSize( optionSize );
+   optionPressedContainer.SetPreferredSize( optionSize );
 
    // 5. Create a option.
    Toolkit::PushButton option = Toolkit::PushButton::New();
-   //option.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed ); FIXME
-   option.SetSize( optionSize );
+   option.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+   option.SetPreferredSize( optionSize );
    option.SetAnchorPoint( AnchorPoint::TOP_LEFT );
    option.SetX( mContentSize.width );
    option.SetName( name );
@@ -541,7 +544,8 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
      const Size size( POPUP_DIVIDER_WIDTH, mContentSize.height );
 
      ImageActor divider =  Toolkit::CreateSolidColorActor( Color::WHITE );
-     divider.SetSize (size);
+     divider.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+     divider.SetPreferredSize( size );
      divider.SetParentOrigin( ParentOrigin::TOP_LEFT );
      divider.SetAnchorPoint( AnchorPoint::TOP_LEFT );
      divider.SetPosition( mContentSize.width - POPUP_DIVIDER_WIDTH, 0.0f );
@@ -559,14 +563,17 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
    stencil.SetDrawMode( DrawMode::STENCIL );
    stencil.SetVisible( true );
    Actor scrollview = Actor::New(); //todo make a scrollview
+   stencil.SetRelayoutEnabled( true );
 
-   //todo Use Size negotiation
-   //self.SetSize( size ); // control matches stencil size
-   self.SetSize( mRequiredPopUpSize ); // control matches stencil size
-   mStencilLayer.SetSize( size ); // matches stencil size
-   stencil.SetSize( size );
-   scrollview.SetSize( size );
-   mButtons.SetSize( size );
+   self.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+   self.SetPreferredSize( mRequiredPopUpSize ); // control matches stencil size
+
+   mStencilLayer.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+   mStencilLayer.SetPreferredSize( size ); // matches stencil size
+
+   stencil.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+   scrollview.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+   mButtons.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 
    mStencilLayer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
    scrollview.SetAnchorPoint(AnchorPoint::TOP_LEFT);
@@ -587,6 +594,7 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
    mContentSize = Vector2::ZERO;
 
    mButtons = Actor::New();
+   mButtons.SetRelayoutEnabled( true );
 
    // Add the options into the buttons container.
 
index 92dbaa4..7a79e4c 100644 (file)
@@ -78,8 +78,8 @@ void Clipper::Refresh( const Vector2& size )
     FrameBufferImage frameBufferImage = FrameBufferImage::New( offscreenSize.width,
                                                                offscreenSize.height,
                                                                Pixel::RGBA8888 );
-    mImageActor.SetPreferredSize( offscreenSize );
-    mImageActor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+
+    mImageActor.SetSize( offscreenSize );
     mImageActor.SetImage( frameBufferImage );
     mRenderTask.SetTargetFrameBuffer( frameBufferImage );
 
@@ -97,20 +97,20 @@ void Clipper::Initialize( const Vector2& size )
 
   // Create a root actor and an image actor for offscreen rendering.
   mOffscreenRootActor = Layer::New();
+  mOffscreenRootActor.SetRelayoutEnabled( false );
   mOffscreenRootActor.SetColorMode( USE_OWN_COLOR );
   mOffscreenRootActor.SetPositionInheritanceMode( DONT_INHERIT_POSITION );
   mOffscreenRootActor.SetInheritScale( false );
   mOffscreenRootActor.SetDepthTestDisabled( true );
-  mOffscreenRootActor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
-  mOffscreenRootActor.SetPreferredSize( offscreenSize );
+  mOffscreenRootActor.SetSize( offscreenSize );
 
   mImageActor = ImageActor::New();
+  mImageActor.SetRelayoutEnabled( false );
   mImageActor.SetParentOrigin( ParentOrigin::CENTER );
   mImageActor.SetBlendFunc( BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA,
                             BlendingFactor::ONE, BlendingFactor::ONE );
   mImageActor.SetScale( Vector3( 1.0f, -1.0f, 1.0f ) );
-  mImageActor.SetPreferredSize( offscreenSize );
-  mImageActor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+  mImageActor.SetSize( offscreenSize );
 
   // Creates a new camera actor.
   mOffscreenCameraActor = CameraActor::New();
index 551c961..97aa0c8 100644 (file)
@@ -182,15 +182,13 @@ struct Decorator::Impl : public ConnectionTracker
     {
       mPrimaryCursor.SetPosition( mCursor[PRIMARY_CURSOR].x + scrollPosition.x,
                                   mCursor[PRIMARY_CURSOR].y + scrollPosition.y );
-      mPrimaryCursor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
-      mPrimaryCursor.SetPreferredSize( Vector2( 1.0f, mCursor[PRIMARY_CURSOR].height ) );
+      mPrimaryCursor.SetSize( Vector2( 1.0f, mCursor[PRIMARY_CURSOR].height ) );
     }
     if( mSecondaryCursor )
     {
       mSecondaryCursor.SetPosition( mCursor[SECONDARY_CURSOR].x + scrollPosition.x,
                                     mCursor[SECONDARY_CURSOR].y + scrollPosition.y );
-      mSecondaryCursor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
-      mSecondaryCursor.SetPreferredSize( Vector2( 1.0f, mCursor[SECONDARY_CURSOR].height ) );
+      mSecondaryCursor.SetSize( Vector2( 1.0f, mCursor[SECONDARY_CURSOR].height ) );
     }
 
     // Show or hide the grab handle
@@ -254,8 +252,9 @@ struct Decorator::Impl : public ConnectionTracker
   void CreateCursor( ImageActor& cursor )
   {
     cursor = CreateSolidColorActor( Color::WHITE );
-    cursor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+    cursor.SetParentOrigin( ParentOrigin::TOP_LEFT ); // Need to set the default parent origin as CreateSolidColorActor() sets a different one.
     cursor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+    cursor.SetRelayoutEnabled( false );
   }
 
   // Add or Remove cursor(s) from parent
@@ -339,8 +338,7 @@ struct Decorator::Impl : public ConnectionTracker
       mActiveLayer.SetName ( "ActiveLayerActor" );
 #endif
 
-      mActiveLayer.SetAnchorPoint( AnchorPoint::CENTER);
-      mActiveLayer.SetParentOrigin( ParentOrigin::CENTER);
+      mActiveLayer.SetParentOrigin( ParentOrigin::CENTER );
       mActiveLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
       mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
 
@@ -363,20 +361,19 @@ struct Decorator::Impl : public ConnectionTracker
 #ifdef DECORATOR_DEBUG
       mGrabHandle.SetName( "GrabHandleActor" );
 #endif
-      mGrabHandle.SetParentOrigin( ParentOrigin::TOP_LEFT );
       mGrabHandle.SetAnchorPoint( AnchorPoint::TOP_CENTER );
       mGrabHandle.SetDrawMode( DrawMode::OVERLAY );
       // Area that Grab handle responds to, larger than actual handle so easier to move
-//#ifdef DECORATOR_DEBUG
-//      mGrabArea = Toolkit::CreateSolidColorActor( Vector4(0.0f, 0.0f, 0.0f, 0.0f), true, Color::RED, 1 );
-//      mGrabArea.SetName( "GrabArea" );
-//#else
-      mGrabArea = Actor::New();  //todo Force use of Actor until SolidColorActor fixed in Size Negotiation
+#ifdef DECORATOR_DEBUG
+     mGrabArea = Toolkit::CreateSolidColorActor( Vector4(0.0f, 0.0f, 0.0f, 0.0f), true, Color::RED, 1 );
+     mGrabArea.SetName( "GrabArea" );
+#else
+      mGrabArea = Actor::New();
       mGrabArea.SetRelayoutEnabled( true );
-//#endif
+#endif
       mGrabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
-      mGrabArea.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
       mGrabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+      mGrabArea.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
       mGrabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
       mGrabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE );
       mGrabHandle.Add( mGrabArea );
@@ -402,12 +399,12 @@ struct Decorator::Impl : public ConnectionTracker
 #ifdef DECORATOR_DEBUG
       primary.actor.SetName("SelectionHandleOne");
 #endif
-      primary.actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
       primary.actor.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); // Change to BOTTOM_RIGHT if Look'n'Feel requires handle above text.
       primary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
       primary.flipped = false;
 
       primary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
+      primary.grabArea.SetRelayoutEnabled( true );
 #ifdef DECORATOR_DEBUG
       primary.grabArea.SetName("SelectionHandleOneGrabArea");
 #endif
@@ -435,12 +432,12 @@ struct Decorator::Impl : public ConnectionTracker
 #ifdef DECORATOR_DEBUG
       secondary.actor.SetName("SelectionHandleTwo");
 #endif
-      secondary.actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
       secondary.actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // Change to BOTTOM_LEFT if Look'n'Feel requires handle above text.
       secondary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
       secondary.flipped = false;
 
       secondary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
+      secondary.grabArea.SetRelayoutEnabled( true );
 #ifdef DECORATOR_DEBUG
       secondary.grabArea.SetName("SelectionHandleTwoGrabArea");
 #endif
@@ -475,7 +472,6 @@ struct Decorator::Impl : public ConnectionTracker
 #ifdef DECORATOR_DEBUG
       mHighlightMeshActor.SetName( "HighlightMeshActor" );
 #endif
-      mHighlightMeshActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
       mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
       mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
 
index a5ea934..63deea2 100644 (file)
@@ -161,7 +161,6 @@ struct AtlasRenderer::Impl : public ConnectionTracker
       for ( uint32_t i = 0; i < meshContainer.size(); ++i )
       {
         MeshActor actor = MeshActor::New( Mesh::New( meshContainer[ i ].mMeshData ) );
-        actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
         actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
 
         // Check to see what pixel format the shader should be
@@ -362,7 +361,6 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     meshData.SetHasColor( false );
     meshData.SetHasTextureCoords( true );
     MeshActor actor = MeshActor::New( Mesh::New( meshData ) );
-    actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
     actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
     actor.SetShaderEffect( mBgraShader );
     actor.SetFilterMode( FilterMode::LINEAR, FilterMode::LINEAR );
@@ -399,7 +397,6 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     newMeshData.SetHasTextureCoords( true );
 
     MeshActor subActor = MeshActor::New( Mesh::New( newMeshData ) );
-    subActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
     subActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
     subActor.SetColor( shadowColor );
     subActor.SetShaderEffect( mBasicShadowShader );
@@ -485,4 +482,4 @@ AtlasRenderer::AtlasRenderer()
 AtlasRenderer::~AtlasRenderer()
 {
   delete mImpl;
-}
\ No newline at end of file
+}
index 1474151..5a6ae0e 100644 (file)
@@ -83,7 +83,6 @@ ImageActor CreateSolidColorActor( const Vector4& color, bool border, const Vecto
 
   imageData.Update();
   image = ImageActor::New( imageData );
-  image.SetAnchorPoint( AnchorPoint::CENTER );
   image.SetParentOrigin( ParentOrigin::CENTER );
 
   if( border )