X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Faccessibility-manager%2Faccessibility-manager-impl.cpp;h=deafb5335dab275dc0c0596737b16039749d6115;hb=ad110f27c01af7e617df158891eef5cf60bf22e6;hp=6562a45d6dd4dedb662b3038ae5c4bfb0ef22a2a;hpb=4c9152e53ad2cc0f85c35288599c103192ed98d6;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 6562a45..deafb53 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,6 +29,7 @@ #include // INTERNAL INCLUDES +#include #include #include #include @@ -58,10 +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.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 +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.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 +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,19 +709,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 +721,7 @@ bool AccessibilityManager::ChangeAccessibilityStatus() Actor actor = GetCurrentFocusActor(); if(actor) { - if(mFocusIndicatorActor) - { - actor.Add(mFocusIndicatorActor); - } + actor.Add( GetFocusIndicatorActor() ); } mIsFocusIndicatorEnabled = true; @@ -701,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; @@ -1227,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 ); @@ -1298,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; @@ -1319,7 +1339,7 @@ bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& // 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 +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;