dnd: add drag and drop csharp binding codes 09/268209/14
authorTaehyub Kim <taehyub.kim@samsung.com>
Fri, 17 Dec 2021 05:54:44 +0000 (14:54 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Tue, 15 Feb 2022 08:21:45 +0000 (17:21 +0900)
Change-Id: Ia537714144d72a7b5d8304f754363e17270093c2

dali-csharp-binder/file.list
dali-csharp-binder/src/drag-and-drop-wrap.cpp [new file with mode: 0644]

index 65d6c14..af79796 100755 (executable)
@@ -52,7 +52,8 @@ dali_csharp_binder_common_src_files = \
   ${dali_csharp_binder_dir}/src/input-options-wrap.cpp \
   ${dali_csharp_binder_dir}/src/model3d-view-wrap.cpp \
   ${dali_csharp_binder_dir}/src/native-image-queue-wrap.cpp \
-  ${dali_csharp_binder_dir}/src/style-manager-wrap.cpp
+  ${dali_csharp_binder_dir}/src/style-manager-wrap.cpp \
+  ${dali_csharp_binder_dir}/src/drag-and-drop-wrap.cpp
 
 # added for key grab binding only for tizen
 # module: csharp-binder, backend: mobile,tv,ivi,watch
diff --git a/dali-csharp-binder/src/drag-and-drop-wrap.cpp b/dali-csharp-binder/src/drag-and-drop-wrap.cpp
new file mode 100644 (file)
index 0000000..7bd116f
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define SWIGSTDCALL
+
+// INCLUDES
+#include "common.h"
+#include <dali/devel-api/adaptor-framework/drag-and-drop.h>
+#include <dali/integration-api/debug.h>
+
+using namespace Dali;
+
+/* Callback for returning strings to C# without leaking memory */
+typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *);
+extern SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback;
+
+static char temp_msg[] = "DnD Data is Empty!";
+static const char * nullExceptMsg = "Attempt to dereference null Dali::Adaptor::DragAndDrop";
+
+using DnDCallback = void(SWIGSTDCALL *)(const Dali::DragAndDrop::DragEvent&);
+DnDCallback dndCallback;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_DragAndDrop_New__SWIG_0() {
+  void *jresult = nullptr;
+  Dali::DragAndDrop result;
+  try {
+      result = Dali::DragAndDrop::Get();
+      jresult = new Dali::DragAndDrop((const Dali::DragAndDrop &)result);
+
+  } CALL_CATCH_EXCEPTION(0);
+
+ return jresult;
+}
+
+SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_DragAndDrop_StartDragAndDrop(void * jarg1, void * jarg2, void * jarg3, char * jarg4) {
+  Dali::DragAndDrop *dnd = (Dali::DragAndDrop *)jarg1;
+
+  if (!dnd) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
+    return false;
+  }
+
+  Dali::Actor *argp2;
+  Dali::Actor *argp3;
+  Dali::Actor source;
+  Dali::Actor shadow;
+
+  argp2 = (Dali::Actor *)jarg2;
+  if (!argp2) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
+    return false;
+  }
+
+  argp3 = (Dali::Actor *)jarg3;
+  if (!argp3) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
+    return false;
+  }
+
+  source = *argp2;
+  shadow = *argp3;
+  bool result = false;
+  {
+    try {
+      result = dnd->StartDragAndDrop(source, shadow, jarg4);
+    }
+    CALL_CATCH_EXCEPTION(0);
+  }
+  return result;
+}
+
+SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_DragAndDrop_AddListener(void * jarg1, void * jarg2, void * jarg3) {
+  Dali::DragAndDrop *dnd = (Dali::DragAndDrop *)jarg1;
+  if (!dnd) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
+    return false;
+  }
+
+  Dali::Actor *argp2;
+  Dali::Actor target;
+
+  argp2 = (Dali::Actor *)jarg2;
+  if (!argp2) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
+    return false;
+  }
+
+  target = *argp2;
+  bool result = false;
+  {
+    try {
+      dndCallback = (DnDCallback)jarg3;
+      result = dnd->AddListener(target, dndCallback);
+    }
+    CALL_CATCH_EXCEPTION(0);
+  }
+  return result;
+}
+
+SWIGEXPORT int SWIGSTDCALL CSharp_Dali_DragEvent_GetAction(void * jarg) {
+  int jresult;
+  Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)jarg;
+
+  if (!dragEvent) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
+    return 0;
+  }
+  {
+    try {
+      jresult = (int)((Dali::DragAndDrop::DragEvent &)*dragEvent).GetAction();
+    }
+    CALL_CATCH_EXCEPTION(0);
+  }
+
+  return jresult;
+}
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_DragEvent_GetPosition(void * jarg) {
+  void * jresult = nullptr;
+  Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)jarg;
+  Dali::Vector2 result;
+
+  if (!dragEvent) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
+    return 0;
+  }
+  {
+    try {
+      result = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetPosition();
+    }
+    CALL_CATCH_EXCEPTION(0);
+  }
+
+  jresult = new Dali::Vector2((const Dali::Vector2 &)result);
+  return jresult;
+}
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_Dali_DragEvent_GetData(void * jarg) {
+  char * jresult = nullptr;
+  Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)jarg;
+  std::string result;
+
+  if (!dragEvent) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
+    return 0;
+  }
+  {
+    try {
+      if (dragEvent->GetData() != nullptr)
+      {
+        result = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetData();
+      }
+      else
+      {
+        result = temp_msg;
+      }
+    }
+    CALL_CATCH_EXCEPTION(0);
+  }
+
+  jresult = SWIG_csharp_string_callback((&result)->c_str());
+  return jresult;
+}
+
+#ifdef __cplusplus
+} // end extern "C"
+#endif