Add text selection popup style
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / decorator / text-decorator.cpp
index d005d94..543c232 100644 (file)
@@ -746,12 +746,15 @@ struct Decorator::Impl : public ConnectionTracker
       {
         layer.SetProperty(Actor::Property::NAME, "ActiveLayerActor");
       }
+      else if(type == DecorationType::CURSOR_LAYER)
+      {
+        layer.SetProperty(Actor::Property::NAME, "CursorLayerActor");
+      }
 #endif
       bool needsClipping = false;
       if(type == DecorationType::CURSOR_LAYER)
       {
         needsClipping = true;
-        layer.SetProperty(Actor::Property::NAME, "CursorLayerActor");
       }
 
       layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
@@ -943,6 +946,19 @@ struct Decorator::Impl : public ConnectionTracker
     }
   }
 
+  void CreateSelectionPopup()
+  {
+    if(!mCopyPastePopup.actor)
+    {
+      mCopyPastePopup.actor = TextSelectionPopup::New(&mTextSelectionPopupCallbackInterface);
+  #ifdef DECORATOR_DEBUG
+      mCopyPastePopup.actor.SetProperty(Dali::Actor::Property::NAME, "mCopyPastePopup");
+  #endif
+      mCopyPastePopup.actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+      mCopyPastePopup.actor.OnRelayoutSignal().Connect(this, &Decorator::Impl::SetPopupPosition); // Position popup after size negotiation
+    }
+  }
+
   void CalculateHandleWorldCoordinates(HandleImpl& handle, Vector2& position)
   {
     // Gets the world position of the active layer. The active layer is where the handles are added.
@@ -2106,6 +2122,27 @@ int Decorator::GetCursorWidth() const
 void Decorator::SetEditable(bool editable)
 {
   mImpl->mHidePrimaryCursorAndGrabHandle = !editable;
+  // If editable is false, all decorators should be disabled.
+  if(!editable)
+  {
+    if(IsHighlightActive())
+    {
+      SetHighlightActive(false);
+    }
+    if(IsHandleActive(LEFT_SELECTION_HANDLE))
+    {
+      SetHandleActive(LEFT_SELECTION_HANDLE, false);
+    }
+    if(IsHandleActive(RIGHT_SELECTION_HANDLE))
+    {
+      SetHandleActive(RIGHT_SELECTION_HANDLE, false);
+    }
+    if(IsPopupActive())
+    {
+      SetPopupActive(false);
+    }
+  }
+
   mImpl->Relayout(mImpl->mControlSize);
 }
 /** Handles **/
@@ -2278,17 +2315,7 @@ bool Decorator::IsPopupActive() const
 void Decorator::SetEnabledPopupButtons(TextSelectionPopup::Buttons& enabledButtonsBitMask)
 {
   mImpl->mEnabledPopupButtons = enabledButtonsBitMask;
-
-  if(!mImpl->mCopyPastePopup.actor)
-  {
-    mImpl->mCopyPastePopup.actor = TextSelectionPopup::New(&mImpl->mTextSelectionPopupCallbackInterface);
-#ifdef DECORATOR_DEBUG
-    mImpl->mCopyPastePopup.actor.SetProperty(Dali::Actor::Property::NAME, "mCopyPastePopup");
-#endif
-    mImpl->mCopyPastePopup.actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
-    mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect(mImpl, &Decorator::Impl::SetPopupPosition); // Position popup after size negotiation
-  }
-
+  mImpl->CreateSelectionPopup();
   mImpl->mCopyPastePopup.actor.EnableButtons(mImpl->mEnabledPopupButtons);
 }
 
@@ -2297,6 +2324,20 @@ TextSelectionPopup::Buttons& Decorator::GetEnabledPopupButtons()
   return mImpl->mEnabledPopupButtons;
 }
 
+void Decorator::SetSelectionPopupStyle(const Property::Map& options)
+{
+  mImpl->CreateSelectionPopup();
+  mImpl->mCopyPastePopup.actor.SetProperties(options);
+}
+
+void Decorator::GetSelectionPopupStyle(Property::Map& options)
+{
+  if(mImpl->mCopyPastePopup.actor)
+  {
+    mImpl->mCopyPastePopup.actor.GetProperties(options);
+  }
+}
+
 /** Scroll **/
 
 void Decorator::SetScrollThreshold(float threshold)