*/
virtual ~Bridge() = default;
+ /**
+ * @brief Adds the accessible object associated with given actorId to the brige.
+ */
+ virtual void AddAccessible(uint32_t actorId, std::shared_ptr<Accessible> accessible) = 0;
+
+ /**
+ * @brief Removed the accessible object associated with given actorId from the brige.
+ */
+ virtual void RemoveAccessible(uint32_t actorId) = 0;
+
+ /**
+ * @brief Gets the accessible object associated with given actorId from the brige.
+ */
+ virtual std::shared_ptr<Accessible> GetAccessible(uint32_t actorId) const = 0;
+
/**
* @brief Gets bus name which bridge is initialized on.
*
private:
std::unique_ptr<TriggerEventInterface> mRenderNotification = nullptr;
+ void OffSceneCallback(Actor actor)
+ {
+ uint32_t actorId = actor.GetProperty<int>(Actor::Property::ID);
+ Bridge::GetCurrentBridge()->RemoveAccessible(actorId);
+ }
+
protected:
bool mRoot = false;
: ActorAccessible(actor),
mRoot(isRoot)
{
+ actor.OffSceneSignal().Connect(this, &AdaptorAccessible::OffSceneCallback);
}
bool GrabFocus() override
}
}; // AdaptorAccessible
-using AdaptorAccessiblesType = std::unordered_map<const Dali::RefObject*, std::shared_ptr<AdaptorAccessible>>;
+using ConvertingResult = std::pair<std::shared_ptr<Accessible>, bool>;
-// Save RefObject from an Actor in Accessible::Get()
-AdaptorAccessiblesType& GetAdaptorAccessibles()
-{
- static AdaptorAccessiblesType gAdaptorAccessibles;
- return gAdaptorAccessibles;
-}
-
-std::function<std::shared_ptr<Accessible>(Dali::Actor)> convertingFunctor = [](Dali::Actor) -> std::shared_ptr<Accessible> {
- return nullptr;
+std::function<ConvertingResult(Dali::Actor)> convertingFunctor = [](Dali::Actor) -> ConvertingResult {
+ return {nullptr, true};
};
-ObjectRegistry objectRegistry;
} // namespace
-void Accessible::SetObjectRegistry(ObjectRegistry registry)
-{
- objectRegistry = registry;
- objectRegistry.ObjectDestroyedSignal().Connect([](const Dali::RefObject* obj) {
- GetAdaptorAccessibles().erase(obj);
- });
-}
-
-void Accessible::RegisterExternalAccessibleGetter(std::function<std::shared_ptr<Accessible>(Dali::Actor)> functor)
+void Accessible::RegisterExternalAccessibleGetter(std::function<ConvertingResult(Dali::Actor)> functor)
{
convertingFunctor = functor;
}
return nullptr;
}
- auto accessible = convertingFunctor(actor);
- if(!accessible)
+ auto bridge = Bridge::GetCurrentBridge();
+
+ uint32_t actorId = actor.GetProperty<int>(Actor::Property::ID);
+ auto accessible = bridge->GetAccessible(actorId);
+ if(accessible)
{
- auto pair = GetAdaptorAccessibles().emplace(&actor.GetBaseObject(), nullptr);
- if(pair.second)
+ return accessible;
+ }
+
+ auto result = convertingFunctor(actor);
+ accessible = result.first;
+ const bool creationEnabled = result.second;
+ if(!accessible && creationEnabled)
+ {
+ bool isRoot = false;
+ Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor);
+ if(scene)
{
- bool isRoot = false;
- Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor);
- if(scene)
- {
- isRoot = (actor == scene.GetRootLayer());
- }
- pair.first->second.reset(new AdaptorAccessible(actor, isRoot));
+ isRoot = (actor == scene.GetRootLayer());
}
- accessible = pair.first->second;
+ accessible = std::make_shared<AdaptorAccessible>(actor, isRoot);
+ }
+
+ if(accessible)
+ {
+ bridge->AddAccessible(actorId, accessible);
}
return accessible;
*/
static void SetCurrentlyHighlightedActor(Dali::Actor actor);
- /**
- * @brief Sets ObjectRegistry.
- *
- * @param[in] registry ObjectRegistry instance
- */
- static void SetObjectRegistry(ObjectRegistry registry);
-
/**
* @brief The method registers functor resposible for converting Actor into Accessible.
* @param functor The returning Accessible handle from Actor object
*/
- static void RegisterExternalAccessibleGetter(std::function<std::shared_ptr<Accessible>(Dali::Actor)> functor);
+ static void RegisterExternalAccessibleGetter(std::function<std::pair<std::shared_ptr<Accessible>, bool>(Dali::Actor)> functor);
/**
* @brief Acquires Accessible object from Actor object.
Dali::Timer mReadScreenReaderEnabledTimer;
Dali::Timer mForceUpTimer;
std::string mPreferredBusName;
+ std::map<uint32_t, std::shared_ptr<Accessible>> mAccessibles; // Actor.ID to Accessible map
public:
BridgeImpl() = default;
+ void AddAccessible(uint32_t actorId, std::shared_ptr<Accessible> accessible) override
+ {
+ mAccessibles[actorId] = std::move(accessible);
+ }
+
+ void RemoveAccessible(uint32_t actorId) override
+ {
+ mAccessibles.erase(actorId);
+ }
+
+ std::shared_ptr<Accessible> GetAccessible(uint32_t actorId) const override
+ {
+ auto iter = mAccessibles.find(actorId);
+ return iter != mAccessibles.end() ? iter->second : nullptr;
+ }
+
/**
* @copydoc Dali::Accessibility::Bridge::EmitKeyEvent()
*/