CMake - Option added to define the default toolkit resource path.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / accessibility-manager / accessibility-manager-impl.cpp
index aee1bc0..7f69861 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 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 <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
 #include <dali-toolkit/public-api/controls/control.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
@@ -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.
@@ -112,6 +113,8 @@ AccessibilityManager::AccessibilityManager()
   mFocusIndicatorActor(),
   mPreviousPosition( 0.0f, 0.0f ),
   mRecursiveFocusMoveCounter(0),
+  mFocusSoundFilePath(),
+  mFocusChainEndSoundFilePath(),
   mIsWrapped(false),
   mIsFocusWithinGroup(false),
   mIsEndcapFeedbackEnabled(false),
@@ -119,7 +122,9 @@ AccessibilityManager::AccessibilityManager()
   mIsAccessibilityTtsEnabled(false),
   mTtsCreated(false),
   mIsFocusIndicatorEnabled(false),
-  mContinuousPlayMode(false)
+  mContinuousPlayMode(false),
+  mIsFocusSoundFilePathSet(false),
+  mIsFocusChainEndSoundFilePathSet(false)
 {
 }
 
@@ -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.
@@ -595,7 +606,10 @@ 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
-    mFocusIndicatorActor = Toolkit::ImageView::New( FOCUS_BORDER_IMAGE_PATH );
+    const std::string imageDirPath = AssetManager::GetDaliImagePath();
+    const std::string focusBorderImagePath = imageDirPath + FOCUS_BORDER_IMAGE_FILE_NAME;
+
+    mFocusIndicatorActor = Toolkit::ImageView::New(focusBorderImagePath);
     mFocusIndicatorActor.SetParentOrigin( ParentOrigin::CENTER );
     mFocusIndicatorActor.SetZ( 1.0f );
 
@@ -622,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;
@@ -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<Dali::Gesture::State>(panEvent.state) );
+
   pan.time = panEvent.time;
   pan.numberOfTouches = panEvent.numberOfTouches;
   pan.screenPosition = panEvent.currentPosition;