Merge "Make -DUSE_DEFAULT_RESOURCE_DIR=OFF compile again" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 23 Dec 2020 17:11:58 +0000 (17:11 +0000)
committerGerrit Code Review <gerrit@review>
Wed, 23 Dec 2020 17:11:58 +0000 (17:11 +0000)
1  2 
dali-toolkit/internal/controls/control/control-data-impl.cpp

@@@ -47,6 -47,7 +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
  {
@@@ -104,30 -105,25 +105,30 @@@ void Remove( DictionaryKeys& keys, cons
    }
  }
  
 -Toolkit::Visual::Type GetVisualTypeFromMap( const Property::Map& map )
 +/**
 + *  Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
 + */
 +bool FindVisual( Property::Index targetIndex, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter )
  {
 -  Property::Value* typeValue = map.Find( Toolkit::Visual::Property::TYPE, VISUAL_TYPE  );
 -  Toolkit::Visual::Type type = Toolkit::Visual::IMAGE;
 -  if( typeValue )
 +  for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
    {
 -    Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, type );
 +    if ( (*iter)->index ==  targetIndex )
 +    {
 +      return true;
 +    }
    }
 -  return type;
 +  return false;
  }
  
  /**
   *  Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
   */
 -bool FindVisual( Property::Index targetIndex, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter )
 +bool FindVisual( std::string visualName, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter )
  {
    for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
    {
 -    if ( (*iter)->index ==  targetIndex )
 +    Toolkit::Visual::Base visual = (*iter)->visual;
 +    if( visual && visual.GetName() == visualName )
      {
        return true;
      }
@@@ -174,24 -170,6 +175,24 @@@ Toolkit::Visual::Base GetVisualByName
    return visualHandle;
  }
  
 +Toolkit::Visual::Base GetVisualByIndex(
 +  const RegisteredVisualContainer& visuals,
 +  Property::Index                  index)
 +{
 +  Toolkit::Visual::Base visualHandle;
 +
 +  RegisteredVisualContainer::Iterator iter;
 +  for(iter = visuals.Begin(); iter != visuals.End(); iter++)
 +  {
 +    if((*iter)->index == index)
 +    {
 +      visualHandle = (*iter)->visual;
 +      break;
 +    }
 +  }
 +  return visualHandle;
 +}
 +
  /**
   * Move visual from source to destination container
   */
@@@ -1563,47 -1541,59 +1564,47 @@@ void Control::Impl::RecreateChangedVisu
      const std::string& visualName = (*iter).key;
      const Property::Map& toMap = (*iter).entry;
  
 -    // is it a candidate for re-creation?
 -    bool recreate = false;
 -
 -    Toolkit::Visual::Base visual = GetVisualByName( mVisuals, visualName );
 -    if( visual )
 +    Actor self = mControlImpl.Self();
 +    RegisteredVisualContainer::Iterator registeredVisualsiter;
 +    // Check if visual (visualName) is already registered, this is the current visual.
 +    if(FindVisual(visualName, mVisuals, registeredVisualsiter))
      {
 -      Property::Map fromMap;
 -      visual.CreatePropertyMap( fromMap );
 -
 -      Toolkit::Visual::Type fromType = GetVisualTypeFromMap( fromMap );
 -      Toolkit::Visual::Type toType = GetVisualTypeFromMap( toMap );
 -
 -      if( fromType != toType )
 +      Toolkit::Visual::Base& visual = (*registeredVisualsiter)->visual;
 +      if(visual)
        {
 -        recreate = true;
 -      }
 -      else
 -      {
 -        if( fromType == Toolkit::Visual::IMAGE || fromType == Toolkit::Visual::N_PATCH
 -            || fromType == Toolkit::Visual::SVG || fromType == Toolkit::Visual::ANIMATED_IMAGE )
 -        {
 -          Property::Value* fromUrl = fromMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
 -          Property::Value* toUrl = toMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
 +        // No longer required to know if the replaced visual's resources are ready
 +        StopObservingVisual(visual);
  
 -          if( fromUrl && toUrl )
 +        // If control staged then visuals will be swapped once ready
 +        if(self.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
 +        {
 +          // Check if visual is currently in the process of being replaced ( is in removal container )
 +          RegisteredVisualContainer::Iterator visualQueuedForRemoval;
 +          if(FindVisual(visualName, mRemoveVisuals, visualQueuedForRemoval))
            {
 -            std::string fromUrlString;
 -            std::string toUrlString;
 -            fromUrl->Get(fromUrlString);
 -            toUrl->Get(toUrlString);
 -
 -            if( fromUrlString != toUrlString )
 -            {
 -              recreate = true;
 -            }
 +            // Visual with same visual name is already in removal container so current visual pending
 +            // Only the the last requested visual will be displayed so remove current visual which is staged but not ready.
 +            Toolkit::GetImplementation(visual).SetOffScene(self);
 +            (*registeredVisualsiter)->visual.Reset();
 +            mVisuals.Erase(registeredVisualsiter);
 +          }
 +          else
 +          {
 +            // current visual not already in removal container so add now.
 +            DALI_LOG_INFO(gLogFilter, Debug::Verbose, "RegisterVisual Move current registered visual to removal Queue: %s \n", visualName.c_str());
 +            MoveVisual(registeredVisualsiter, mVisuals, mRemoveVisuals);
            }
          }
 +        else
 +        {
 +          // Control not staged or visual disabled so can just erase from registered visuals and new visual will be added later.
 +          (*registeredVisualsiter)->visual.Reset();
 +          mVisuals.Erase(registeredVisualsiter);
 +        }
        }
  
 -      const Property::Map* instancedMap = instancedProperties.FindConst( visualName );
 -      if( recreate || instancedMap )
 -      {
 -        RemoveVisual( mVisuals, visualName );
 -        Style::ApplyVisual( handle, visualName, toMap, instancedMap );
 -      }
 -      else
 -      {
 -        // @todo check to see if we can apply toMap without recreating the visual
 -        // e.g. by setting only animatable properties
 -        // For now, recreate all visuals, but merge in instance data.
 -        RemoveVisual( mVisuals, visualName );
 -        Style::ApplyVisual( handle, visualName, toMap, instancedMap );
 -      }
 +      const Property::Map* instancedMap = instancedProperties.FindConst(visualName);
 +      Style::ApplyVisual(handle, visualName, toMap, instancedMap);
      }
    }
  }
@@@ -1831,19 -1821,6 +1832,19 @@@ void Control::Impl::ClearShadow(
     mControlImpl.RelayoutRequest();
  }
  
 +Dali::Property Control::Impl::GetVisualProperty(Dali::Property::Index index, Dali::Property::Key visualPropertyKey)
 +{
 +  Toolkit::Visual::Base visual = GetVisualByIndex(mVisuals, index);
 +  if(visual)
 +  {
 +    Internal::Visual::Base& visualImpl = Toolkit::GetImplementation(visual);
 +    return visualImpl.GetPropertyObject(visualPropertyKey);
 +  }
 +
 +  Handle handle;
 +  return Dali::Property(handle, Property::INVALID_INDEX);
 +}
 +
  void Control::Impl::EmitResourceReadySignal()
  {
    if(!mIsEmittingResourceReadySignal)
@@@ -2132,14 -2109,13 +2133,13 @@@ bool Control::Impl::AccessibleImpl::Gra
    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);