Adding LayoutController and bindings 96/196996/13
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Tue, 8 Jan 2019 19:59:32 +0000 (19:59 +0000)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Thu, 7 Feb 2019 16:11:05 +0000 (16:11 +0000)
Change-Id: I02c82ecaddbb6322627259dd4575573f5623df72

dali-csharp-binder/file.list
dali-csharp-binder/src/layout-controller.cpp [new file with mode: 0644]
dali-csharp-binder/src/layout-controller.h [new file with mode: 0644]

index f7effb1..d7149a1 100755 (executable)
@@ -11,6 +11,7 @@ dali_csharp_binder_common_src_files = \
   ${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 \
+  ${dali_csharp_binder_dir}/src/layout-controller.cpp \
   ${dali_csharp_binder_dir}/src/layout-length.cpp \
   ${dali_csharp_binder_dir}/src/layout-size.cpp \
   ${dali_csharp_binder_dir}/src/layout-measured-size.cpp \
diff --git a/dali-csharp-binder/src/layout-controller.cpp b/dali-csharp-binder/src/layout-controller.cpp
new file mode 100644 (file)
index 0000000..b564c15
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2019 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 "layout-controller.h"
+#include <dali/integration-api/adaptors/adaptor.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+namespace
+{
+static int gLayoutControllerId = 1;
+} // unnamed namespace
+
+LayoutController::LayoutController() : mId( gLayoutControllerId++ )
+{
+  Dali::Adaptor::Get().RegisterProcessor(*this);
+}
+
+
+LayoutController::~LayoutController()
+{
+  Dali::Adaptor::Get().UnregisterProcessor(*this);
+}
+
+
+int LayoutController::GetId() const
+{
+  return mId;
+}
+
+void LayoutController::Process()
+{
+  if( handler )
+  {
+    handler( mId );
+  }
+}
+
+void LayoutController::SetCallback(  LayoutControllerProcessCallback callback )
+{
+  handler = callback;
+}
+
+// LayoutController Bindings
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_new_LayoutController() {
+
+  LayoutController *result = 0 ;
+
+  {
+    try {
+      result = (LayoutController *)new LayoutController();
+    } catch (std::out_of_range& e) {
+      {
+        SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
+      };
+    } catch (std::exception& e) {
+      {
+        SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return 0;
+      };
+    } catch (Dali::DaliException e) {
+      {
+        SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
+      };
+    } catch (...) {
+      {
+        SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
+      };
+    }
+  }
+
+  return (void *)result;
+}
+
+SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_LayoutController(void * jarg1) {
+
+  LayoutController * arg1 = (LayoutController *)jarg1;
+  {
+    try {
+      delete arg1;
+    } catch (std::out_of_range& e) {
+      {
+        SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return ;
+      };
+    } catch (std::exception& e) {
+      {
+        SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return ;
+      };
+    } catch (...) {
+      {
+        SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return ;
+      };
+    }
+  }
+}
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_LayoutController_SetCallback( void* jarg1, LayoutController::LayoutControllerProcessCallback callback )
+{
+  LayoutController* layoutController = (LayoutController *) jarg1;
+
+  if( layoutController )
+  {
+    layoutController->SetCallback( callback );
+  }
+}
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_LayoutController_GetId( void* jarg1 )
+{
+  LayoutController * layoutController = (LayoutController *)jarg1;
+  if( layoutController )
+  {
+    layoutController->GetId();
+  }
+}
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
diff --git a/dali-csharp-binder/src/layout-controller.h b/dali-csharp-binder/src/layout-controller.h
new file mode 100644 (file)
index 0000000..a3fff0d
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2019 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/processor-interface.h>
+
+// INTERNAL INCLUDES
+#include "common.h"
+
+/**
+ * @brief Implements a Integration::Processor interface so can be registered with dali-core as
+ * a Processor.  Enables the setting of a callback so dali-core can execute this callback when
+ * Process() is run.
+ */
+class LayoutController : public Dali::Integration::Processor
+{
+public:
+
+  // Function pointer matching delegate in C# LayoutController
+  using LayoutControllerProcessCallback = void (SWIGSTDCALL*)(int);
+
+public:
+  /**
+   * @brief Constructor - creates a LayoutController and registers it with dali-core.
+   *
+   */
+  LayoutController();
+
+  /**
+   * @brief Destructor - Unregisters itself from dali-core.
+   */
+  ~LayoutController();
+
+  /**
+   * @brief Gets the id of the LayoutController that was initialised during construction.
+   * @return the id of the LayoutController.
+   * @note Useful for debugging when multiple LayoutControllers are registered with dali-core.
+   */
+  int GetId() const;
+
+  /**
+   * @copydoc Dali::Integration::Processor::Process()
+   */
+  void Process() override;
+
+   /**
+    * @brief Set the callback to be executed when dali-core calls the overriden Process() api.
+    * @param[in] callback, function to be called
+    */
+  void SetCallback( LayoutControllerProcessCallback callback );
+
+private:
+
+  LayoutControllerProcessCallback handler;
+
+  int mId;
+
+};
\ No newline at end of file