(ImageView) Partially Restore Tizen 2.4 GetImage() functionality 30/67630/3
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 27 Apr 2016 13:41:46 +0000 (14:41 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 28 Apr 2016 16:51:39 +0000 (17:51 +0100)
Change-Id: I6f501ee01d094e5889c7c713364b56645f00e8b9

automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/internal/controls/image-view/image-view-impl.h
dali-toolkit/public-api/controls/image-view/image-view.cpp
dali-toolkit/public-api/controls/image-view/image-view.h

index 36a42dd..cbba3e0 100644 (file)
@@ -968,3 +968,46 @@ int UtcDaliImageViewSetImageBufferImageWithCustomShaderToNativeImage(void)
 
   END_TEST;
 }
 
   END_TEST;
 }
+
+int UtcDaliImageViewGetImageP1(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New();
+  DALI_TEST_CHECK( ! imageView.GetImage() );
+
+  Image image = CreateBufferImage();
+  imageView.SetImage( image );
+  DALI_TEST_CHECK( imageView.GetImage() == image );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewGetImageP2(void)
+{
+  ToolkitTestApplication application;
+
+  BufferImage image = CreateBufferImage();
+  ImageView imageView = ImageView::New( image );
+  DALI_TEST_CHECK( imageView.GetImage() == image );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewGetImageN(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
+  DALI_TEST_CHECK( ! imageView.GetImage() );
+
+  Image image = CreateBufferImage();
+  imageView.SetImage( image );
+  DALI_TEST_CHECK( imageView.GetImage() == image );
+
+  imageView.SetImage( TEST_IMAGE_FILE_NAME );
+  DALI_TEST_CHECK( ! imageView.GetImage() );
+
+  END_TEST;
+}
+
index 3eb0144..5843804 100644 (file)
@@ -142,6 +142,11 @@ void ImageView::SetImage( const std::string& url, ImageDimensions size )
   }
 }
 
   }
 }
 
