[Tizen][AT-SPI] Add SlimCustomViewImpl 43/290143/3
authorArtur Świgoń <a.swigon@samsung.com>
Mon, 20 Mar 2023 14:46:32 +0000 (15:46 +0100)
committerArtur Świgoń <a.swigon@samsung.com>
Mon, 27 Mar 2023 08:26:29 +0000 (10:26 +0200)
SlimCustomViewImpl is almost identical to Toolkit::Internal::Control, and its
purpose is to support the NUI option ViewAccessibilityMode.Custom by providing
a NUIViewAccessible instead of a ControlAccessible, thus allowing Accessibility
to be implemented in C# for a given View.

Change-Id: Iac0b7001ef8b0ce29f7fde3483db57ef3c2713fd

dali-csharp-binder/file.list
dali-csharp-binder/src/dali-wrap.cpp
dali-csharp-binder/src/slim-custom-view-impl.cpp [new file with mode: 0644]
dali-csharp-binder/src/slim-custom-view-impl.h [new file with mode: 0644]

index 1eb6134..cc31114 100755 (executable)
@@ -56,6 +56,7 @@ SET( dali_csharp_binder_common_src_files
   ${dali_csharp_binder_dir}/src/native-image-queue-wrap.cpp
   ${dali_csharp_binder_dir}/src/style-manager-wrap.cpp
   ${dali_csharp_binder_dir}/src/drag-and-drop-wrap.cpp
+  ${dali_csharp_binder_dir}/src/slim-custom-view-impl.cpp
 )
 
 # added for key grab binding only for tizen
index 7853429..a11c809 100644 (file)
 #include <stdio.h>
 
 #include "common.h"
+#include "slim-custom-view-impl.h"
 
 SWIG_CSharpException_t SWIG_csharp_exceptions[] = {
   { SWIG_CSharpApplicationException, NULL },
@@ -39366,6 +39367,19 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_View_New() {
   return jresult;
 }
 
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_View_NewCustom() {
+  void * jresult;
+  Dali::Toolkit::Control result;
+
+  {
+    try {
+      result = SlimCustomViewImpl::New(Dali::Toolkit::Internal::Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS);
+    } CALL_CATCH_EXCEPTION(0);
+  }
+
+  jresult = new Dali::Toolkit::Control((const Dali::Toolkit::Control &)result);
+  return jresult;
+}
 
 SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_new_View__SWIG_0() {
   void * jresult ;
diff --git a/dali-csharp-binder/src/slim-custom-view-impl.cpp b/dali-csharp-binder/src/slim-custom-view-impl.cpp
new file mode 100644 (file)
index 0000000..a2ecdce
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2023 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.
+ *
+ */
+
+// CLASS HEADER
+#include "slim-custom-view-impl.h"
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/object/handle-devel.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+// INTERNAL INCLUDES
+#include "nui-view-accessible.h"
+
+SlimCustomViewImpl::SlimCustomViewImpl(ControlBehaviour behaviourFlags) : Control(behaviourFlags)
+{
+}
+
+Dali::Toolkit::Control SlimCustomViewImpl::New(ControlBehaviour additionalBehaviour)
+{
+  // Create the implementation, temporarily owned on stack
+  Dali::IntrusivePtr<SlimCustomViewImpl> controlImpl = new SlimCustomViewImpl(Control::ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehaviour));
+
+  // Pass ownership to handle
+  Dali::Toolkit::Control handle(*controlImpl);
+
+  // Second-phase init of the implementation
+  // This can only be done after the CustomActor connection has been made...
+  controlImpl->Initialize();
+
+  // Impersonate Control by adopting its TypeInfo. Without this, many things don't work.
+  Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo(typeid(Control));
+  if(typeInfo)
+  {
+    Dali::DevelHandle::SetTypeInfo(handle, typeInfo);
+  }
+
+  return handle;
+}
+
+Dali::Toolkit::DevelControl::ControlAccessible* SlimCustomViewImpl::CreateAccessibleObject()
+{
+  return new NUIViewAccessible(Self());
+}
diff --git a/dali-csharp-binder/src/slim-custom-view-impl.h b/dali-csharp-binder/src/slim-custom-view-impl.h
new file mode 100644 (file)
index 0000000..a2cb8e6
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef CSHARP_SLIM_CUSTOM_VIEW_IMPL_H
+#define CSHARP_SLIM_CUSTOM_VIEW_IMPL_H
+
+/*
+ * Copyright (c) 2023 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-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
+
+// INTERNAL INCLUDES
+#include "common.h"
+
+// SlimCustomViewImpl behaves almost identically to Toolkit::Internal::Control,
+// but is associated with a NUIViewAccessible, therefore opening the possibility
+// of providing Accessibility support in C#.
+class SlimCustomViewImpl : public Dali::Toolkit::Internal::Control
+{
+  using Dali::Toolkit::Internal::Control::ControlBehaviour;
+
+  SlimCustomViewImpl(ControlBehaviour behaviourFlags);
+
+public:
+  static Dali::Toolkit::Control New(ControlBehaviour additionalBehaviour);
+
+protected:
+  Dali::Toolkit::DevelControl::ControlAccessible* CreateAccessibleObject() override;
+};
+
+#endif // CSHARP_SLIM_CUSTOM_VIEW_IMPL_H