-#ifndef __DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H__
-#define __DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H
+#define DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <dali/public-api/images/image.h>
-#include <dali/public-api/images/nine-patch-image.h>
#include <dali/public-api/images/image-operations.h>
-#include <dali/devel-api/rendering/geometry.h>
-#include <dali/devel-api/rendering/shader.h>
-#include <dali/devel-api/rendering/sampler.h>
+#include <dali/public-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>
namespace Dali
{
*
* The following properties are optional
*
- * | %Property Name | Type |
- * |---------------------------|------------------|
- * | image-url | STRING |
- * | border-only | BOOLEAN
+ * | %Property Name | Type |
+ * |--------------------------|------------------|
+ * | imageUrl | STRING |
+ * | borderOnly | BOOLEAN
*
*/
class NPatchRenderer: public ControlRenderer
/**
* @brief Constructor.
+ *
+ * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
*/
- NPatchRenderer();
+ NPatchRenderer( RendererFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
public: // from ControlRenderer
/**
- * @copydoc ControlRenderer::Initialize
+ * @copydoc ControlRenderer::GetNaturalSize
*/
- virtual void Initialize( RendererFactoryCache& factoryCache, const Property::Map& propertyMap );
+ virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
* @copydoc ControlRenderer::SetClipRect
/**
* @copydoc ControlRenderer::CreatePropertyMap
*/
- virtual void CreatePropertyMap( Property::Map& map ) const;
+ virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
+
+ /**
+ * @copydoc ControlRenderer::DoInitialize
+ */
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+
/**
* @copydoc ControlRenderer::DoSetOnStage
*/
public:
/**
- * Request the geometry and shader from the cache, if not available, create and save to the cache for sharing.
- *
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
- */
- void Initialize( RendererFactoryCache& factoryCache );
-
- /**
* @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
*
private:
/**
+ * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
+ */
+ void InitializeRenderer();
+
+ /**
+ * @brief Creates a geometry for this renderer's grid size
+ *
+ * @return Returns the created geometry for this renderer's grid size
+ */
+ Geometry CreateGeometry();
+
+ /**
+ * @brief Creates a shader for this renderer's grid size
+ *
+ * @return Returns the created shader for this renderer's grid size
+ */
+ Shader CreateShader();
+
+ /**
* @brief Creates a geometry for the grid size to be used by this renderers' shaders
*
- * @param gridSize The grid size of the solid geometry to create
+ * @param[in] gridSize The grid size of the solid geometry to create
* @return Returns the created geometry for the grid size
*/
Geometry CreateGeometry( Uint16Pair gridSize );
* |/ |/ |/ |/ |/ |
* ---------------------
*
- * @param gridSize The grid size of the solid geometry to create
+ * @param[in] gridSize The grid size of the solid geometry to create
* @return Returns the created geometry for the grid size
*/
Geometry CreateGeometryBorder( Uint16Pair gridSize );
/**
* @brief Creates Image from the image url and parses the image for the stretch borders. Will create a error image if the n patch image is invalid
*
- * @param nPatchImage The NinePatchImage to base our cropped images and stretch borders from
+ * @param[in] nPatchImage The NinePatchImage to base our cropped images and stretch borders from
*/
- void InitialiseFromImage( NinePatchImage nPatchImage );
+ void InitializeFromImage( NinePatchImage nPatchImage );
/**
- * @brief Creates a black Image to indicate that there was an error in either the image url or the parsing of the image
+ * @brief Creates an error Image to indicate that there was an error in either the image url or the parsing of the image
*
*/
- void CreateErrorImage();
+ void InitializeFromBrokenImage();
/**
- * @brief Applies this renderer's image to the sampler to the material used for this renderer
+ * @brief Applies this renderer's image to the sampler to the texture set used for this renderer
*/
void ApplyImageToSampler();
+ /**
+ * @brief Changes the current renderer if the n-patch meta data has changed
+ *
+ * @param[in] oldBorderOnly The old flag indicating if the image should omit the centre of the n-patch and only render the border
+ * @param[in] oldGridX The old horizontal grid size of the solid geometry
+ * @param[in] oldGridY The old vertical grid size of the solid geometry
+ */
+ void ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t oldGridY );
+
private:
NinePatchImage mImage; ///< The image to render if the renderer was set from an NinePatchImage, empty otherwise
Image mCroppedImage;
- Geometry mNinePatchGeometry;
- Geometry mNinePatchBorderGeometry;
- Shader mNinePatchShader;
std::string mImageUrl; ///< The url to the image resource to render if the renderer was set from an image resource url, empty otherwise
NinePatchImage::StretchRanges mStretchPixelsX;
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H__ */
+#endif // DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H