[dali_2.3.37] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / accessibility.cpp
index 4c83f43..6caf3d8 100644 (file)
@@ -40,6 +40,8 @@
 #include <dali/devel-api/atspi-interfaces/hypertext.h>
 #include <dali/devel-api/atspi-interfaces/selection.h>
 #include <dali/devel-api/atspi-interfaces/socket.h>
 #include <dali/devel-api/atspi-interfaces/hypertext.h>
 #include <dali/devel-api/atspi-interfaces/selection.h>
 #include <dali/devel-api/atspi-interfaces/socket.h>
+#include <dali/devel-api/atspi-interfaces/table-cell.h>
+#include <dali/devel-api/atspi-interfaces/table.h>
 #include <dali/devel-api/atspi-interfaces/text.h>
 #include <dali/devel-api/atspi-interfaces/value.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/devel-api/atspi-interfaces/text.h>
 #include <dali/devel-api/atspi-interfaces/value.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
@@ -241,6 +243,8 @@ AtspiInterfaces Accessible::DoGetInterfaces() const
   interfaces[AtspiInterface::HYPERTEXT]     = dynamic_cast<const Hypertext*>(this);
   interfaces[AtspiInterface::SELECTION]     = dynamic_cast<const Selection*>(this);
   interfaces[AtspiInterface::SOCKET]        = dynamic_cast<const Socket*>(this);
   interfaces[AtspiInterface::HYPERTEXT]     = dynamic_cast<const Hypertext*>(this);
   interfaces[AtspiInterface::SELECTION]     = dynamic_cast<const Selection*>(this);
   interfaces[AtspiInterface::SOCKET]        = dynamic_cast<const Socket*>(this);
+  interfaces[AtspiInterface::TABLE]         = dynamic_cast<const Table*>(this);
+  interfaces[AtspiInterface::TABLE_CELL]    = dynamic_cast<const TableCell*>(this);
   interfaces[AtspiInterface::TEXT]          = dynamic_cast<const Text*>(this);
   interfaces[AtspiInterface::VALUE]         = dynamic_cast<const Value*>(this);
 
   interfaces[AtspiInterface::TEXT]          = dynamic_cast<const Text*>(this);
   interfaces[AtspiInterface::VALUE]         = dynamic_cast<const Value*>(this);
 
@@ -302,6 +306,13 @@ void Accessible::SetCurrentlyHighlightedActor(Dali::Actor actor)
   }
 }
 
   }
 }
 
+bool Accessible::IsHighlighted() const
+{
+  Dali::Actor self = GetInternalActor();
+
+  return self && self == GetCurrentlyHighlightedActor();
+}
+
 Dali::Actor Accessible::GetHighlightActor()
 {
   return IsUp() ? Bridge::GetCurrentBridge()->mData->mHighlightActor : Dali::Actor{};
 Dali::Actor Accessible::GetHighlightActor()
 {
   return IsUp() ? Bridge::GetCurrentBridge()->mData->mHighlightActor : Dali::Actor{};
@@ -408,15 +419,14 @@ public:
       return false;
     }
 
       return false;
     }
 
-    auto self = Self();
-    if(self != GetCurrentlyHighlightedActor())
+    if(!IsHighlighted())
     {
       return false;
     }
 
     SetCurrentlyHighlightedActor({});
 
     {
       return false;
     }
 
     SetCurrentlyHighlightedActor({});
 
-    auto                             window     = Dali::DevelWindow::Get(self);
+    auto                             window     = Dali::DevelWindow::Get(Self());
     Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
     windowImpl.EmitAccessibilityHighlightSignal(false);
 
     Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
     windowImpl.EmitAccessibilityHighlightSignal(false);
 
@@ -441,12 +451,17 @@ public:
       state[State::VISIBLE]   = true;
       state[State::ACTIVE]    = visible;
     }
       state[State::VISIBLE]   = true;
       state[State::ACTIVE]    = visible;
     }
-    else
+    else if(GetParent())
     {
       auto parentState      = GetParent()->GetStates();
       state[State::SHOWING] = parentState[State::SHOWING];
       state[State::VISIBLE] = parentState[State::VISIBLE];
     }
     {
       auto parentState      = GetParent()->GetStates();
       state[State::SHOWING] = parentState[State::SHOWING];
       state[State::VISIBLE] = parentState[State::VISIBLE];
     }