+Image ImageView::GetImage() const
+{
+  return mImage;
+}
+
 void ImageView::EnablePreMultipliedAlpha( bool preMultipled )
 {
   if( mRenderer )
 void ImageView::EnablePreMultipliedAlpha( bool preMultipled )
 {
   if( mRenderer )
index b517994..c598c26 100644 (file)
@@ -76,6 +76,11 @@ public:
   void SetImage( const std::string& imageUrl, ImageDimensions size );
 
   /**
   void SetImage( const std::string& imageUrl, ImageDimensions size );
 
   /**
+   * @copydoc Dali::Toolkit::GetImage
+   */
+  Image GetImage() const;
+
+  /**
    * @brief Set whether the Pre-multiplied Alpha Blending is required
    *
    * @param[in] preMultipled whether alpha is pre-multiplied.
    * @brief Set whether the Pre-multiplied Alpha Blending is required
    *
    * @param[in] preMultipled whether alpha is pre-multiplied.
index 3333289..2726af5 100644 (file)
@@ -101,7 +101,7 @@ void ImageView::SetImage( const std::string& url, ImageDimensions size )
 
 Image ImageView::GetImage() const
 {
 
 Image ImageView::GetImage() const
 {
-  return Image();
+  return Dali::Toolkit::GetImpl( *this ).GetImage();
 }
 
 ImageView::ImageView( Internal::ImageView& implementation )
 }
 
 ImageView::ImageView( Internal::ImageView& implementation )
index 370579a..14e3427 100644 (file)
@@ -40,13 +40,17 @@ class ImageView;
  */
 
 /**
  */
 
 /**
- * @brief ImageView is a class for displaying an Image.
+ * @brief ImageView is a class for displaying an image resource.
+ *
+ * An instance of ImageView can be created using a URL or an Image instance.
+ *
  * @SINCE_1_0.0
  *
  */
 class DALI_IMPORT_API ImageView : public Control
 {
 public:
  * @SINCE_1_0.0
  *
  */
 class DALI_IMPORT_API ImageView : public Control
 {
 public:
+
   /**
    * @brief The start and end property ranges for this control.
    * @SINCE_1_0.0
   /**
    * @brief The start and end property ranges for this control.
    * @SINCE_1_0.0
@@ -76,11 +80,13 @@ public:
        * @SINCE_1_0.0
        */
       RESOURCE_URL = PROPERTY_START_INDEX,
        * @SINCE_1_0.0
        */
       RESOURCE_URL = PROPERTY_START_INDEX,
+
       /**
        * @brief name "image", type string if it is a url, map otherwise
        * @SINCE_1_0.0
        */
       IMAGE,
       /**
        * @brief name "image", type string if it is a url, map otherwise
        * @SINCE_1_0.0
        */
       IMAGE,
+
       /**
        * @brief name "preMultipliedAlpha", type Boolean
        * @SINCE_1_1.18
       /**
        * @brief name "preMultipliedAlpha", type Boolean
        * @SINCE_1_1.18
@@ -90,7 +96,6 @@ public:
 
       // Animatable properties
 
 
       // Animatable properties
 
-
       /**
        * @brief name "pixelArea", type Vector4
        * @details Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].
       /**
        * @brief name "pixelArea", type Vector4
        * @details Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].
@@ -119,18 +124,18 @@ public:
   static ImageView New();
 
   /**
   static ImageView New();
 
   /**
-   * @brief Create an initialized ImageView from an Image.
+   * @brief Create an initialized ImageView from an Image instance.
    *
    * If the handle is empty, ImageView will not display anything.
    *
    * @SINCE_1_0.0
    *
    * If the handle is empty, ImageView will not display anything.
    *
    * @SINCE_1_0.0
-   * @param[in] image The Image to display.
+   * @param[in] image The Image instance to display.
    * @return A handle to a newly allocated ImageView.
    */
   static ImageView New( Image image );
 
   /**
    * @return A handle to a newly allocated ImageView.
    */
   static ImageView New( Image image );
 
   /**
-   * @brief Create an initialized ImageView from an Image resource URL
+   * @brief Create an initialized ImageView from an URL to an image resource.
    *
    * If the string is empty, ImageView will not display anything.
    *
    *
    * If the string is empty, ImageView will not display anything.
    *
@@ -141,13 +146,13 @@ public:
   static ImageView New( const std::string& url );
 
   /**
   static ImageView New( const std::string& url );
 
   /**
-   * @brief Create an initialized ImageView from an Image resource URL
+   * @brief Create an initialized ImageView from a URL to an image resource.
    *
    * If the string is empty, ImageView will not display anything.
    *
    * @SINCE_1_1.10
    * @param[in] url The url of the image resource to display.
    *
    * If the string is empty, ImageView will not display anything.
    *
    * @SINCE_1_1.10
    * @param[in] url The url of the image resource to display.
-   * @param [in] size The width and height to fit the loaded image to.
+   * @param [in] size The width and height to which to fit the loaded image.
    * @return A handle to a newly allocated ImageView.
    *
    * @note A valid size is preferable for efficiency.
    * @return A handle to a newly allocated ImageView.
    *
    * @note A valid size is preferable for efficiency.
@@ -194,42 +199,43 @@ public:
   static ImageView DownCast( BaseHandle handle );
 
   /**
   static ImageView DownCast( BaseHandle handle );
 
   /**
-   * @brief Sets this ImageView from an Image
+   * @brief Sets this ImageView from an Image instance.
    *
    * If the handle is empty, ImageView will display nothing
    * @SINCE_1_0.0
    *
    * If the handle is empty, ImageView will display nothing
    * @SINCE_1_0.0
-   * @param[in] image The Image to display.
+   * @param[in] image The Image instance to display.
    */
   void SetImage( Image image );
 
   /**
    */
   void SetImage( Image image );
 
   /**
-   * @brief Sets this ImageView from an Image URL
+   * @brief Sets this ImageView from the given URL.
    *
    * If the URL is empty, ImageView will not display anything.
    *
    * @SINCE_1_1.4
    *
    * If the URL is empty, ImageView will not display anything.
    *
    * @SINCE_1_1.4
-   * @param[in] url The Image resource to display.
+   * @param[in] url The URL to the image resource to display.
    */
   void SetImage( const std::string& url );
 
   /**
    */
   void SetImage( const std::string& url );
 
   /**
-   * @brief Sets this ImageView from an Image URL
+   * @brief Sets this ImageView from the given URL.
    *
    * If the URL is empty, ImageView will not display anything.
    *
    * @SINCE_1_1.10
    *
    * If the URL is empty, ImageView will not display anything.
    *
    * @SINCE_1_1.10
-   * @param[in] url A URL to the image resource to display.
+   * @param[in] url The URL to the image resource to display.
    * @param [in] size The width and height to fit the loaded image to.
    */
   void SetImage( const std::string& url, ImageDimensions size );
 
   /**
    * @DEPRECATED_1_1.4
    * @param [in] size The width and height to fit the loaded image to.
    */
   void SetImage( const std::string& url, ImageDimensions size );
 
   /**
    * @DEPRECATED_1_1.4
-   * @brief Gets the Image
+   * @brief Gets the Image instance handle used by the ImageView.
+   *
+   * A valid handle will be returned only if this instance was created with New(Image) or SetImage(Image) was called.
    *
    * @SINCE_1_0.0
    *
    * @SINCE_1_0.0
-   * @remarks Calls to this method should be avoided as this may return an empty handle if the image has not been created yet.
-   * @return The Image currently set to this ImageView
+   * @return The Image instance currently used by the ImageView.
    */
   Image GetImage() const;
 
    */
   Image GetImage() const;