X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fdevel-api%2Fadaptor-framework%2Faccessibility.cpp;h=f69c96cdc768806952b25f6658ba5a8ad6cb10ac;hb=HEAD;hp=196ab605c72fa1e39508851058254286745c2d2d;hpb=a8f11873cf284a084bc89b847f6988da35737637;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/devel-api/adaptor-framework/accessibility.cpp b/dali/devel-api/adaptor-framework/accessibility.cpp index 196ab60..6caf3d8 100644 --- a/dali/devel-api/adaptor-framework/accessibility.cpp +++ b/dali/devel-api/adaptor-framework/accessibility.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2020 Samsung Electronics Co., Ltd + * Copyright 2022 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. @@ -39,9 +39,13 @@ #include #include #include +#include +#include +#include #include #include #include +#include #include using namespace Dali::Accessibility; @@ -238,6 +242,9 @@ AtspiInterfaces Accessible::DoGetInterfaces() const interfaces[AtspiInterface::HYPERLINK] = dynamic_cast(this); interfaces[AtspiInterface::HYPERTEXT] = dynamic_cast(this); interfaces[AtspiInterface::SELECTION] = dynamic_cast(this); + interfaces[AtspiInterface::SOCKET] = dynamic_cast(this); + interfaces[AtspiInterface::TABLE] = dynamic_cast(this); + interfaces[AtspiInterface::TABLE_CELL] = dynamic_cast(this); interfaces[AtspiInterface::TEXT] = dynamic_cast(this); interfaces[AtspiInterface::VALUE] = dynamic_cast(this); @@ -299,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{}; @@ -335,6 +349,9 @@ namespace { class AdaptorAccessible : public ActorAccessible { +private: + std::unique_ptr mRenderNotification = nullptr; + protected: bool mRoot = false; @@ -352,12 +369,68 @@ public: bool GrabHighlight() override { - return false; + if(!IsUp()) + { + return false; + } + + // Only window accessible is able to grab and clear highlight + if(!mRoot) + { + return false; + } + + auto self = Self(); + auto oldHighlightedActor = GetCurrentlyHighlightedActor(); + if(self == oldHighlightedActor) + { + return true; + } + + // Clear the old highlight. + if(oldHighlightedActor) + { + auto oldHighlightedObject = Dali::Accessibility::Component::DownCast(Accessible::Get(oldHighlightedActor)); + if(oldHighlightedObject) + { + oldHighlightedObject->ClearHighlight(); + } + } + + SetCurrentlyHighlightedActor(self); + + auto window = Dali::DevelWindow::Get(self); + Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window); + windowImpl.EmitAccessibilityHighlightSignal(true); + + return true; } bool ClearHighlight() override { - return false; + if(!IsUp()) + { + return false; + } + + // Only window accessible is able to grab and clear highlight + if(!mRoot) + { + return false; + } + + if(!IsHighlighted()) + { + return false; + } + + SetCurrentlyHighlightedActor({}); + + auto window = Dali::DevelWindow::Get(Self()); + Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window); + windowImpl.EmitAccessibilityHighlightSignal(false); + + return true; } Role GetRole() const override @@ -378,22 +451,36 @@ public: 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]; } + else + { + state[State::SHOWING] = false; + state[State::VISIBLE] = false; + } return state; } Attributes GetAttributes() const override { + Attributes attributes; + + if(mRoot) + { + Dali::Window window = Dali::DevelWindow::Get(Self()); + Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window); + attributes["resID"] = windowImpl.GetNativeResourceId(); + } + Dali::TypeInfo type; Self().GetTypeInfo(type); - return { - {"class", type.GetName()}, - }; + attributes["class"] = type.GetName(); + + return attributes; } bool DoGesture(const GestureInfo& gestureInfo) override @@ -405,14 +492,50 @@ public: { return {}; } + + void SetListenPostRender(bool enabled) override + { + if(!mRoot) + { + return; + } + + auto window = Dali::DevelWindow::Get(Self()); + Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window); + + if(!mRenderNotification) + { + mRenderNotification = std::unique_ptr( + TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &AdaptorAccessible::OnPostRender), + TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER)); + } + + if(enabled) + { + windowImpl.SetRenderNotification(mRenderNotification.get()); + } + else + { + windowImpl.SetRenderNotification(nullptr); + } + } + + void OnPostRender() + { + Accessibility::Bridge::GetCurrentBridge()->EmitPostRender(shared_from_this()); + } }; // AdaptorAccessible -using AdaptorAccessiblesType = std::unordered_map >; +using AdaptorAccessiblesType = std::unordered_map>; // Save RefObject from an Actor in Accessible::Get() -AdaptorAccessiblesType gAdaptorAccessibles; +AdaptorAccessiblesType& GetAdaptorAccessibles() +{ + static AdaptorAccessiblesType gAdaptorAccessibles; + return gAdaptorAccessibles; +} -std::function convertingFunctor = [](Dali::Actor) -> Accessible* { +std::function(Dali::Actor)> convertingFunctor = [](Dali::Actor) -> std::shared_ptr { return nullptr; }; @@ -423,16 +546,16 @@ void Accessible::SetObjectRegistry(ObjectRegistry registry) { objectRegistry = registry; objectRegistry.ObjectDestroyedSignal().Connect([](const Dali::RefObject* obj) { - gAdaptorAccessibles.erase(obj); + GetAdaptorAccessibles().erase(obj); }); } -void Accessible::RegisterExternalAccessibleGetter(std::function functor) +void Accessible::RegisterExternalAccessibleGetter(std::function(Dali::Actor)> functor) { convertingFunctor = functor; } -Accessible* Accessible::Get(Dali::Actor actor, bool isRoot) +std::shared_ptr Accessible::GetOwningPtr(Dali::Actor actor) { if(!actor) { @@ -442,13 +565,25 @@ Accessible* Accessible::Get(Dali::Actor actor, bool isRoot) auto accessible = convertingFunctor(actor); if(!accessible) { - auto pair = gAdaptorAccessibles.emplace(&actor.GetBaseObject(), nullptr); + auto pair = GetAdaptorAccessibles().emplace(&actor.GetBaseObject(), nullptr); if(pair.second) { + 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)); } - accessible = pair.first->second.get(); + accessible = pair.first->second; } return accessible; } + +Accessible* Accessible::Get(Dali::Actor actor) +{ + auto accessible = Accessible::GetOwningPtr(actor); + return accessible ? accessible.get() : nullptr; +} \ No newline at end of file