Further Setter/Getter public API removal from Dali::Actor
[platform/core/uifw/dali-demo.git] / examples / drag-and-drop / drag-and-drop-example.cpp
index ef11be7..4cbe592 100755 (executable)
@@ -57,13 +57,17 @@ public:
   DragAndDropExample( Application& application )
   : mApplication( application ),
     mDragIndex(-1),
-    mDragRealIndex(-1),
-    mDroppedFinished(false)
+    mDragRealIndex(-1)
   {
     // Connect to the Application's Init signal
     mApplication.InitSignal().Connect( this, &DragAndDropExample::Create );
   }
 
+  ~DragAndDropExample()
+  {
+    mDragAndDropDetector.DetachAll();
+  }
+
   // The Init signal is received once (only) during the Application lifetime
   void Create( Application& application )
   {
@@ -76,9 +80,9 @@ public:
     stage.KeyEventSignal().Connect( this, &DragAndDropExample::OnKeyEvent );
 
     TextLabel hintText = TextLabel::New("please drag one textlabel, move and drop on other textlabel");
-    hintText.SetPosition(0.0f, 700.0f);
-    hintText.SetParentOrigin(ParentOrigin::TOP_LEFT);
-    hintText.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+    hintText.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 700.0f));
+    hintText.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+    hintText.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
     hintText.SetProperty(TextLabel::Property::MULTI_LINE, true);
     stage.Add(hintText);
 
@@ -86,16 +90,16 @@ public:
     {
       std::string str = "textlabel ";
       mTextLabel[i] = TextLabel::New(str + std::to_string(i));
-      mTextLabel[i].SetParentOrigin(ParentOrigin::TOP_LEFT);
-      mTextLabel[i].SetAnchorPoint(AnchorPoint::TOP_LEFT);
-      mTextLabel[i].SetName("textlabel " + std::to_string(i));
-      mTextLabel[i].SetLeaveRequired(true);
+      mTextLabel[i].SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+      mTextLabel[i].SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+      mTextLabel[i].SetProperty( Dali::Actor::Property::NAME,"textlabel " + std::to_string(i));
+      mTextLabel[i].SetProperty( Actor::Property::LEAVE_REQUIRED,true);
       mTextLabel[i].SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
       mTextLabel[i].SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
       mTextLabel[i].SetBackgroundColor(TEXT_LABEL_COLOR[i]);
 
-      mTextLabel[i].SetSize(TEXT_LABEL_WIDTH, TEXT_LABEL_HEIGHT);
-      mTextLabel[i].SetPosition(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * i);
+      mTextLabel[i].SetProperty( Actor::Property::SIZE, Vector2(TEXT_LABEL_WIDTH, TEXT_LABEL_HEIGHT) );
+      mTextLabel[i].SetProperty( Actor::Property::POSITION, Vector2(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * i));
       mDragAndDropDetector.Attach(mTextLabel[i]);
 
       mRect[i] = Rect<float>(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * i, TEXT_LABEL_WIDTH, TEXT_LABEL_HEIGHT);
@@ -126,9 +130,9 @@ public:
   void OnStart(Control control, Dali::Toolkit::DragAndDropDetector detector)
   {
     DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---OnStart---\n");
-    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetName().c_str());
+    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str());
 
-    control.SetOpacity(0.1f);
+    control.SetProperty( DevelActor::Property::OPACITY,0.1f);
     Vector2 screenPos  = detector.GetCurrentScreenPosition();
     control.ScreenToLocal(mDragLocalPos.x, mDragLocalPos.y,screenPos.x, screenPos.y );
     Rect<float> targetRect(screenPos.x, screenPos.y, 0.0f, 0.0f);
