X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-factory-impl.cpp;h=469ead5a0ee6d107a52ac5ccd0fb6598ba725f13;hp=909cfcc03d3efeaeedbd980fea49fa11a7684849;hb=386634b00f264e667074fa7d956c81bc72233c62;hpb=cb30ef68af0383b073ba2d425d3d95c1e916cbb4 diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index 909cfcc..469ead5 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-impl.cpp @@ -27,6 +27,7 @@ // INTERNAL INCLUDES #include +#include #include #include #include @@ -41,7 +42,7 @@ #include #include #include -#include +#include #include namespace Dali @@ -118,28 +119,45 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property { Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); std::string imageUrl; - if( imageURLValue && imageURLValue->Get( imageUrl ) ) + if( imageURLValue ) { - // first resolve url type to know which visual to create - UrlType::Type type = ResolveUrlType( imageUrl ); - if( UrlType::N_PATCH == type ) - { - visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); - } - else if( UrlType::SVG == type ) + if( imageURLValue->Get( imageUrl ) ) { - visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + VisualUrl visualUrl( imageUrl ); + + switch( visualUrl.GetType() ) + { + case VisualUrl::N_PATCH: + { + visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); + break; + } + case VisualUrl::SVG: + { + visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); + break; + } + case VisualUrl::GIF: + { + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); + break; + } + case VisualUrl::REGULAR_IMAGE: + { + visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); + break; + } + } } - else if( UrlType::GIF == type ) + else { - visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); - } - else // Regular image - { - visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + Property::Array* array = imageURLValue->GetArray(); + if( array ) + { + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), *array, propertyMap ); + } } } - break; } @@ -166,6 +184,50 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property visualPtr = TextVisual::New( *( mFactoryCache.Get() ), propertyMap ); break; } + + case Toolkit::DevelVisual::N_PATCH: + { + Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); + std::string imageUrl; + if( imageURLValue && imageURLValue->Get( imageUrl ) ) + { + visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + } + break; + } + + case Toolkit::DevelVisual::SVG: + { + Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); + std::string imageUrl; + if( imageURLValue && imageURLValue->Get( imageUrl ) ) + { + visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + } + break; + } + + case Toolkit::DevelVisual::ANIMATED_IMAGE: + { + Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); + std::string imageUrl; + if( imageURLValue ) + { + if( imageURLValue->Get( imageUrl ) ) + { + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + } + else + { + Property::Array* array = imageURLValue->GetArray(); + if( array ) + { + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), *array, propertyMap ); + } + } + } + break; + } } if( !visualPtr ) @@ -220,22 +282,29 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, Image Visual::BasePtr visualPtr; // first resolve url type to know which visual to create - UrlType::Type type = ResolveUrlType( url ); - if( UrlType::N_PATCH == type ) - { - visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), url ); - } - else if( UrlType::SVG == type ) - { - visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), url ); - } - else if( UrlType::GIF == type ) + VisualUrl visualUrl( url ); + switch( visualUrl.GetType() ) { - visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), url ); - } - else // Regular image - { - visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), url, size ); + case VisualUrl::N_PATCH: + { + visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), visualUrl ); + break; + } + case VisualUrl::SVG: + { + visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), visualUrl ); + break; + } + case VisualUrl::GIF: + { + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), visualUrl ); + break; + } + case VisualUrl::REGULAR_IMAGE: + { + visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), visualUrl, size ); + break; + } } if( mDebugEnabled )