Make -DUSE_DEFAULT_RESOURCE_DIR=OFF compile again
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / control / control-data-impl.cpp
index 4d7c6e4..83cc802 100755 (executable)
@@ -47,6 +47,7 @@
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
 
 namespace
 {
@@ -189,71 +190,64 @@ void MoveVisual( RegisteredVisualContainer::Iterator sourceIter, RegisteredVisua
  * @param[in] attributes The attributes with which to perfrom this action.
  * @return true if action has been accepted by this control
  */
-const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated";
-const char* ACTION_ACCESSIBILITY_READING_SKIPPED = "ReadingSkipped";
+const char* ACTION_ACCESSIBILITY_ACTIVATED         = "accessibilityActivated";
 const char* ACTION_ACCESSIBILITY_READING_CANCELLED = "ReadingCancelled";
-const char* ACTION_ACCESSIBILITY_READING_STOPPED = "ReadingStopped";
+const char* ACTION_ACCESSIBILITY_READING_PAUSED    = "ReadingPaused";
+const char* ACTION_ACCESSIBILITY_READING_RESUMED   = "ReadingResumed";
+const char* ACTION_ACCESSIBILITY_READING_SKIPPED   = "ReadingSkipped";
+const char* ACTION_ACCESSIBILITY_READING_STOPPED   = "ReadingStopped";
 
 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
 {
-  bool ret = false;
+  bool ret = true;
 
-  if( object &&
-      ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ||
-        actionName == "activate" ) )
+  Dali::BaseHandle handle( object );
+
+  Toolkit::Control control = Toolkit::Control::DownCast( handle );
+
+  DALI_ASSERT_ALWAYS( control );
+
+  if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ||
+     actionName == "activate" )
   {
-    Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
-    if( control )
-    {
-      // if cast succeeds there is an implementation so no need to check
-      if (!DevelControl::AccessibilityActivateSignal( control ).Empty()) {
-        DevelControl::AccessibilityActivateSignal( control ).Emit();
-        ret = true;
-      }
-      else
-        ret = Internal::GetImplementation( control ).OnAccessibilityActivated();
-    }
+    // if cast succeeds there is an implementation so no need to check
+    if( !DevelControl::AccessibilityActivateSignal( control ).Empty() )
+      DevelControl::AccessibilityActivateSignal( control ).Emit();
+    else ret = Internal::GetImplementation( control ).OnAccessibilityActivated();
   }
-  else if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_SKIPPED ) ) )
+  else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_SKIPPED ) )
   {
-    Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
-    if( control )
-    {
-      // if cast succeeds there is an implementation so no need to check
-      if (!DevelControl::AccessibilityReadingSkippedSignal( control ).Empty())
-      {
-        DevelControl::AccessibilityReadingSkippedSignal( control ).Emit();
-        ret = true;
-      }
-    }
+    // if cast succeeds there is an implementation so no need to check
+    if( !DevelControl::AccessibilityReadingSkippedSignal( control ).Empty() )
+      DevelControl::AccessibilityReadingSkippedSignal( control ).Emit();
   }
-  else if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_CANCELLED ) ) )
+  else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_PAUSED ) )
   {
-    Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
-    if( control )
-    {
-      // if cast succeeds there is an implementation so no need to check
-      if (!DevelControl::AccessibilityReadingCancelledSignal( control ).Empty())
-      {
-        DevelControl::AccessibilityReadingCancelledSignal( control ).Emit();
-        ret = true;
-      }
-    }
+    // if cast succeeds there is an implementation so no need to check
+    if( !DevelControl::AccessibilityReadingPausedSignal( control ).Empty() )
+      DevelControl::AccessibilityReadingPausedSignal( control ).Emit();
   }
-  else if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_STOPPED ) ) )
+  else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_RESUMED ) )
   {
-    Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
-    if( control )
-    {
-      // if cast succeeds there is an implementation so no need to check
-      if (!DevelControl::AccessibilityReadingStoppedSignal( control ).Empty())
-      {
-        DevelControl::AccessibilityReadingStoppedSignal( control ).Emit();
-        ret = true;
-      }
-    }
+    // if cast succeeds there is an implementation so no need to check
+    if( !DevelControl::AccessibilityReadingResumedSignal( control ).Empty() )
+      DevelControl::AccessibilityReadingResumedSignal( control ).Emit();
+  }
+  else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_CANCELLED ) )
+  {
+    // if cast succeeds there is an implementation so no need to check
+    if( !DevelControl::AccessibilityReadingCancelledSignal( control ).Empty() )
+      DevelControl::AccessibilityReadingCancelledSignal( control ).Emit();
+  }
+  else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_STOPPED ) )
+  {
+    // if cast succeeds there is an implementation so no need to check
+    if(!DevelControl::AccessibilityReadingStoppedSignal( control ).Empty())
+      DevelControl::AccessibilityReadingStoppedSignal( control ).Emit();
+  } else
+  {
+    ret = false;
   }
