Add null check for mTextureSet.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / accessibility-manager / accessibility-manager-impl.cpp
index 42952e3..e336eee 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 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,7 +25,7 @@
 #include <dali/devel-api/adaptor-framework/sound-player.h>
 #include <dali/public-api/animation/constraints.h>
 #include <dali/devel-api/events/hit-test-algorithm.h>
-#include <dali/public-api/images/resource-image.h>
+#include <dali/devel-api/events/pan-gesture-devel.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
@@ -165,7 +165,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;
@@ -181,7 +181,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];
   }
 
@@ -243,11 +243,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);
   }
 }
 
@@ -257,7 +257,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;
   }
 
@@ -295,7 +295,7 @@ bool AccessibilityManager::SetCurrentFocusActor(Actor actor)
 {
   if(actor)
   {
-    return DoSetCurrentFocusActor(actor.GetId());
+    return DoSetCurrentFocusActor(actor.GetProperty< int >( Actor::Property::ID ));
   }
 
   return false;
@@ -611,7 +611,7 @@ Actor AccessibilityManager::GetFocusIndicatorActor()
 
     mFocusIndicatorActor = Toolkit::ImageView::New(focusBorderImagePath);
     mFocusIndicatorActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
-    mFocusIndicatorActor.SetZ( 1.0f );
+    mFocusIndicatorActor.SetProperty( Actor::Property::POSITION_Z,  1.0f );
 
     // Apply size constraint to the focus indicator
     mFocusIndicatorActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
@@ -964,12 +964,12 @@ bool AccessibilityManager::ClearAccessibilityFocus()
   }
 }
 
-bool AccessibilityManager::AccessibilityActionScroll( Dali::TouchEvent& touchEvent )
+bool AccessibilityManager::AccessibilityActionScroll( Dali::TouchEvent& touch )
 {
   Dali::Toolkit::AccessibilityManager handle( this );
   if( !mActionScrollSignal.Empty() )
   {
-    mActionScrollSignal.Emit( handle, touchEvent );
+    mActionScrollSignal.Emit( handle, touch );
   }
 
   return true;
@@ -1303,26 +1303,11 @@ bool AccessibilityManager::AccessibilityActionStartStop()
   return mIsAccessibilityTtsEnabled;
 }
 
-bool AccessibilityManager::AccessibilityActionTouch(const TouchEvent& touchEvent)
-{
-  bool handled = false;
-
-  // TODO: Need to convert the touchevent for the focused actor?
-
-  Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(GetCurrentFocusActor());
-  if(control)
-  {
-    handled = GetImplementation( control ).OnAccessibilityTouch(touchEvent);
-  }
-
-  return handled;
-}
-
 bool AccessibilityManager::HandlePanGesture(const AccessibilityGestureEvent& panEvent)
 {
   bool handled = false;
 
-  if( panEvent.state == AccessibilityGestureEvent::Started )
+  if( panEvent.state == AccessibilityGestureEvent::STARTED )
   {
     // Find the focusable actor at the event position
     Dali::HitTestAlgorithm::Results results;
@@ -1337,24 +1322,22 @@ bool AccessibilityManager::HandlePanGesture(const AccessibilityGestureEvent& pan
     }
   }
 
-  // Gesture::Finished (Up) events are delivered with previous (Motion) event position
+  // GestureState::FINISHED (Up) events are delivered with previous (Motion) event position
   // Use the real previous position; otherwise we may incorrectly get a ZERO velocity
-  if ( AccessibilityGestureEvent::Finished != panEvent.state )
+  if ( AccessibilityGestureEvent::FINISHED != panEvent.state )
   {
-    // Store the previous position for next Gesture::Finished iteration.
+    // Store the previous position for next GestureState::FINISHED iteration.
     mPreviousPosition = panEvent.previousPosition;
   }
 
   Actor rootActor = Stage::GetCurrent().GetRootLayer();
 
-  Dali::PanGesture pan( static_cast<Dali::Gesture::State>(panEvent.state) );
-
-  pan.time = panEvent.time;
-  pan.numberOfTouches = panEvent.numberOfTouches;
-  pan.screenPosition = panEvent.currentPosition;
-  pan.screenDisplacement = mPreviousPosition - panEvent.currentPosition;
-  pan.screenVelocity.x = pan.screenDisplacement.x / panEvent.timeDelta;
-  pan.screenVelocity.y = pan.screenDisplacement.y / panEvent.timeDelta;
+  Dali::PanGesture pan = DevelPanGesture::New( static_cast<Dali::GestureState>(panEvent.state) );
+  DevelPanGesture::SetTime( pan, panEvent.time );
+  DevelPanGesture::SetNumberOfTouches( pan, panEvent.numberOfTouches  );
+  DevelPanGesture::SetScreenPosition( pan, panEvent.currentPosition );
+  DevelPanGesture::SetScreenDisplacement( pan, mPreviousPosition - panEvent.currentPosition );
+  DevelPanGesture::SetScreenVelocity( pan, Vector2( pan.GetScreenDisplacement().x / panEvent.timeDelta, pan.GetScreenDisplacement().y / panEvent.timeDelta ) );
 
   // Only handle the pan gesture when the current focused actor is scrollable or within a scrollable actor
   while(mCurrentGesturedActor && mCurrentGesturedActor != rootActor && !handled)
@@ -1364,14 +1347,13 @@ bool AccessibilityManager::HandlePanGesture(const AccessibilityGestureEvent& pan
     {
       Vector2 localCurrent;
       control.ScreenToLocal( localCurrent.x, localCurrent.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
-      pan.position = localCurrent;
+      DevelPanGesture::SetPosition( pan, localCurrent );
 
       Vector2 localPrevious;
       control.ScreenToLocal( localPrevious.x, localPrevious.y, mPreviousPosition.x, mPreviousPosition.y );
 
-      pan.displacement = localCurrent - localPrevious;
-      pan.velocity.x = pan.displacement.x / panEvent.timeDelta;
-      pan.velocity.y = pan.displacement.y / panEvent.timeDelta;
+      DevelPanGesture::SetDisplacement( pan, localCurrent - localPrevious );
+      DevelPanGesture::SetVelocity( pan, Vector2( pan.GetDisplacement().x / panEvent.timeDelta, pan.GetDisplacement().y / panEvent.timeDelta ));
 
       handled = GetImplementation( control ).OnAccessibilityPan(pan);
     }