@@ -147,26 +151,26 @@ public:
   void OnEnter(Control control, Dali::Toolkit::DragAndDropDetector detector)
   {
     DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---OnEnter---\n");
-    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetName().c_str());
+    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str());
   }
 
   void OnExit(Control control, Dali::Toolkit::DragAndDropDetector detector)
   {
     DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---OnExit---\n");
-    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetName().c_str());
+    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str());
   }
 
   void OnMoved(Control control, Dali::Toolkit::DragAndDropDetector detector)
   {
     DALI_LOG_INFO(gDragAndDropFilter, Debug::Verbose, "---OnMoved---\n");
-    DALI_LOG_INFO(gDragAndDropFilter, Debug::Verbose, "---control name is %s---\n", control.GetName().c_str());
+    DALI_LOG_INFO(gDragAndDropFilter, Debug::Verbose, "---control name is %s---\n", control.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str());
     DALI_LOG_INFO(gDragAndDropFilter, Debug::Verbose, "---coordinate is (%f, %f)---\n", detector.GetCurrentScreenPosition().x, detector.GetCurrentScreenPosition().y);
   }
 
   void OnDropped(Control control, Dali::Toolkit::DragAndDropDetector detector)
   {
     DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---OnDropped---\n");
-    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetName().c_str());
+    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str());
 
     Vector2 screenPos  = detector.GetCurrentScreenPosition();
     Rect<float> targetRect(screenPos.x, screenPos.y, 0.0f, 0.0f);
@@ -185,7 +189,7 @@ public:
     {
       for(int i = mDragIndex + 1; i <= droppedIndex; i++)
       {
-        float y = mTextLabel[mOrder[i]].GetCurrentPosition().y;
+        float y = mTextLabel[mOrder[i]].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
         mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), Vector3(TEXT_LABEL_POSITION_X, y - TEXT_LABEL_HEIGHT, 0.0f), AlphaFunction::EASE_OUT);
         mAnimation.Play();
       }
@@ -203,7 +207,7 @@ public:
 
       for(int i = mDragIndex - 1; i >= droppedIndex; i--)
       {
-        float y = mTextLabel[mOrder[i]].GetCurrentPosition().y;
+        float y = mTextLabel[mOrder[i]].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
         mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), Vector3(TEXT_LABEL_POSITION_X, y + TEXT_LABEL_HEIGHT, 0.0f), AlphaFunction::EASE_OUT);
         mAnimation.Play();
       }
@@ -225,19 +229,16 @@ public:
 
     KeyFrames k0 = KeyFrames::New();
     k0.Add(0.0f, Vector3(localPos.x - mDragLocalPos.x, localPos.y - mDragLocalPos.y, 0.0f));
-    k0.Add(1.0f, Vector3(control.GetCurrentPosition().x, control.GetCurrentPosition().y, 0.0f));
+    k0.Add(1.0f, Vector3(control.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, control.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, 0.0f));
 
     KeyFrames k1 = KeyFrames::New();
     k1.Add(0.0f, 0.1f);
     k1.Add(1.0f, 1.0f);
 
     Animation dropAnimation = Animation::New(0.5f);
-    dropAnimation.FinishedSignal().Connect(this, &DragAndDropExample::DropAnimationFinished);
     dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], Actor::Property::POSITION), k0, AlphaFunction::EASE_OUT);
     dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], DevelActor::Property::OPACITY), k1, AlphaFunction::EASE_OUT);
     dropAnimation.Play();
-
-    mDroppedFinished = true;
   }
 
   void DropAnimationFinished(Animation& animation)
@@ -251,16 +252,9 @@ public:
   void OnEnd(Control control, Dali::Toolkit::DragAndDropDetector detector)
   {
     DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---OnEnd---\n");
-    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetName().c_str());
-
-    control.SetOpacity(1.0f);
+    DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str());
 
-    if(mDroppedFinished)
-    {
-      mDragAndDropDetector.DetachAll();
-    }
-
-    mDroppedFinished = false;
+    control.SetProperty( DevelActor::Property::OPACITY,1.0f);
   }
 
 private:
@@ -276,8 +270,6 @@ private:
 
   Vector2 mDragLocalPos;
 
-  bool mDroppedFinished;
-
 };
 
 int DALI_EXPORT_API main( int argc, char **argv )