-
   return ret;
 }
 
@@ -364,6 +358,8 @@ TypeAction registerAction2( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &D
 TypeAction registerAction3( typeRegistration, ACTION_ACCESSIBILITY_READING_SKIPPED, &DoAction );
 TypeAction registerAction4( typeRegistration, ACTION_ACCESSIBILITY_READING_CANCELLED, &DoAction );
 TypeAction registerAction5( typeRegistration, ACTION_ACCESSIBILITY_READING_STOPPED, &DoAction );
+TypeAction registerAction6( typeRegistration, ACTION_ACCESSIBILITY_READING_PAUSED, &DoAction );
+TypeAction registerAction7( typeRegistration, ACTION_ACCESSIBILITY_READING_RESUMED, &DoAction );
 
 DALI_TYPE_REGISTRATION_END()
 
@@ -464,6 +460,16 @@ Control::Impl::Impl( Control& controlImpl )
 
 Control::Impl::~Impl()
 {
+  for( auto&& iter : mVisuals )
+  {
+    StopObservingVisual( iter->visual );
+  }
+
+  for( auto&& iter : mRemoveVisuals )
+  {
+    StopObservingVisual( iter->visual );
+  }
+
   AccessibilityDeregister();
   // All gesture detectors will be destroyed so no need to disconnect.
   delete mStartingPinchScale;
@@ -1212,13 +1218,21 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons
 
       case Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES:
       {
-        value.Get( controlImpl.mImpl->mAccessibilityAttributes );
+        const Property::Map* map = value.GetMap();
+        if( map && !map->Empty() )
+        {
+          controlImpl.mImpl->mAccessibilityAttributes = *map;
+        }
         break;
       }
 
       case Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED:
       {
-        value.Get( controlImpl.mImpl->mAccessibilityAnimated );
+        bool animated;
+        if( value.Get( animated ) )
+        {
+          controlImpl.mImpl->mAccessibilityAnimated = animated;
+        }
         break;
       }
     }
@@ -1889,6 +1903,32 @@ Control::Impl::AccessibleImpl::AccessibleImpl(Dali::Actor self, Dali::Accessibil
   Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl );
   if( controlImpl.mAccessibilityRole == Dali::Accessibility::Role::UNKNOWN )
     controlImpl.mAccessibilityRole = role;
+
+  self.PropertySetSignal().Connect(&controlImpl, [this, &controlImpl](Dali::Handle &handle, Dali::Property::Index index, Dali::Property::Value value)
+  {
+    if (this->self != Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor())
+    {
+      return;
+    }
+
+    if (index == DevelControl::Property::ACCESSIBILITY_NAME
+      || (index == GetNamePropertyIndex() && !controlImpl.mAccessibilityNameSet))
+    {
+      if (controlImpl.mAccessibilityGetNameSignal.Empty())
+      {
+        Emit(Dali::Accessibility::ObjectPropertyChangeEvent::NAME);
+      }
+    }
+
+    if (index == DevelControl::Property::ACCESSIBILITY_DESCRIPTION
+      || (index == GetDescriptionPropertyIndex() && !controlImpl.mAccessibilityDescriptionSet))
+    {
+      if (controlImpl.mAccessibilityGetDescriptionSignal.Empty())
+      {
+        Emit(Dali::Accessibility::ObjectPropertyChangeEvent::DESCRIPTION);
+      }
+    }
+  });
 }
 
 std::string Control::Impl::AccessibleImpl::GetName()
@@ -1984,19 +2024,21 @@ Dali::Accessibility::States Control::Impl::AccessibleImpl::CalculateStates()
   s[Dali::Accessibility::State::FOCUSABLE] = self.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE );
   s[Dali::Accessibility::State::FOCUSED] = Toolkit::KeyboardFocusManager::Get().GetCurrentFocusActor() == self;
   if(self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE ).GetType() == Property::NONE )
