Visuals call SetProperties internally for 2-stage initialization
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / primitive / primitive-visual.h
index b655ee3..7792321 100644 (file)
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/internal/visuals/visual-impl.h>
+#include <dali-toolkit/public-api/visuals/primitive-visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
 
 namespace Dali
 {
@@ -57,8 +60,13 @@ namespace Toolkit
 namespace Internal
 {
 
+class PrimitiveVisual;
+typedef IntrusivePtr< PrimitiveVisual > PrimitiveVisualPtr;
+
 /**
- * The renderer which renders a simple 3D shape to the control's quad
+ * The visual which renders a simple 3D shape to the control's quad
+ *
+ * Primitives are created with clockwise winding and back-face culling by default.
  *
  * The following properties are required to create a PrimitiveRender
  *
@@ -83,74 +91,67 @@ namespace Internal
  *
  * Note: slices and stacks both have an upper limit of 255.
  *
- * Finally, the following can be used to affect the renderer's shader
+ * Finally, the following can be used to affect the visual's shader
  *
  * | %Property Name  | Type        | Representing                            |
  * |-----------------|-------------|-----------------------------------------|
  * | lightPosition   | VECTOR3     | The position (on stage) of the light    |
  */
-class PrimitiveVisual: public Visual
+class PrimitiveVisual: public Visual::Base
 {
 public:
 
   /**
-   * @brief Constructor.
+   * @brief Create a new primitive visual.
    *
    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+   * @param[in] properties A Property::Map containing settings for this visual
+   * @return A smart-pointer to the newly allocated visual.
    */
-  PrimitiveVisual( VisualFactoryCache& factoryCache );
-
-  /**
-   * @brief A reference counted object may only be deleted by calling Unreference().
-   */
-  virtual ~PrimitiveVisual();
+  static PrimitiveVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
 
 public:  // from Visual
 
   /**
-   * @copydoc Visual::SetSize
+   * @copydoc Visual::Base::GetNaturalSize
    */
-  virtual void SetSize( const Vector2& size );
+  virtual void GetNaturalSize( Vector2& naturalSize );
 
   /**
-   * @copydoc Visual::SetClipRect
+   * @copydoc Visual::Base::CreatePropertyMap
    */
-  virtual void SetClipRect( const Rect<int>& clipRect );
+  virtual void DoCreatePropertyMap( Property::Map& map ) const;
+
+protected:
 
   /**
-   * @copydoc Visual::SetOffset
+   * @brief Constructor.
+   *
+   * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
    */
-  virtual void SetOffset( const Vector2& offset );
+  PrimitiveVisual( VisualFactoryCache& factoryCache );
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @brief A reference counted object may only be deleted by calling Unreference().
    */
-  virtual void DoCreatePropertyMap( Property::Map& map ) const;
-
-protected:
+  virtual ~PrimitiveVisual();
 
   /**
-   * @copydoc Visual::DoInitialize
+   * @copydoc Visual::Base::DoSetProperties
    */
-  virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+  virtual void DoSetProperties( const Property::Map& propertyMap );
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
-private:
+  /**
+   * @copydoc Visual::Base::OnSetTransform
+   */
+  virtual void OnSetTransform();
 
-  enum PrimitiveType
-  {
-    SPHERE,
-    CONE,
-    CONICAL_FRUSTRUM,
-    CYLINDER,
-    CUBE,
-    OCTAHEDRON,
-    BEVELLED_CUBE
-  };
+private:
 
   //Simple struct to store the position and normal of a single vertex.
   struct Vertex
@@ -319,7 +320,6 @@ private:
   Shader mShader;
   Geometry mGeometry;
 
-  std::string mShape;            //Shape to render, as string.
   Vector4 mColor;                //Color of shape.
   Vector3 mObjectDimensions;     //Dimensions of shape, scaled to be between 0.0 and 1.0.
 
@@ -340,7 +340,7 @@ private:
   int     mSlices;               ///< Number of slices to use when creating certain objects.
   int     mStacks;               ///< Number of stacks to use when creating certain objects.
 
-  PrimitiveType mPrimitiveType;  //Shape to render, as enum.
+  Toolkit::PrimitiveVisual::Shape::Type mPrimitiveType;  //Shape to render, as enum.
 };
 
 } // namespace Internal