*
*/
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/visuals/visual-impl.h>
-
// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/images/image.h>
#include <dali/public-api/images/image-operations.h>
-#include <dali/public-api/images/nine-patch-image.h>
+#include <dali/devel-api/images/nine-patch-image.h>
#include <dali/public-api/rendering/geometry.h>
#include <dali/public-api/rendering/sampler.h>
#include <dali/public-api/rendering/shader.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
+
namespace Dali
{
namespace Internal
{
+class NPatchVisual;
+typedef IntrusivePtr< NPatchVisual > NPatchVisualPtr;
+
/**
- * The renderer which renders an 9 patch image to the control's quad
+ * The visual which renders an 9 patch image to the control's quad
*
* The following properties are optional
*
* | borderOnly | BOOLEAN
*
*/
-class NPatchVisual: public Visual
+class NPatchVisual: public Visual::Base
{
public:
/**
- * @brief Constructor.
+ * @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.
*/
- NPatchVisual( VisualFactoryCache& factoryCache );
+ static NPatchVisualPtr New( VisualFactoryCache& factoryCache );
/**
- * @brief A reference counted object may only be deleted by calling Unreference().
+ * @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 );
+
+ /**
+ * @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
*/
- ~NPatchVisual();
+ static NPatchVisualPtr New( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly = false );
public: // from Visual
/**
- * @copydoc Visual::GetNaturalSize
+ * @copydoc Visual::Base::GetNaturalSize
*/
virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * @copydoc Visual::SetClipRect
+ * @copydoc Visual::Base::CreatePropertyMap
*/
- virtual void SetClipRect( const Rect<int>& clipRect );
+ virtual void DoCreatePropertyMap( Property::Map& map ) const;
/**
- * @copydoc Visual::SetOffset
+ * @copydoc Visual::Base::DoSetProperty
*/
- virtual void SetOffset( const Vector2& offset );
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::DoGetProperty
*/
- virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
protected:
/**
- * @copydoc Visual::DoInitialize
+ * @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
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ NPatchVisual( VisualFactoryCache& factoryCache, bool borderOnly = false );
/**
- * @copydoc Visual::DoSetOnStage
+ * @brief A reference counted object may only be deleted by calling Unreference().
*/
- virtual void DoSetOnStage( Actor& actor );
+ virtual ~NPatchVisual();
/**
- * @copydoc Visual::DoSetOffStage
+ * @copydoc Visual::Base::DoSetProperties
*/
- virtual void DoSetOffStage( Actor& actor );
-
-public:
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
- * @brief Sets the 9 patch image of this renderer to the resource at imageUrl
- * The renderer will load the image synchronously when the associated actor is put on stage, and destroy the image when it is off stage
- *
- * @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
+ * @copydoc Visual::Base::DoSetOnStage
*/
- void SetImage( const std::string& imageUrl, bool borderOnly = false );
+ virtual void DoSetOnStage( Actor& actor );
/**
- * @brief Sets the 9 patch image of this renderer to the 9 patch image
- *
- * @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
+ * @copydoc Visual::Base::DoSetOffStage
*/
- void SetImage( NinePatchImage image, bool borderOnly = false );
+ virtual void DoSetOffStage( Actor& actor );
private:
private:
- NinePatchImage mImage; ///< The image to render if the renderer was set from an NinePatchImage, empty otherwise
+ NinePatchImage mImage; ///< The image to render if the visual was set from an NinePatchImage, empty otherwise
Image mCroppedImage;
- std::string mImageUrl; ///< The url to the image resource to render if the renderer was set from an image resource url, empty otherwise
+ std::string mImageUrl; ///< The url to the image resource to render if the visual was set from an image resource url, empty otherwise
NinePatchImage::StretchRanges mStretchPixelsX;
NinePatchImage::StretchRanges mStretchPixelsY;
ImageDimensions mImageSize;