X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Faccessibility-manager%2Faccessibility-manager-impl.cpp;h=42952e38cc3f0b502ed77c8c152cdce43e9b5427;hb=5e937a6322849b76d49d5b3f41cb5d91c94acd3e;hp=15ed9205b5ddcf28e6dab643def2262ae4a253e2;hpb=2c97b9f743493b56e6256fbce8ef5c3e2080572c;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 15ed920..42952e3 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) 2019 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. @@ -29,8 +29,10 @@ #include // INTERNAL INCLUDES +#include #include #include +#include namespace Dali { @@ -57,11 +59,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.png"; -const Vector4 FOCUS_BORDER_IMAGE_BORDER = Vector4(7.0f, 7.0f, 7.0f, 7.0f); +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 +76,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 +90,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 +109,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 +122,9 @@ AccessibilityManager::AccessibilityManager() mIsAccessibilityTtsEnabled(false), mTtsCreated(false), mIsFocusIndicatorEnabled(false), - mContinuousPlayMode(false) + mContinuousPlayMode(false), + mIsFocusSoundFilePathSet(false), + mIsFocusChainEndSoundFilePathSet(false) { } @@ -127,8 +134,6 @@ AccessibilityManager::~AccessibilityManager() void AccessibilityManager::Initialise() { - CreateDefaultFocusIndicatorActor(); - AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); adaptor.SetActionHandler(*this); adaptor.SetGestureHandler(*this); @@ -326,24 +331,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 +362,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 +490,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 +580,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.SetZ( 1.0f ); + + // Apply size constraint to the focus indicator + mFocusIndicatorActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + } + return mFocusIndicatorActor; } @@ -593,7 +636,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,23 +709,6 @@ void AccessibilityManager::SetFocusable(Actor actor, bool focusable) } } -void AccessibilityManager::CreateDefaultFocusIndicatorActor() -{ - // Create a focus indicator actor shared by all the focusable actors - Image borderImage = ResourceImage::New(FOCUS_BORDER_IMAGE_PATH); - - ImageActor focusIndicator = ImageActor::New(borderImage); - focusIndicator.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION ); - focusIndicator.SetStyle( ImageActor::STYLE_NINE_PATCH ); - focusIndicator.SetNinePatchBorder(FOCUS_BORDER_IMAGE_BORDER); - 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(); @@ -689,10 +721,7 @@ bool AccessibilityManager::ChangeAccessibilityStatus() Actor actor = GetCurrentFocusActor(); if(actor) { - if(mFocusIndicatorActor) - { - actor.Add(mFocusIndicatorActor); - } + actor.Add( GetFocusIndicatorActor() ); } mIsFocusIndicatorEnabled = true; @@ -705,9 +734,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; @@ -1231,19 +1260,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 ); @@ -1302,11 +1318,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; @@ -1317,13 +1333,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; @@ -1331,7 +1347,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; @@ -1366,7 +1383,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 @@ -1394,34 +1411,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