From ecd2671e258423eb9649c9e48d1de61de0def31d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Artur=20=C5=9Awigo=C5=84?= Date: Fri, 13 May 2022 13:51:29 +0200 Subject: [PATCH] [AT-SPI] Rework bindings for GetAccessibilityRelations() With the relation target type changed from Address to Accessible* in dali-adaptor and dali-toolkit, the result of GetAccessibilityRelations() can be converted to a mapping from RelationType to Control (View), to make this API more useful in NUI, in which there are no Accessible objects, and Address objects are totally useless. Address and AddressCollection are also removed from NUI. Change-Id: Ic32ffc559dcf94608a35b89e7e8fdcc82204d89f --- dali-csharp-binder/src/control-devel-wrap.cpp | 65 +++++++-------------------- 1 file changed, 17 insertions(+), 48 deletions(-) diff --git a/dali-csharp-binder/src/control-devel-wrap.cpp b/dali-csharp-binder/src/control-devel-wrap.cpp index 604d98c..56dd608 100644 --- a/dali-csharp-binder/src/control-devel-wrap.cpp +++ b/dali-csharp-binder/src/control-devel-wrap.cpp @@ -147,59 +147,28 @@ SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Toolkit_DevelControl_RemoveAccessibility })); } -SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Toolkit_DevelControl_new_GetAccessibilityRelations(void *arg1) { - std::vector> *result = nullptr; - GUARD_ON_NULL_RET0(arg1); - try_catch(([&]() { - auto *control = (Dali::Toolkit::Control*)arg1; - result = new std::vector>(GetAccessibilityRelations(*control)); - })); - return (void*)result; -} +SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Toolkit_DevelControl_GetAccessibilityRelations(void* arg1_control, void (*arg2_callback)(int, void*, void*), void* arg3_userData) { + using namespace Dali::Accessibility; -//SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Toolkit_DevelControl_AccessibilityRelations_Size(void *arg1) { -// unsigned int result = 0; -// GUARD_ON_NULL_RET0(arg1); -// try_catch(([&]() { -// auto *vect = (std::vector>*) arg1; -// result = vect->size(); -// })); -// return result; -//} + GUARD_ON_NULL_RET(arg1_control); + GUARD_ON_NULL_RET(arg2_callback); -SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Toolkit_DevelControl_AccessibilityRelations_RelationSize(void *arg1, int rel) { - unsigned int result = 0; - GUARD_ON_NULL_RET0(arg1); try_catch(([&]() { - auto *vect = (std::vector>*) arg1; - if (((unsigned int) rel) >= vect->size()) - result = 0; - else - result = vect->at(rel).size(); - })); - return result; -} - -SWIGEXPORT char * SWIGSTDCALL CSharp_Dali_Toolkit_DevelControl_new_GetAccessibilityRelations_At(void *arg1, int rel, int pos, int id) { - GUARD_ON_NULL_RET0(arg1); - char *result = nullptr; - try_catch(([&]() { - auto *vect = (std::vector>*) arg1; - const auto &r = vect->at(rel); - const auto &e = r.at(pos); - - if (id == 0) - result = SWIG_csharp_string_callback(e.GetBus().c_str()); + auto* control = static_cast(arg1_control); + std::vector relations = GetAccessibilityRelations(*control); - if (id == 1) - result = SWIG_csharp_string_callback(e.GetPath().c_str()); - })); - return result; -} + for(Relation& relation : relations) { + for(Accessible* target : relation.mTargets) { + // NUI is unaware of Accessible objects, so we only report those convertible to Control. + // Note that it is currently impossible to make a relation with anything other than Control (View) + // using NUI API, so there should not be any loss of information for typical NUI applications. + auto targetControl = Dali::Toolkit::Control::DownCast(target->GetInternalActor()); -SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Toolkit_DevelControl_delete_AccessibilityRelations(void *arg1) { - try_catch(([&]() { - delete static_cast>*>(arg1); + if(targetControl) { + arg2_callback(static_cast(relation.mRelationType), static_cast(new Dali::Actor(targetControl)), arg3_userData); + } + } + } })); } -- 2.7.4