(ImageActor) Partially restored Get/Set Image & NinePatchBorder APIs 47/56247/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 5 Jan 2016 18:10:10 +0000 (18:10 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 6 Jan 2016 11:16:20 +0000 (11:16 +0000)
- The value is only stored so that it can be returned in the getter.
- Internally, we do not support any other style apart from STYLE_QUAD.

Change-Id: Ifad7dbfd60bbaa6761a8c0fe4c4e76ab1ba457c3

automated-tests/src/dali/utc-Dali-ImageActor.cpp
dali/internal/event/actors/image-actor-impl.cpp
dali/internal/event/actors/image-actor-impl.h
dali/public-api/actors/image-actor.cpp
dali/public-api/actors/image-actor.h

index e9f893a..c65465c 100644 (file)
@@ -151,16 +151,15 @@ int UtcDaliImageActor9Patch(void)
   ImageActor actor = ImageActor::New(image);
 
   actor.SetStyle(ImageActor::STYLE_NINE_PATCH);
-  DALI_TEST_EQUALS( ImageActor::STYLE_QUAD, actor.GetStyle(), TEST_LOCATION ); //nine patch is deprecated
+  DALI_TEST_EQUALS( ImageActor::STYLE_NINE_PATCH, actor.GetStyle(), TEST_LOCATION );
 
   Vector4 border(0.1,0.2,0.3,0.4);
   actor.SetNinePatchBorder(border);
 
-  //nine patch is deprecated
-  DALI_TEST_EQUALS( 0.0f, actor.GetNinePatchBorder().x, TEST_LOCATION );
-  DALI_TEST_EQUALS( 0.0f, actor.GetNinePatchBorder().y, TEST_LOCATION );
-  DALI_TEST_EQUALS( 0.0f, actor.GetNinePatchBorder().z, TEST_LOCATION );
-  DALI_TEST_EQUALS( 0.0f, actor.GetNinePatchBorder().w, TEST_LOCATION );
+  DALI_TEST_EQUALS( 0.1f, actor.GetNinePatchBorder().x, TEST_LOCATION );
+  DALI_TEST_EQUALS( 0.2f, actor.GetNinePatchBorder().y, TEST_LOCATION );
+  DALI_TEST_EQUALS( 0.3f, actor.GetNinePatchBorder().z, TEST_LOCATION );
+  DALI_TEST_EQUALS( 0.4f, actor.GetNinePatchBorder().w, TEST_LOCATION );
   END_TEST;
 }
 
@@ -782,7 +781,7 @@ int UtcDaliImageActorUseImageAlpha05(void)
   END_TEST;
 }
 
-int UtcDaliImageGetStyle(void)
+int UtcDaliImageActorGetStyle(void)
 {
   TestApplication application;
 
@@ -795,11 +794,11 @@ int UtcDaliImageGetStyle(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( ImageActor::STYLE_QUAD, actor.GetStyle(), TEST_LOCATION ); //nine patch is deprecated
+  DALI_TEST_EQUALS( ImageActor::STYLE_NINE_PATCH, actor.GetStyle(), TEST_LOCATION );
   END_TEST;
 }
 
-int UtcDaliImageSetNinePatchBorder(void)
+int UtcDaliImageActorSetNinePatchBorder(void)
 {
   TestApplication application;
 
@@ -807,15 +806,14 @@ int UtcDaliImageSetNinePatchBorder(void)
   ImageActor actor = ImageActor::New(image);
 
   actor.SetStyle(ImageActor::STYLE_NINE_PATCH);
-  DALI_TEST_EQUALS( ImageActor::STYLE_QUAD, actor.GetStyle(), TEST_LOCATION ); //nine patch is deprecated
+  DALI_TEST_EQUALS( ImageActor::STYLE_NINE_PATCH, actor.GetStyle(), TEST_LOCATION );
 
   actor.SetNinePatchBorder(Vector4( 1.0f, 2.0f, 3.0f, 4.0f));
 
-  //nine patch is deprecated
-  DALI_TEST_EQUALS( 0.0f, actor.GetNinePatchBorder().x, TEST_LOCATION );
-  DALI_TEST_EQUALS( 0.0f, actor.GetNinePatchBorder().y, TEST_LOCATION );
-  DALI_TEST_EQUALS( 0.0f, actor.GetNinePatchBorder().z, TEST_LOCATION );
-  DALI_TEST_EQUALS( 0.0f, actor.GetNinePatchBorder().w, TEST_LOCATION );
+  DALI_TEST_EQUALS( 1.0f, actor.GetNinePatchBorder().x, TEST_LOCATION );
+  DALI_TEST_EQUALS( 2.0f, actor.GetNinePatchBorder().y, TEST_LOCATION );
+  DALI_TEST_EQUALS( 3.0f, actor.GetNinePatchBorder().z, TEST_LOCATION );
+  DALI_TEST_EQUALS( 4.0f, actor.GetNinePatchBorder().w, TEST_LOCATION );
   END_TEST;
 }
 
index d8b2a18..19f6cd2 100644 (file)
@@ -268,6 +268,30 @@ void ImageActor::ClearPixelArea()
   UpdateTexureRect();
 }
 
