X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Faccessibility-manager%2Faccessibility-manager-impl.cpp;h=6b4433d2c35f919b2262e7bce1cd76be4a4400d0;hb=da6b7205afe6a54fb1caf7a765008948a57f45eb;hp=a3eac2cb77613c41227b7dd200f1783878699699;hpb=8e902a37f200809376dc5746e0bcb9d40dd79049;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp index a3eac2c..6b4433d 100644 --- a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp +++ b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -25,10 +25,10 @@ #include #include #include -#include #include // INTERNAL INCLUDES +#include #include #include #include @@ -58,10 +58,10 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_FOC const char* const ACTOR_FOCUSABLE("focusable"); const char* const IS_FOCUS_GROUP("isFocusGroup"); -const char* FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "B16-8_TTS_focus.9.png"; +const char* FOCUS_BORDER_IMAGE_FILE_NAME = "B16-8_TTS_focus.9.png"; -const char* FOCUS_SOUND_FILE = DALI_SOUND_DIR "Focus.ogg"; -const char* FOCUS_CHAIN_END_SOUND_FILE = DALI_SOUND_DIR "End_of_List.ogg"; +const char* FOCUS_SOUND_FILE_NAME = "Focus.ogg"; +const char* FOCUS_CHAIN_END_SOUND_FILE_NAME = "End_of_List.ogg"; /** * The function to be used in the hit-test algorithm to check whether the actor is hittable. @@ -75,8 +75,8 @@ bool IsActorFocusableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType case Dali::HitTestAlgorithm::CHECK_ACTOR: { // Check whether the actor is visible and not fully transparent. - if( actor.IsVisible() - && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT + if( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) + && actor.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ).a > 0.01f) // not FULLY_TRANSPARENT { // Check whether the actor is focusable Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE); @@ -89,7 +89,7 @@ bool IsActorFocusableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType } case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE: { - if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible. + if( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) ) // Actor is visible, if not visible then none of its children are visible. { hittable = true; } @@ -108,8 +108,12 @@ bool IsActorFocusableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType AccessibilityManager::AccessibilityManager() : mCurrentFocusActor(FocusIDPair(0, 0)), - mFocusIndicatorActor(Actor()), + mCurrentGesturedActor(), + mFocusIndicatorActor(), + mPreviousPosition( 0.0f, 0.0f ), mRecursiveFocusMoveCounter(0), + mFocusSoundFilePath(), + mFocusChainEndSoundFilePath(), mIsWrapped(false), mIsFocusWithinGroup(false), mIsEndcapFeedbackEnabled(false), @@ -117,7 +121,9 @@ AccessibilityManager::AccessibilityManager() mIsAccessibilityTtsEnabled(false), mTtsCreated(false), mIsFocusIndicatorEnabled(false), - mContinuousPlayMode(false) + mContinuousPlayMode(false), + mIsFocusSoundFilePathSet(false), + mIsFocusChainEndSoundFilePathSet(false) { } @@ -127,8 +133,6 @@ AccessibilityManager::~AccessibilityManager() void AccessibilityManager::Initialise() { - CreateDefaultFocusIndicatorActor(); - AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); adaptor.SetActionHandler(*this); adaptor.SetGestureHandler(*this); @@ -160,7 +164,7 @@ void AccessibilityManager::SetAccessibilityAttribute(Actor actor, Toolkit::Acces { if(actor) { - unsigned int actorID = actor.GetId(); + unsigned int actorID = actor.GetProperty< int >( Actor::Property::ID ); ActorAdditionalInfo info = GetActorAdditionalInfo(actorID); info.mAccessibilityAttributes[type] = text; @@ -176,7 +180,7 @@ std::string AccessibilityManager::GetAccessibilityAttribute(Actor actor, Toolkit if(actor) { - ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId()); + ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetProperty< int >( Actor::Property::ID )); text = data.mAccessibilityAttributes[type]; } @@ -238,11 +242,11 @@ void AccessibilityManager::SetFocusOrder(Actor actor, const unsigned int order) actor.SetProperty(propertyActorFocusable, true); // Now we insert the actor into the focus chain with the specified focus order - mFocusIDContainer.insert(FocusIDPair(order, actor.GetId())); + mFocusIDContainer.insert(FocusIDPair(order, actor.GetProperty< int >( Actor::Property::ID ))); } // Update the actor's focus order in its additional data - SynchronizeActorAdditionalInfo(actor.GetId(), order); + SynchronizeActorAdditionalInfo(actor.GetProperty< int >( Actor::Property::ID ), order); } } @@ -252,7 +256,7 @@ unsigned int AccessibilityManager::GetFocusOrder(Actor actor) const if(actor) { - ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId()); + ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetProperty< int >( Actor::Property::ID )); focusOrder = data.mFocusOrder; } @@ -290,7 +294,7 @@ bool AccessibilityManager::SetCurrentFocusActor(Actor actor) { if(actor) { - return DoSetCurrentFocusActor(actor.GetId()); + return DoSetCurrentFocusActor(actor.GetProperty< int >( Actor::Property::ID )); } return false; @@ -326,24 +330,24 @@ bool AccessibilityManager::DoSetCurrentFocusActor(const unsigned int actorID) } // Go through the actor's hierarchy to check whether the actor is visible - bool actorVisible = actor.IsVisible(); + bool actorVisible = actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ); Actor parent = actor.GetParent(); while (actorVisible && parent && parent != rootActor) { - actorVisible = parent.IsVisible(); + actorVisible = parent.GetCurrentProperty< bool >( Actor::Property::VISIBLE ); parent = parent.GetParent(); } // Check whether the actor is fully transparent - bool actorOpaque = actor.GetCurrentWorldColor().a > 0.01f; + bool actorOpaque = actor.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ).a > 0.01f; // Set the focus only when the actor is focusable and visible and not fully transparent if(actorVisible && actorFocusable && actorOpaque) { // Draw the focus indicator upon the focused actor - if(mIsFocusIndicatorEnabled && mFocusIndicatorActor) + if( mIsFocusIndicatorEnabled ) { - actor.Add(mFocusIndicatorActor); + actor.Add( GetFocusIndicatorActor() ); } // Send notification for the change of focus actor @@ -357,7 +361,13 @@ bool AccessibilityManager::DoSetCurrentFocusActor(const unsigned int actorID) Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get(); if(soundPlayer) { - soundPlayer.PlaySound(FOCUS_SOUND_FILE); + if (!mIsFocusSoundFilePathSet) + { + const std::string soundDirPath = AssetManager::GetDaliSoundPath(); + mFocusSoundFilePath = soundDirPath + FOCUS_SOUND_FILE_NAME; + mIsFocusSoundFilePathSet = true; + } + soundPlayer.PlaySound(mFocusSoundFilePath); } // Play the accessibility attributes with the TTS player. @@ -479,9 +489,9 @@ void AccessibilityManager::DoActivate(Actor actor) void AccessibilityManager::ClearFocus() { Actor actor = GetCurrentFocusActor(); - if(actor) + if( actor && mFocusIndicatorActor ) { - actor.Remove(mFocusIndicatorActor); + actor.Remove( mFocusIndicatorActor ); } mCurrentFocusActor = FocusIDPair(0, 0); @@ -569,11 +579,43 @@ bool AccessibilityManager::GetWrapMode() const void AccessibilityManager::SetFocusIndicatorActor(Actor indicator) { - mFocusIndicatorActor = indicator; + if( mFocusIndicatorActor != indicator ) + { + Actor currentFocusActor = GetCurrentFocusActor(); + if( currentFocusActor ) + { + // The new focus indicator should be added to the current focused actor immediately + if( mFocusIndicatorActor ) + { + currentFocusActor.Remove( mFocusIndicatorActor ); + } + + if( indicator ) + { + currentFocusActor.Add( indicator ); + } + } + + mFocusIndicatorActor = indicator; + } } Actor AccessibilityManager::GetFocusIndicatorActor() { + if( ! mFocusIndicatorActor ) + { + // Create the default if it hasn't been set and one that's shared by all the keyboard focusable actors + const std::string imageDirPath = AssetManager::GetDaliImagePath(); + const std::string focusBorderImagePath = imageDirPath + FOCUS_BORDER_IMAGE_FILE_NAME; + + mFocusIndicatorActor = Toolkit::ImageView::New(focusBorderImagePath); + mFocusIndicatorActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + mFocusIndicatorActor.SetProperty( Actor::Property::POSITION_Z, 1.0f ); + + // Apply size constraint to the focus indicator + mFocusIndicatorActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + } + return mFocusIndicatorActor; } @@ -593,7 +635,13 @@ bool AccessibilityManager::DoMoveFocus(FocusIDIter focusIDIter, bool forward, bo Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get(); if(soundPlayer) { - soundPlayer.PlaySound(FOCUS_CHAIN_END_SOUND_FILE); + if (!mIsFocusChainEndSoundFilePathSet) + { + const std::string soundDirPath = AssetManager::GetDaliSoundPath(); + mFocusChainEndSoundFilePath = soundDirPath + FOCUS_CHAIN_END_SOUND_FILE_NAME; + mIsFocusChainEndSoundFilePathSet = true; + } + soundPlayer.PlaySound(mFocusChainEndSoundFilePath); } mIsEndcapFeedbackPlayed = true; @@ -660,19 +708,6 @@ void AccessibilityManager::SetFocusable(Actor actor, bool focusable) } } -void AccessibilityManager::CreateDefaultFocusIndicatorActor() -{ - // Create a focus indicator actor shared by all the focusable actors - Toolkit::ImageView focusIndicator = Toolkit::ImageView::New(FOCUS_BORDER_IMAGE_PATH); - focusIndicator.SetParentOrigin( ParentOrigin::CENTER ); - focusIndicator.SetPosition(Vector3(0.0f, 0.0f, 1.0f)); - - // Apply size constraint to the focus indicator - focusIndicator.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - SetFocusIndicatorActor(focusIndicator); -} - bool AccessibilityManager::ChangeAccessibilityStatus() { AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); @@ -685,10 +720,7 @@ bool AccessibilityManager::ChangeAccessibilityStatus() Actor actor = GetCurrentFocusActor(); if(actor) { - if(mFocusIndicatorActor) - { - actor.Add(mFocusIndicatorActor); - } + actor.Add( GetFocusIndicatorActor() ); } mIsFocusIndicatorEnabled = true; @@ -701,9 +733,9 @@ bool AccessibilityManager::ChangeAccessibilityStatus() { // Hide indicator when tts turned off Actor actor = GetCurrentFocusActor(); - if(actor) + if( actor && mFocusIndicatorActor ) { - actor.Remove(mFocusIndicatorActor); + actor.Remove( mFocusIndicatorActor ); } mIsFocusIndicatorEnabled = false; @@ -1227,19 +1259,6 @@ bool AccessibilityManager::AccessibilityActionZoom() return ret; } -bool AccessibilityManager::AccessibilityActionReadIndicatorInformation() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionReadIndicatorInformationSignal.Empty() ) - { - mActionReadIndicatorInformationSignal.Emit( handle ); - } - - // TODO: Read the information in the indicator - - return mIsAccessibilityTtsEnabled; -} - bool AccessibilityManager::AccessibilityActionReadPauseResume() { Dali::Toolkit::AccessibilityManager handle( this ); @@ -1298,11 +1317,11 @@ bool AccessibilityManager::AccessibilityActionTouch(const TouchEvent& touchEvent return handled; } -bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& panEvent) +bool AccessibilityManager::HandlePanGesture(const AccessibilityGestureEvent& panEvent) { bool handled = false; - if( panEvent.state == Gesture::Started ) + if( panEvent.state == AccessibilityGestureEvent::Started ) { // Find the focusable actor at the event position Dali::HitTestAlgorithm::Results results; @@ -1313,13 +1332,13 @@ bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& if(!mCurrentGesturedActor) { - DALI_LOG_ERROR("Gesture detected, but no hit actor"); + DALI_LOG_ERROR("Gesture detected, but no hit actor\n"); } } // Gesture::Finished (Up) events are delivered with previous (Motion) event position // Use the real previous position; otherwise we may incorrectly get a ZERO velocity - if ( Gesture::Finished != panEvent.state ) + if ( AccessibilityGestureEvent::Finished != panEvent.state ) { // Store the previous position for next Gesture::Finished iteration. mPreviousPosition = panEvent.previousPosition; @@ -1327,7 +1346,8 @@ bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& Actor rootActor = Stage::GetCurrent().GetRootLayer(); - Dali::PanGesture pan(panEvent.state); + Dali::PanGesture pan( static_cast(panEvent.state) ); + pan.time = panEvent.time; pan.numberOfTouches = panEvent.numberOfTouches; pan.screenPosition = panEvent.currentPosition; @@ -1362,7 +1382,7 @@ bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& if(!mCurrentGesturedActor) { - DALI_LOG_ERROR("no more gestured actor"); + DALI_LOG_ERROR("no more gestured actor\n"); } } else @@ -1390,34 +1410,6 @@ Toolkit::AccessibilityManager::FocusedActorActivatedSignalType& AccessibilityMan return mFocusedActorActivatedSignal; } -bool AccessibilityManager::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) -{ - Dali::BaseHandle handle( object ); - - bool connected( true ); - AccessibilityManager* manager = dynamic_cast( object ); - - if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_CHANGED ) ) - { - manager->FocusChangedSignal().Connect( tracker, functor ); - } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_OVERSHOT ) ) - { - manager->FocusOvershotSignal().Connect( tracker, functor ); - } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUSED_ACTOR_ACTIVATED ) ) - { - manager->FocusedActorActivatedSignal().Connect( tracker, functor ); - } - else - { - // signalName does not match any signal - connected = false; - } - - return connected; -} - } // namespace Internal } // namespace Toolkit