X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fcontrols%2Fcontrol-accessible.cpp;h=719657d83b2201bce55d3c3da51fd20c54d158ad;hb=a1d6238d1bb9d8ca13d9bca6a4d58b633b0eb906;hp=ae7eff0553772af4dc3a1e07cac7ebbaa31aa3d7;hpb=f0379552a8e3342b6606f5b64558cd24a7198b6c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/controls/control-accessible.cpp b/dali-toolkit/devel-api/controls/control-accessible.cpp index ae7eff0..719657d 100644 --- a/dali-toolkit/devel-api/controls/control-accessible.cpp +++ b/dali-toolkit/devel-api/controls/control-accessible.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 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. @@ -38,14 +38,14 @@ namespace Dali::Toolkit::DevelControl { namespace { -static std::string GetLocaleText(std::string string, const char *domain = "dali-toolkit") +static std::string GetLocaleText(std::string string, const char* domain = "dali-toolkit") { #ifdef DGETTEXT_ENABLED - /*TODO: currently non-localized string is used as a key for translation lookup. In case the lookup key formatting is forced + /*TODO: currently non-localized string is used as a key for translation lookup. In case the lookup key formatting is forced consider calling utility function for converting non-localized string into well-formatted key before lookup. */ - return dgettext(domain, string.c_str()); + return dgettext(domain, string.c_str()); #else - return string; + return string; #endif } @@ -66,20 +66,15 @@ static Dali::Actor CreateHighlightIndicatorActor() } } // unnamed namespace -ControlAccessible::ControlAccessible(Dali::Actor self, Dali::Accessibility::Role role, bool modal) -: ActorAccessible(self), - mIsModal(modal) +ControlAccessible::ControlAccessible(Dali::Actor self) +: ActorAccessible(self) { - auto control = Dali::Toolkit::Control::DownCast(Self()); + auto control = Toolkit::Control::DownCast(self); Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control); Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get(internalControl); - if(controlImpl.mAccessibilityRole == Dali::Accessibility::Role::UNKNOWN) - { - controlImpl.mAccessibilityRole = role; - } - Self().PropertySetSignal().Connect(&controlImpl, [this, &controlImpl](Dali::Handle& handle, Dali::Property::Index index, Dali::Property::Value value) { + self.PropertySetSignal().Connect(&controlImpl, [this, &controlImpl](Dali::Handle& handle, Dali::Property::Index index, Dali::Property::Value value) { if(this->Self() != Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor()) { return; @@ -109,7 +104,7 @@ std::string ControlAccessible::GetName() const Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control); Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get(internalControl); - std::string name; + std::string name; if(!controlImpl.mAccessibilityGetNameSignal.Empty()) { @@ -147,7 +142,7 @@ std::string ControlAccessible::GetDescription() const Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control); Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get(internalControl); - std::string description; + std::string description; if(!controlImpl.mAccessibilityGetDescriptionSignal.Empty()) { @@ -188,7 +183,7 @@ std::string ControlAccessible::GetLocalizedRoleName() const bool ControlAccessible::IsShowing() { Dali::Actor self = Self(); - if(!self.GetProperty(Actor::Property::VISIBLE) || self.GetProperty(Actor::Property::WORLD_COLOR).a == 0 || self.GetProperty(Dali::DevelActor::Property::CULLED)) + if(!self.GetProperty(Actor::Property::VISIBLE) || Dali::EqualsZero(self.GetProperty(Actor::Property::WORLD_COLOR).a) || self.GetProperty(Dali::DevelActor::Property::CULLED)) { return false; } @@ -203,14 +198,14 @@ bool ControlAccessible::IsShowing() auto childExtent = child->GetExtents(Dali::Accessibility::CoordinateType::WINDOW); while(parent) { - auto control = Dali::Toolkit::Control::DownCast(parent->Self()); + auto control = Dali::Toolkit::Control::DownCast(parent->Self()); if(!control.GetProperty(Actor::Property::VISIBLE)) { return false; } auto clipMode = control.GetProperty(Actor::Property::CLIPPING_MODE).Get(); auto parentExtent = parent->GetExtents(Dali::Accessibility::CoordinateType::WINDOW); - if ((clipMode != ClippingMode::DISABLED) && !parentExtent.Intersects(childExtent)) + if((clipMode != ClippingMode::DISABLED) && !parentExtent.Intersects(childExtent)) { return false; } @@ -222,32 +217,22 @@ bool ControlAccessible::IsShowing() Dali::Accessibility::States ControlAccessible::CalculateStates() { - Dali::Actor self = Self(); - Dali::Accessibility::States state; - state[Dali::Accessibility::State::FOCUSABLE] = self.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE); - state[Dali::Accessibility::State::FOCUSED] = Toolkit::KeyboardFocusManager::Get().GetCurrentFocusActor() == self; + using Dali::Accessibility::State; - if(self.GetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE).GetType() == Dali::Property::NONE) - { - state[Dali::Accessibility::State::HIGHLIGHTABLE] = false; - } - else - { - state[Dali::Accessibility::State::HIGHLIGHTABLE] = self.GetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE).Get(); - } + Dali::Actor self = Self(); + Dali::Accessibility::States states; - state[Dali::Accessibility::State::HIGHLIGHTED] = GetCurrentlyHighlightedActor() == self; - state[Dali::Accessibility::State::ENABLED] = true; - state[Dali::Accessibility::State::SENSITIVE] = true; - state[Dali::Accessibility::State::VISIBLE] = self.GetProperty(Actor::Property::VISIBLE); + states[State::FOCUSABLE] = self.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE); + states[State::FOCUSED] = Toolkit::KeyboardFocusManager::Get().GetCurrentFocusActor() == self; + states[State::HIGHLIGHTABLE] = self.GetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE); + states[State::HIGHLIGHTED] = GetCurrentlyHighlightedActor() == self; + states[State::ENABLED] = true; + states[State::SENSITIVE] = true; + states[State::VISIBLE] = self.GetProperty(Actor::Property::VISIBLE); + states[State::SHOWING] = IsShowing(); + states[State::DEFUNCT] = !self.GetProperty(Dali::DevelActor::Property::CONNECTED_TO_SCENE).Get(); - if(mIsModal) - { - state[Dali::Accessibility::State::MODAL] = true; - } - state[Dali::Accessibility::State::SHOWING] = IsShowing(); - state[Dali::Accessibility::State::DEFUNCT] = !self.GetProperty(Dali::DevelActor::Property::CONNECTED_TO_SCENE).Get(); - return state; + return states; } Dali::Accessibility::States ControlAccessible::GetStates() @@ -258,9 +243,9 @@ Dali::Accessibility::States ControlAccessible::GetStates() Dali::Accessibility::Attributes ControlAccessible::GetAttributes() const { std::unordered_map attributeMap; - auto control = Dali::Toolkit::Control::DownCast(Self()); - auto attribute = control.GetProperty(Dali::Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES); - auto map = attribute.GetMap(); + auto control = Dali::Toolkit::Control::DownCast(Self()); + auto attribute = control.GetProperty(Dali::Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES); + auto map = attribute.GetMap(); if(map) { @@ -280,6 +265,12 @@ Dali::Accessibility::Attributes ControlAccessible::GetAttributes() const } } + auto automationId = control.GetProperty(Dali::Toolkit::DevelControl::Property::AUTOMATION_ID); + if(!automationId.empty()) + { + attributeMap.emplace("automationId", std::move(automationId)); + } + return attributeMap; } @@ -300,12 +291,12 @@ bool ControlAccessible::GrabFocus() void ControlAccessible::ScrollToSelf() { - auto* child = this; + auto* child = this; auto* parent = dynamic_cast(child->GetParent()); - while (parent) + while(parent) { - if (parent->IsScrollable()) + if(parent->IsScrollable()) { parent->ScrollToChild(child->Self()); } @@ -332,8 +323,8 @@ void ControlAccessible::UnregisterPositionPropertyNotification() bool ControlAccessible::GrabHighlight() { - Dali::Actor self = Self(); - auto oldHighlightedActor = GetCurrentlyHighlightedActor(); + Dali::Actor self = Self(); + auto oldHighlightedActor = GetCurrentlyHighlightedActor(); if(!Dali::Accessibility::IsUp()) { @@ -348,10 +339,10 @@ bool ControlAccessible::GrabHighlight() // Clear the old highlight. if(oldHighlightedActor) { - auto oldHighlightObject = dynamic_cast(Internal::Control::Impl::GetAccessibilityObject(oldHighlightedActor)); - if(oldHighlightObject) + auto oldHighlightedObject = Dali::Accessibility::Component::DownCast(Accessible::Get(oldHighlightedActor)); + if(oldHighlightedObject) { - oldHighlightObject->ClearHighlight(); + oldHighlightedObject->ClearHighlight(); } } @@ -472,24 +463,7 @@ std::vector ControlAccessible::GetRelationSet() { auto control = Dali::Toolkit::Control::DownCast(Self()); - Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control); - Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get(internalControl); - - std::vector ret; - - for(auto& relation : controlImpl.mAccessibilityRelations) - { - auto& targets = relation.second; - - ret.emplace_back(Accessibility::Relation{relation.first, {}}); - - // Map every Accessible* to its Address - std::transform(targets.begin(), targets.end(), std::back_inserter(ret.back().targets), [](auto* x) { - return x->GetAddress(); - }); - } - - return ret; + return DevelControl::GetAccessibilityRelations(control); } bool ControlAccessible::ScrollToChild(Actor child)