Text Selection Popup Fade-in/Fade-out animation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / decorator / text-decorator.cpp
index ed67d72..380d97b 100644 (file)
@@ -384,18 +384,13 @@ struct Decorator::Impl : public ConnectionTracker
 
     if( mActiveCopyPastePopup )
     {
-      if( !mCopyPastePopup.actor.GetParent() )
-      {
-        mActiveLayer.Add( mCopyPastePopup.actor );
-      }
-
-      mCopyPastePopup.actor.RaiseAbove( mActiveLayer );
+      ShowPopup();
     }
     else
     {
       if( mCopyPastePopup.actor )
       {
-        mCopyPastePopup.actor.Unparent();
+        mCopyPastePopup.actor.HidePopup();
       }
     }
   }
@@ -411,6 +406,22 @@ struct Decorator::Impl : public ConnectionTracker
     DeterminePositionPopup();
   }
 
+  void ShowPopup()
+  {
+    if ( !mCopyPastePopup.actor )
+    {
+      return;
+    }
+
+    if( !mCopyPastePopup.actor.GetParent() )
+    {
+      mActiveLayer.Add( mCopyPastePopup.actor );
+    }
+
+    mCopyPastePopup.actor.RaiseAbove( mActiveLayer );
+    mCopyPastePopup.actor.ShowPopup();
+  }
+
   void DeterminePositionPopup()
   {
     if ( !mActiveCopyPastePopup )
@@ -445,7 +456,6 @@ struct Decorator::Impl : public ConnectionTracker
   void PopupRelayoutComplete( Actor actor )
   {
     // Size negotiation for CopyPastePopup complete so can get the size and constrain position within bounding box.
-    mCopyPastePopup.actor.OnRelayoutSignal().Disconnect( this, &Decorator::Impl::PopupRelayoutComplete  );
 
     DeterminePositionPopup();
   }
@@ -1498,20 +1508,17 @@ void Decorator::SetEnabledPopupButtons( TextSelectionPopup::Buttons& enabledButt
 {
    mImpl->mEnabledPopupButtons = enabledButtonsBitMask;
 
-   UnparentAndReset( mImpl->mCopyPastePopup.actor );
-   mImpl->mCopyPastePopup.actor = TextSelectionPopup::New( mImpl->mEnabledPopupButtons,
-                                                           &mImpl->mTextSelectionPopupCallbackInterface );
+   if ( !mImpl->mCopyPastePopup.actor )
+   {
+     mImpl->mCopyPastePopup.actor = TextSelectionPopup::New( &mImpl->mTextSelectionPopupCallbackInterface );
 #ifdef DECORATOR_DEBUG
-   mImpl->mCopyPastePopup.actor.SetName("mCopyPastePopup");
+     mImpl->mCopyPastePopup.actor.SetName("mCopyPastePopup");
 #endif
-   mImpl->mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
-   mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect( mImpl,  &Decorator::Impl::PopupRelayoutComplete  ); // Position popup after size negotiation
-
-   if( mImpl->mActiveLayer )
-   {
-     mImpl->mActiveLayer.Add( mImpl->mCopyPastePopup.actor );
-     mImpl->mCopyPastePopup.actor.ShowPopup();
+     mImpl->mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
+     mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect( mImpl,  &Decorator::Impl::PopupRelayoutComplete  ); // Position popup after size negotiation
    }
+
+   mImpl->mCopyPastePopup.actor.EnableButtons( mImpl->mEnabledPopupButtons );
 }
 
 TextSelectionPopup::Buttons& Decorator::GetEnabledPopupButtons()