-    s[Dali::Accessibility::State::HIGHLIGHTABLE] = true;
+    s[Dali::Accessibility::State::HIGHLIGHTABLE] = false;
   else
     s[Dali::Accessibility::State::HIGHLIGHTABLE] = self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE ).Get< bool >();
   s[Dali::Accessibility::State::HIGHLIGHTED] = GetCurrentlyHighlightedActor() == self;
   s[Dali::Accessibility::State::ENABLED] = true;
   s[Dali::Accessibility::State::SENSITIVE] = true;
   s[Dali::Accessibility::State::ANIMATED] = self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED ).Get< bool >();
-  s[Dali::Accessibility::State::VISIBLE] = self.GetCurrentProperty< bool >( Actor::Property::VISIBLE );
+  s[Dali::Accessibility::State::VISIBLE] = true;
   if( modal )
   {
     s[Dali::Accessibility::State::MODAL] = true;
   }
-  s[Dali::Accessibility::State::SHOWING] = !self.GetProperty( Dali::DevelActor::Property::CULLED ).Get< bool >();
+  s[Dali::Accessibility::State::SHOWING] = !self.GetProperty( Dali::DevelActor::Property::CULLED ).Get< bool >()
+                                         && self.GetCurrentProperty< bool >( Actor::Property::VISIBLE );
+
   s[Dali::Accessibility::State::DEFUNCT] = !self.GetProperty( Dali::DevelActor::Property::CONNECTED_TO_SCENE ).Get< bool >();
   return s;
 }
@@ -2067,14 +2109,13 @@ bool Control::Impl::AccessibleImpl::GrabFocus()
   return Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( self );
 }
 
-const char* const FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "keyboard_focus.9.png";
-
 static Dali::Actor CreateHighlightIndicatorActor()
 {
+  std::string focusBorderImagePath(AssetManager::GetDaliImagePath());
+  focusBorderImagePath += "/keyboard_focus.9.png";
   // Create the default if it hasn't been set and one that's shared by all the
-  // keyboard focusable actors const char* const FOCUS_BORDER_IMAGE_PATH =
-  // DALI_IMAGE_DIR "keyboard_focus.9.png";
-  auto actor = Toolkit::ImageView::New( FOCUS_BORDER_IMAGE_PATH );
+  // keyboard focusable actors
+  auto actor = Toolkit::ImageView::New( focusBorderImagePath );
   actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
   DevelControl::AppendAccessibilityAttribute( actor, "highlight", "" );
   actor.SetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED, true);
@@ -2108,6 +2149,7 @@ bool Control::Impl::AccessibleImpl::GrabHighlight()
   highlight.SetProperty( Actor::Property::POSITION_Z, 1.0f );
   highlight.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ));
 
+  EnsureSelfVisible();
   self.Add( highlight );
   SetCurrentlyHighlightedActor( self );
   EmitHighlighted( true );
@@ -2131,11 +2173,6 @@ bool Control::Impl::AccessibleImpl::ClearHighlight()
   return false;
 }
 
-int Control::Impl::AccessibleImpl::GetHighlightIndex()
-{
-  return 0;
-}
-
 std::string Control::Impl::AccessibleImpl::GetActionName( size_t index )
 {
   if ( index >= GetActionCount() ) return "";
@@ -2211,6 +2248,29 @@ std::vector<Dali::Accessibility::Relation> Control::Impl::AccessibleImpl::GetRel
   return ret;
 }
 
+void Control::Impl::AccessibleImpl::EnsureChildVisible(Actor child)
+{
+}
+
+void Control::Impl::AccessibleImpl::EnsureSelfVisible()
+{
+  auto parent = dynamic_cast<Control::Impl::AccessibleImpl*>(GetParent());
+  if (parent)
+  {
+    parent->EnsureChildVisible(self);
+  }
+}
+
+Property::Index Control::Impl::AccessibleImpl::GetNamePropertyIndex()
+{
+  return Actor::Property::NAME;
+}
+
+Property::Index Control::Impl::AccessibleImpl::GetDescriptionPropertyIndex()
+{
+  return Property::INVALID_INDEX;
+}
+
 void Control::Impl::PositionOrSizeChangedCallback( PropertyNotification &p )
 {
   auto self = Dali::Actor::DownCast(p.GetTarget());