+void ImageActor::SetStyle( Dali::ImageActor::Style style )
+{
+  DALI_LOG_WARNING( "SetStyle Deprecated. Only STYLE_QUAD supported." );
+  mStyle = style;
+}
+
+Dali::ImageActor::Style ImageActor::GetStyle() const
+{
+  DALI_LOG_WARNING( "GetStyle Deprecated. Only STYLE_QUAD supported." );
+  return mStyle;
+}
+
+void ImageActor::SetNinePatchBorder( const Vector4& border )
+{
+  DALI_LOG_WARNING( "SetNinePatchBorder Deprecated. Only STYLE_QUAD supported." );
+  mNinePatchBorder = border;
+}
+
+Vector4 ImageActor::GetNinePatchBorder() const
+{
+  DALI_LOG_WARNING( "GetNinePatchBorder Deprecated. Only STYLE_QUAD supported." );
+  return mNinePatchBorder;
+}
+
 ImageActor::ImageActor()
 : Actor( Actor::BASIC ),
   mGridSize( 1u, 1u ),
@@ -276,6 +300,7 @@ ImageActor::ImageActor()
   mEffectTextureIndex( INVALID_TEXTURE_ID ),
   mMinFilter( FilterMode::DEFAULT ),
   mMagFilter( FilterMode::DEFAULT ),
+  mStyle( Dali::ImageActor::STYLE_QUAD ),
   mIsPixelAreaSet( false )
 {
 }
index 8265936..a9e2f6f 100644 (file)
@@ -100,6 +100,26 @@ public:
   void ClearPixelArea();
 
   /**
+   * @copydoc Dali::ImageActor::SetStyle()
+   */
+  void SetStyle( Dali::ImageActor::Style style );
+
+  /**
+   * @copydoc Dali::ImageActor::GetStyle()
+   */
+  Dali::ImageActor::Style GetStyle() const;
+
+  /**
+   * @copydoc Dali::ImageActor::SetNinePatchBorder()
+   */
+  void SetNinePatchBorder( const Vector4& border );
+
+  /**
+   * @copydoc Dali::ImageActor::GetNinePatchBorder()
+   */
+  Vector4 GetNinePatchBorder() const;
+
+  /**
    * @copydoc Dali::RenderableActor::SetSortModifier()
    */
   void SetSortModifier(float modifier);
@@ -294,17 +314,19 @@ private:
 
 private:
 
-  ShaderEffectPtr    mShaderEffect;            ///< Optional referenced shader effect
-  RendererPtr        mRenderer;                ///< The renderer used to render the image
-  PixelArea          mPixelArea;               ///< The pixel area of the image to render
-  Vector4            mBlendColor;              ///< The blend color for this ImageActor
-  Uint16Pair         mGridSize;                ///< The geometry grid size
-  int                mRendererIndex;           ///< The index location of mRenderer
-  size_t             mTextureIndex;            ///< The texture index for this ImageActor's texture
-  size_t             mEffectTextureIndex;      ///< The texture index for this ImageActor's effect texture
-  FilterMode::Type   mMinFilter;               ///< The minification filter currently set
-  FilterMode::Type   mMagFilter;               ///< The magnification filter currently set
-  bool               mIsPixelAreaSet;          ///< Flag indicating if the pixel area has been set
+  ShaderEffectPtr         mShaderEffect;            ///< Optional referenced shader effect
+  RendererPtr             mRenderer;                ///< The renderer used to render the image
+  PixelArea               mPixelArea;               ///< The pixel area of the image to render
+  Vector4                 mBlendColor;              ///< The blend color for this ImageActor
+  Vector4                 mNinePatchBorder;         ///< Nine-patch not supported, but this is used to store what is set so it can be returned for backwards compatibility.
+  Uint16Pair              mGridSize;                ///< The geometry grid size
+  int                     mRendererIndex;           ///< The index location of mRenderer
+  size_t                  mTextureIndex;            ///< The texture index for this ImageActor's texture
+  size_t                  mEffectTextureIndex;      ///< The texture index for this ImageActor's effect texture
+  FilterMode::Type        mMinFilter;               ///< The minification filter currently set
+  FilterMode::Type        mMagFilter;               ///< The magnification filter currently set
+  Dali::ImageActor::Style mStyle;                   ///< The style set by SetStyle. Not used internally, only used to store what is set so it can be returned for backwards compatibility.
+  bool                    mIsPixelAreaSet;          ///< Flag indicating if the pixel area has been set
 };
 
 } // namespace Internal
index 8599880..bd225dc 100644 (file)
@@ -104,24 +104,22 @@ ImageActor::PixelArea ImageActor::GetPixelArea() const
 
 void ImageActor::SetStyle(Style style)
 {
-  //deprecated - use ImageView instead for nine patch
+  GetImplementation(*this).SetStyle( style );
 }
 
 ImageActor::Style ImageActor::GetStyle() const
 {
-  //deprecated - use ImageView instead for nine patch
-  return ImageActor::STYLE_QUAD;
+  return GetImplementation(*this).GetStyle();
 }
 
 void ImageActor::SetNinePatchBorder(const Vector4& border)
 {
-  //deprecated - use ImageView instead for nine patch
+  GetImplementation(*this).SetNinePatchBorder( border );
 }
 
 Vector4 ImageActor::GetNinePatchBorder() const
 {
-  //deprecated - use ImageView instead for nine patch
-  return Vector4::ZERO;
+  return GetImplementation(*this).GetNinePatchBorder();
 }
 
 void ImageActor::SetSortModifier(float modifier)
index bc49566..784ab9a 100644 (file)
@@ -242,6 +242,8 @@ public:
    *
    * @pre image must be initialized.
    * @param [in] style The new style.
+   *
+   * @note The style specified is set (so GetStyle will return what's set) but ignored internally.
    */
   void SetStyle(Style style);
 
@@ -252,6 +254,8 @@ public:
    *
    * @pre image must be initialized.
    * @return The rendering style.
+   *
+   * @note This just returns the style set by SetStyle. In reality, only STYLE_QUAD is supported.
    */
   Style GetStyle() const;