From: Artur Świgoń Date: Mon, 20 Mar 2023 14:46:32 +0000 (+0100) Subject: [AT-SPI] Add SlimCustomViewImpl X-Git-Tag: accepted/tizen/unified/20230330.025615^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=600aa35a1db4198d7f01f7dc4e5686d056574b16;p=platform%2Fcore%2Fuifw%2Fdali-csharp-binder.git [AT-SPI] Add SlimCustomViewImpl 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 --- diff --git a/dali-csharp-binder/file.list b/dali-csharp-binder/file.list index c594dedf..2e28c8d5 100755 --- a/dali-csharp-binder/file.list +++ b/dali-csharp-binder/file.list @@ -67,6 +67,7 @@ SET( dali_csharp_binder_common_src_files ${dali_csharp_binder_dir}/src/style-manager-wrap.cpp ${dali_csharp_binder_dir}/src/drag-and-drop-wrap.cpp ${dali_csharp_binder_dir}/src/font-client-wrap.cpp + ${dali_csharp_binder_dir}/src/slim-custom-view-impl.cpp ) # added for key grab binding only for tizen diff --git a/dali-csharp-binder/src/dali-wrap.cpp b/dali-csharp-binder/src/dali-wrap.cpp index 5969e1b3..e56ac3ce 100644 --- a/dali-csharp-binder/src/dali-wrap.cpp +++ b/dali-csharp-binder/src/dali-wrap.cpp @@ -146,6 +146,7 @@ #include #include "common.h" +#include "slim-custom-view-impl.h" SWIG_CSharpException_t SWIG_csharp_exceptions[] = { { SWIG_CSharpApplicationException, NULL }, @@ -35102,6 +35103,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 index 00000000..a2ecdce2 --- /dev/null +++ b/dali-csharp-binder/src/slim-custom-view-impl.cpp @@ -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 +#include +#include + +// 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 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 index 00000000..a2cb8e6a --- /dev/null +++ b/dali-csharp-binder/src/slim-custom-view-impl.h @@ -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 +#include +#include + +// 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