Add Constraint Class + Make Two Useful Constraint 56/261156/7
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 12 Jul 2021 11:54:21 +0000 (20:54 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Thu, 15 Jul 2021 07:55:57 +0000 (00:55 -0700)
Make NUI can use constraint now.

Constraint with custom-function is not allow now, but
We make some useful case with float / ParentSource constraint

- EqualConstraintWithParentFloat
- RelativeConstraintWithParentFloat

Change-Id: I46280605aaf4563ab024a6ef9592552cbd16f9e9

dali-csharp-binder/file.list
dali-csharp-binder/src/constraint.cpp [new file with mode: 0755]

index bea89f9..61fe27c 100755 (executable)
@@ -9,6 +9,7 @@ dali_csharp_binder_common_src_files = \
   ${dali_csharp_binder_dir}/src/dali_wrap.cpp \
   ${dali_csharp_binder_dir}/src/callbackbase_wrap.cpp \
   ${dali_csharp_binder_dir}/src/canvas-view.cpp \
+  ${dali_csharp_binder_dir}/src/constraint.cpp \
   ${dali_csharp_binder_dir}/src/keyboard_focus_manager_wrap.cpp \
   ${dali_csharp_binder_dir}/src/devel-property-wrap.cpp \
   ${dali_csharp_binder_dir}/src/version-check.cpp \
diff --git a/dali-csharp-binder/src/constraint.cpp b/dali-csharp-binder/src/constraint.cpp
new file mode 100755 (executable)
index 0000000..ecbf825
--- /dev/null
@@ -0,0 +1,365 @@
+#ifndef CSHARP_CONSTRAINT
+#define CSHARP_CONSTRAINT
+#endif
+
+/*
+ * Copyright (c) 2021 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.
+ *
+ */
+
+#include "common.h"
+#include <dali/public-api/animation/constraint.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define CALL_CATCH_EXCEPTION(ret)                                          \
+  catch (std::out_of_range & e)                                            \
+  {                                                                        \
+    SWIG_CSharpException(SWIG_IndexError, const_cast<char *>(e.what()));   \
+    return ret;                                                            \
+  }                                                                        \
+  catch (std::exception & e)                                               \
+  {                                                                        \
+    SWIG_CSharpException(SWIG_RuntimeError, const_cast<char *>(e.what())); \
+    return ret;                                                            \
+  }                                                                        \
+  catch (Dali::DaliException e)                                            \
+  {                                                                        \
+    SWIG_CSharpException(SWIG_UnknownError, e.condition);                  \
+    return ret;                                                            \
+  }                                                                        \
+  catch (...)                                                              \
+  {                                                                        \
+    SWIG_CSharpException(SWIG_UnknownError, "unknown error");              \
+    return ret;                                                            \
+  }
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_EqualConstraintWithParentFloat_New(void * nuiHandle, int nuiTargetIndex, int nuiParentIndex)
+{
+  Dali::Handle *handle = (Dali::Handle *) 0;
+  Dali::Property::Index targetIndex;
+  Dali::Property::Index parentIndex;
+  Dali::Constraint result;
+  void * jresult = 0;
+
+  handle = (Dali::Handle *)nuiHandle;
+  if (!handle)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Handle & const is null", 0);
+    return 0;
+  }
+  targetIndex = (Dali::Property::Index)nuiTargetIndex;
+  parentIndex = (Dali::Property::Index)nuiParentIndex;
+
+  {
+    try
+    {
+      result = Dali::Constraint::New<float>(*handle, targetIndex, Dali::EqualToConstraint());
+      result.AddSource(Dali::ParentSource(parentIndex));
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  jresult = new Dali::Constraint((const Dali::Constraint &)result);
+  return jresult;
+}
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_RelativeConstraintWithParentFloat_New(void * nuiHandle, int nuiTargetIndex, int nuiParentIndex, float nuiRelativeRate)
+{
+  Dali::Handle *handle = (Dali::Handle *) 0;
+  Dali::Property::Index targetIndex;
+  Dali::Property::Index parentIndex;
+  float relativeRate;
+  Dali::Constraint result;
+  void * jresult = 0;
+
+  handle = (Dali::Handle *)nuiHandle;
+  if (!handle)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Handle & const is null", 0);
+    return 0;
+  }
+  targetIndex = (Dali::Property::Index)nuiTargetIndex;
+  parentIndex = (Dali::Property::Index)nuiParentIndex;
+  relativeRate = nuiRelativeRate;
+
+  {
+    try
+    {
+      result = Dali::Constraint::New<float>(*handle, targetIndex, Dali::RelativeToConstraintFloat(relativeRate));
+      result.AddSource(Dali::ParentSource(parentIndex));
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  jresult = new Dali::Constraint((const Dali::Constraint &)result);
+  return jresult;
+}
+
+SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Constraint_Apply(void * nuiConstraint)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  if (!constraint)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Constraint is null", 0);
+    return;
+  }
+
+  {
+    try
+    {
+      (*constraint).Apply();
+    } CALL_CATCH_EXCEPTION();
+  }
+}
+
+SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Constraint_Remove(void * nuiConstraint)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  if (!constraint)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Constraint is null", 0);
+    return;
+  }
+
+  {
+    try
+    {
+      (*constraint).Remove();
+    } CALL_CATCH_EXCEPTION();
+  }
+}
+
+SWIGEXPORT int SWIGSTDCALL CSharp_Dali_Constraint_REMOVE_ACTION_BAKE_get()
+{
+  int jresult = 0;
+
+  {
+    try
+    {
+      jresult = (int)Dali::Constraint::BAKE;
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  return jresult;
+}
+
+SWIGEXPORT int SWIGSTDCALL CSharp_Dali_Constraint_REMOVE_ACTION_DISCARD_get()
+{
+  int jresult = 0;
+
+  {
+    try
+    {
+      jresult = (int)Dali::Constraint::DISCARD;
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  return jresult;
+}
+
+SWIGEXPORT int SWIGSTDCALL CSharp_Dali_Constraint_DEFAULT_REMOVE_ACTION_get()
+{
+  int jresult = 0;
+
+  {
+    try
+    {
+      jresult = (int)Dali::Constraint::DEFAULT_REMOVE_ACTION;
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  return jresult;
+}
+
+SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Constraint_SetRemoveAction(void * nuiConstraint, int nuiRemoveAction)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+  Dali::Constraint::RemoveAction removeAction = Dali::Constraint::DEFAULT_REMOVE_ACTION;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  if (!constraint)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Constraint is null", 0);
+    return;
+  }
+  removeAction = (Dali::Constraint::RemoveAction)nuiRemoveAction;
+
+  {
+    try
+    {
+      (*constraint).SetRemoveAction(removeAction);
+    } CALL_CATCH_EXCEPTION();
+  }
+}
+
+SWIGEXPORT int SWIGSTDCALL CSharp_Dali_Constraint_GetRemoveAction(void * nuiConstraint)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+  int jresult = 0;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  if (!constraint)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Constraint is null", 0);
+    return 0;
+  }
+
+  {
+    try
+    {
+      jresult = (int)(*constraint).GetRemoveAction();
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  return jresult;
+}
+
+SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Constraint_SetTag(void * nuiConstraint, unsigned int nuiTag)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+  uint32_t tag = 0;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  if (!constraint)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Constraint is null", 0);
+    return;
+  }
+  tag = nuiTag;
+
+  {
+    try
+    {
+      (*constraint).SetTag(tag);
+    } CALL_CATCH_EXCEPTION();
+  }
+}
+
+SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Constraint_GetTag(void * nuiConstraint)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+  uint32_t jresult = 0;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  if (!constraint)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Constraint is null", 0);
+    return 0;
+  }
+
+  {
+    try
+    {
+      jresult = (*constraint).GetTag();
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  return jresult;
+}
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Constraint_GetTargetObject(void * nuiConstraint)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+  Dali::Handle result = Dali::Handle();
+  void * jresult = 0;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  if (!constraint)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Constraint is null", 0);
+    return 0;
+  }
+
+  {
+    try
+    {
+      result = (*constraint).GetTargetObject();
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  jresult = new Dali::Handle((const Dali::Handle &)result);
+  return jresult;
+}
+
+SWIGEXPORT int SWIGSTDCALL CSharp_Dali_Constraint_GetTargetProperty(void * nuiConstraint)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+  Dali::Property::Index result = Dali::Property::INVALID_INDEX;
+  int jresult = 0;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  if (!constraint)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Constraint is null", 0);
+    return 0;
+  }
+
+  {
+    try
+    {
+      result = (*constraint).GetTargetProperty();
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  jresult = (int)result;
+  return jresult;
+}
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_new_Constraint(void * nuiConstraint)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+  Dali::Constraint *result;
+  void * jresult;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  if (!constraint)
+  {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Constraint is null", 0);
+    return 0;
+  }
+
+  {
+    try
+    {
+      result = new Dali::Constraint(*constraint);
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  jresult = (void *)result;
+  return jresult;
+}
+
+SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_Constraint(void * nuiConstraint)
+{
+  Dali::Constraint *constraint = (Dali::Constraint *) 0;
+
+  constraint = (Dali::Constraint *)nuiConstraint;
+  {
+    try
+    {
+      delete constraint;
+    } CALL_CATCH_EXCEPTION();
+  }
+}
+
+#ifdef __cplusplus
+}
+#endif