} // unnamed namespace
-BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache )
+BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache, const std::string& url )
{
- return new BatchImageVisual( factoryCache );
+ BatchImageVisualPtr visual = new BatchImageVisual( factoryCache );
+ visual->mImageUrl = url;
+ return visual;
}
BatchImageVisual::BatchImageVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
+ mImageUrl(""),
mDesiredSize()
{
}
void BatchImageVisual::DoSetProperties( const Property::Map& propertyMap )
{
- std::string oldImageUrl = mImageUrl;
- Property::Value* imageURLValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::URL, Dali::Toolkit::Internal::IMAGE_URL_NAME );
+ // url already passed in constructor
- if( imageURLValue )
+ int desiredWidth = 0;
+ Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH );
+ if( desiredWidthValue )
{
- imageURLValue->Get( mImageUrl );
-
- int desiredWidth = 0;
- Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH );
- if( desiredWidthValue )
- {
- desiredWidthValue->Get( desiredWidth );
- }
-
- int desiredHeight = 0;
- Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT );
- if( desiredHeightValue )
- {
- desiredHeightValue->Get( desiredHeight );
- }
+ desiredWidthValue->Get( desiredWidth );
+ }
- mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
+ int desiredHeight = 0;
+ Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT );
+ if( desiredHeightValue )
+ {
+ desiredHeightValue->Get( desiredHeight );
}
+
+ mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
}
void BatchImageVisual::SetSize( const Vector2& size )
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @return A smart-pointer to the newly allocated visual.
*/
- static BatchImageVisualPtr New( VisualFactoryCache& factoryCache );
+ static BatchImageVisualPtr New( VisualFactoryCache& factoryCache, const std::string& url );
public: // from Visual
} // unnamed namespace
-ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache )
-{
- return new ImageVisual( factoryCache );
-}
-
ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache,
const std::string& imageUrl,
ImageDimensions size,
return new ImageVisual( factoryCache, image );
}
-ImageVisual::ImageVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache ),
- mImage(),
- mPixels(),
- mPixelArea( FULL_TEXTURE_RECT ),
- mPlacementActor(),
- mImageUrl(),
- mDesiredSize(),
- mFittingMode( FittingMode::DEFAULT ),
- mSamplingMode( SamplingMode::DEFAULT ),
- mWrapModeU( WrapMode::DEFAULT ),
- mWrapModeV( WrapMode::DEFAULT )
-{
-}
-
ImageVisual::ImageVisual( VisualFactoryCache& factoryCache,
const std::string& imageUrl,
ImageDimensions size,
void ImageVisual::DoSetProperties( const Property::Map& propertyMap )
{
- Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
- if( imageURLValue )
+ // Url is already received in constructor
+ Property::Value* fittingValue = propertyMap.Find( Toolkit::ImageVisual::Property::FITTING_MODE, IMAGE_FITTING_MODE );
+ if( fittingValue )
{
- imageURLValue->Get( mImageUrl );
- if( !mImageUrl.empty() )
- {
- mImage.Reset();
- }
-
- Property::Value* fittingValue = propertyMap.Find( Toolkit::ImageVisual::Property::FITTING_MODE, IMAGE_FITTING_MODE );
- if( fittingValue )
- {
- int value;
- Scripting::GetEnumerationProperty( *fittingValue, FITTING_MODE_TABLE, FITTING_MODE_TABLE_COUNT, value );
- mFittingMode = Dali::FittingMode::Type( value );
- }
-
- Property::Value* samplingValue = propertyMap.Find( Toolkit::ImageVisual::Property::SAMPLING_MODE, IMAGE_SAMPLING_MODE );
- if( samplingValue )
- {
- int value;
- Scripting::GetEnumerationProperty( *samplingValue, SAMPLING_MODE_TABLE, SAMPLING_MODE_TABLE_COUNT, value );
- mSamplingMode = Dali::SamplingMode::Type( value );
- }
+ int value;
+ Scripting::GetEnumerationProperty( *fittingValue, FITTING_MODE_TABLE, FITTING_MODE_TABLE_COUNT, value );
+ mFittingMode = Dali::FittingMode::Type( value );
+ }
- int desiredWidth = 0;
- Property::Value* desiredWidthValue = propertyMap.Find( Toolkit::ImageVisual::Property::DESIRED_WIDTH, IMAGE_DESIRED_WIDTH );
- if( desiredWidthValue )
- {
- desiredWidthValue->Get( desiredWidth );
- }
+ Property::Value* samplingValue = propertyMap.Find( Toolkit::ImageVisual::Property::SAMPLING_MODE, IMAGE_SAMPLING_MODE );
+ if( samplingValue )
+ {
+ int value;
+ Scripting::GetEnumerationProperty( *samplingValue, SAMPLING_MODE_TABLE, SAMPLING_MODE_TABLE_COUNT, value );
+ mSamplingMode = Dali::SamplingMode::Type( value );
+ }
- int desiredHeight = 0;
- Property::Value* desiredHeightValue = propertyMap.Find( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, IMAGE_DESIRED_HEIGHT );
- if( desiredHeightValue )
- {
- desiredHeightValue->Get( desiredHeight );
- }
+ int desiredWidth = 0;
+ Property::Value* desiredWidthValue = propertyMap.Find( Toolkit::ImageVisual::Property::DESIRED_WIDTH, IMAGE_DESIRED_WIDTH );
+ if( desiredWidthValue )
+ {
+ desiredWidthValue->Get( desiredWidth );
+ }
- Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME );
- if( pixelAreaValue )
- {
- pixelAreaValue->Get( mPixelArea );
- }
+ int desiredHeight = 0;
+ Property::Value* desiredHeightValue = propertyMap.Find( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, IMAGE_DESIRED_HEIGHT );
+ if( desiredHeightValue )
+ {
+ desiredHeightValue->Get( desiredHeight );
+ }
- Property::Value* wrapModeValueU = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_U, IMAGE_WRAP_MODE_U );
- if( wrapModeValueU )
- {
- int value;
- Scripting::GetEnumerationProperty( *wrapModeValueU, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
- mWrapModeU = Dali::WrapMode::Type( value );
- }
+ Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME );
+ if( pixelAreaValue )
+ {
+ pixelAreaValue->Get( mPixelArea );
+ }
- Property::Value* wrapModeValueV = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_V, IMAGE_WRAP_MODE_V );
- if( wrapModeValueV )
- {
- int value;
- Scripting::GetEnumerationProperty( *wrapModeValueV, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
- mWrapModeV = Dali::WrapMode::Type( value );
- }
+ Property::Value* wrapModeValueU = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_U, IMAGE_WRAP_MODE_U );
+ if( wrapModeValueU )
+ {
+ int value;
+ Scripting::GetEnumerationProperty( *wrapModeValueU, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
+ mWrapModeU = Dali::WrapMode::Type( value );
+ }
- mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
+ Property::Value* wrapModeValueV = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_V, IMAGE_WRAP_MODE_V );
+ if( wrapModeValueV )
+ {
+ int value;
+ Scripting::GetEnumerationProperty( *wrapModeValueV, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
+ mWrapModeV = Dali::WrapMode::Type( value );
}
+ mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
+
Property::Value* syncLoading = propertyMap.Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, SYNCHRONOUS_LOADING );
if( syncLoading )
{
mImpl->mFlags |= Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
// if sync loading is required, the loading should start immediately when new image url is set or the actor is off stage
// ( for on-stage actor with image url unchanged, resource loading is already finished)
- if( imageURLValue )
+ if( mImageUrl.size() > 0u )
{
LoadResourceSynchronously();
}
public:
/**
- * @brief Create a new image visual.
- *
- * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
- * @return A smart-pointer to the newly allocated visual.
- */
- static ImageVisualPtr New( VisualFactoryCache& factoryCache );
-
- /**
* @brief Create a new image visual with a URL.
*
* The visual will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
protected:
/**
- * @brief Constructor.
- *
- * @param[in] factoryCache The VisualFactoryCache object
- */
- ImageVisual( VisualFactoryCache& factoryCache );
-
- /**
* @brief Constructor with a URL.
*
* The visual will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
/////////////////NPatchVisual////////////////
-NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache )
+NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl )
{
- return new NPatchVisual( factoryCache );
-}
-
-NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, bool borderOnly )
-{
- NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache, borderOnly );
+ NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache );
nPatchVisual->mImageUrl = imageUrl;
NinePatchImage image = NinePatchImage::New( imageUrl );
return nPatchVisual;
}
-NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly )
+NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, NinePatchImage image )
{
- NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache, borderOnly );
+ NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache );
nPatchVisual->mImage = image;
nPatchVisual->InitializeFromImage( image );
return nPatchVisual;
}
-NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache, bool borderOnly )
+NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
mImage(),
mCroppedImage(),
mStretchPixelsX(),
mStretchPixelsY(),
mImageSize(),
- mBorderOnly( borderOnly )
+ mBorderOnly( false )
{
}
void NPatchVisual::DoSetProperties( const Property::Map& propertyMap )
{
- Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
- if( imageURLValue )
+ // URL is already passed in via constructor
+ //Read the borderOnly property first since InitialiseFromImage relies on mBorderOnly to be properly set
+ Property::Value* borderOnlyValue = propertyMap.Find( Toolkit::ImageVisual::Property::BORDER_ONLY, BORDER_ONLY );
+ if( borderOnlyValue )
{
- //Read the borderOnly property first since InitialiseFromImage relies on mBorderOnly to be properly set
- Property::Value* borderOnlyValue = propertyMap.Find( Toolkit::ImageVisual::Property::BORDER_ONLY, BORDER_ONLY );
- if( borderOnlyValue )
- {
- borderOnlyValue->Get( mBorderOnly );
- }
-
- if( imageURLValue->Get( mImageUrl ) )
- {
- NinePatchImage nPatch = NinePatchImage::New( mImageUrl );
- InitializeFromImage( nPatch );
- }
- else
- {
- InitializeFromBrokenImage();
- DALI_LOG_ERROR( "The property '%s' is not a string\n", IMAGE_URL_NAME );
- }
+ borderOnlyValue->Get( mBorderOnly );
}
}
public:
/**
- * @brief Create a new n-patch visual.
- *
- * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
- * @return A smart-pointer to the newly allocated visual.
- */
- static NPatchVisualPtr New( VisualFactoryCache& factoryCache );
-
- /**
* @brief Create an N-patch visual using an image URL.
*
* The visual will load the image synchronously when the associated actor is put on stage, and destroy the image when it is off stage
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @param[in] imageUrl The URL to 9 patch image resource to use
- * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
*/
- static NPatchVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, bool borderOnly = false );
+ static NPatchVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl );
/**
* @brief Create an N-patch visual with a NinePatchImage resource.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @param[in] image The NinePatchImage to use
- * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
*/
- static NPatchVisualPtr New( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly = false );
+ static NPatchVisualPtr New( VisualFactoryCache& factoryCache, NinePatchImage image );
public: // from Visual
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
- * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
+ * @param[in] factoryCache Reference to the VisualFactoryCache object
*/
- NPatchVisual( VisualFactoryCache& factoryCache, bool borderOnly = false );
+ NPatchVisual( VisualFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
namespace Internal
{
-SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache )
-{
- return new SvgVisual( factoryCache );
-}
-
SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size )
{
SvgVisual* svgVisual = new SvgVisual( factoryCache );
void SvgVisual::DoSetProperties( const Property::Map& propertyMap )
{
- Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
- if( imageURLValue )
- {
- std::string imageUrl;
- if( imageURLValue->Get( imageUrl ) )
- {
- ParseFromUrl( imageUrl );
- }
- else
- {
- DALI_LOG_ERROR( "The property '%s' is not a string\n", IMAGE_URL_NAME );
- }
- }
+ // url already passed in from constructor
}
void SvgVisual::DoSetOnStage( Actor& actor )
public:
/**
- * @brief Create a new SVG visual.
- *
- * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
- * @return A smart-pointer to the newly allocated visual.
- */
- static SvgVisualPtr New( VisualFactoryCache& factoryCache );
-
- /**
* @brief Create the SVG Visual using the image URL.
*
* The visual will parse the SVG image once it is set.
UrlType::Type type = ResolveUrlType( imageUrl );
if( UrlType::N_PATCH == type )
{
- visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), imageUrl );
}
else if( UrlType::SVG == type )
{
- visualPtr = SvgVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), imageUrl );
}
else // Regular image
{
if( batchingEnabled )
{
- visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ), imageUrl );
break;
}
else
{
- visualPtr = ImageVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl );
}
}
}