+    else
+    {
+      state[State::SHOWING] = false;
+      state[State::VISIBLE] = false;
+    }
     return state;
   }
 
     return state;
   }
 
@@ -480,22 +495,22 @@ public:
 
   void SetListenPostRender(bool enabled) override
   {
 
   void SetListenPostRender(bool enabled) override
   {
-    if (!mRoot)
+    if(!mRoot)
     {
       return;
     }
 
     {
       return;
     }
 
-    auto window                                 = Dali::DevelWindow::Get(Self());
+    auto                             window     = Dali::DevelWindow::Get(Self());
     Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
 
     if(!mRenderNotification)
     {
       mRenderNotification = std::unique_ptr<TriggerEventInterface>(
     Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
 
     if(!mRenderNotification)
     {
       mRenderNotification = std::unique_ptr<TriggerEventInterface>(
-                                           TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &AdaptorAccessible::OnPostRender),
-                                           TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER));
+        TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &AdaptorAccessible::OnPostRender),
+                                                TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER));
     }
 
     }
 
-    if (enabled)
+    if(enabled)
     {
       windowImpl.SetRenderNotification(mRenderNotification.get());
     }
     {
       windowImpl.SetRenderNotification(mRenderNotification.get());
     }
@@ -507,11 +522,11 @@ public:
 
   void OnPostRender()
   {
 
   void OnPostRender()
   {
-    Accessibility::Bridge::GetCurrentBridge()->EmitPostRender(this);
+    Accessibility::Bridge::GetCurrentBridge()->EmitPostRender(shared_from_this());
   }
 }; // AdaptorAccessible
 
   }
 }; // AdaptorAccessible
 
-using AdaptorAccessiblesType = std::unordered_map<const Dali::RefObject*, std::unique_ptr<AdaptorAccessible> >;
+using AdaptorAccessiblesType = std::unordered_map<const Dali::RefObject*, std::shared_ptr<AdaptorAccessible>>;
 
 // Save RefObject from an Actor in Accessible::Get()
 AdaptorAccessiblesType& GetAdaptorAccessibles()
 
 // Save RefObject from an Actor in Accessible::Get()
 AdaptorAccessiblesType& GetAdaptorAccessibles()
@@ -520,7 +535,7 @@ AdaptorAccessiblesType& GetAdaptorAccessibles()
   return gAdaptorAccessibles;
 }
 
   return gAdaptorAccessibles;
 }
 
-std::function<Accessible*(Dali::Actor)> convertingFunctor = [](Dali::Actor) -> Accessible* {
+std::function<std::shared_ptr<Accessible>(Dali::Actor)> convertingFunctor = [](Dali::Actor) -> std::shared_ptr<Accessible> {
   return nullptr;
 };
 
   return nullptr;
 };
 
@@ -535,12 +550,12 @@ void Accessible::SetObjectRegistry(ObjectRegistry registry)
   });
 }
 
   });
 }
 
-void Accessible::RegisterExternalAccessibleGetter(std::function<Accessible*(Dali::Actor)> functor)
+void Accessible::RegisterExternalAccessibleGetter(std::function<std::shared_ptr<Accessible>(Dali::Actor)> functor)
 {
   convertingFunctor = functor;
 }
 
 {
   convertingFunctor = functor;
 }
 
-Accessible* Accessible::Get(Dali::Actor actor)
+std::shared_ptr<Accessible> Accessible::GetOwningPtr(Dali::Actor actor)
 {
   if(!actor)
   {
 {
   if(!actor)
   {
@@ -561,8 +576,14 @@ Accessible* Accessible::Get(Dali::Actor actor)
       }
       pair.first->second.reset(new AdaptorAccessible(actor, isRoot));
     }
       }
       pair.first->second.reset(new AdaptorAccessible(actor, isRoot));
     }
-    accessible = pair.first->second.get();
+    accessible = pair.first->second;
   }
 
   return accessible;
 }
   }
 
   return accessible;
 }
+
+Accessible* Accessible::Get(Dali::Actor actor)
+{
+  auto accessible = Accessible::GetOwningPtr(actor);
+  return accessible ? accessible.get() : nullptr;
+}
\ No newline at end of file