[dali_2.3.22] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / image-view / image-view.h
index 69bcbc3..6f52832 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_IMAGE_VIEW_H__
-#define __DALI_TOOLKIT_IMAGE_VIEW_H__
+#ifndef DALI_TOOLKIT_IMAGE_VIEW_H
+#define DALI_TOOLKIT_IMAGE_VIEW_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Internal DALI_INTERNAL
 {
 class ImageView;
@@ -44,24 +42,49 @@ class ImageView;
  *
  * An instance of ImageView can be created using a URL or an Image instance.
  *
+ * Some resources can be loaded before the ImageView is staged ( already cached ), in these cases if the connection to
+ * ResouceReadySignal is done after the resource is set then signal will be missed.
+ *
+ * To protect against this, IsResourceReady() can be checked before connecting to ResourceReadySignal,
+ * or the signal connection can be done before setting the resource.
+ *
+ * @code
+ *    auto myImageView = ImageView::New( resourceUrl );
+ *    if ( myImageView.IsResourceReady() )
+ *    {
+ *       // do something
+ *    }
+ *    else
+ *    {
+ *      myImageView.ResourceReadySignal.Connect( .... )
+ *    }
+ * @endcode
+ *
+ * OR Connect to signal before setting resource
+ *
+ * @code
+ *    auto myImageView = ImageView::New();
+ *    myImageView.ResourceReadySignal.Connect( .... )
+ *    myImageView.SetProperty( ImageView::Property::IMAGE, resourceUrl );
+ * @endcode
+ *
  * @SINCE_1_0.0
  *
  */
-class DALI_IMPORT_API ImageView : public Control
+class DALI_TOOLKIT_API ImageView : public Control
 {
 public:
-
   /**
    * @brief Enumeration for the start and end property ranges for this control.
    * @SINCE_1_0.0
    */
   enum PropertyRange
   {
-    PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,  ///< @SINCE_1_0.0
-    PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,              ///< Reserve property indices @SINCE_1_0.0
+    PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
+    PROPERTY_END_INDEX   = PROPERTY_START_INDEX + 1000,             ///< Reserve property indices @SINCE_1_0.0
 
-    ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,        ///< @SINCE_1_1.18
-    ANIMATABLE_PROPERTY_END_INDEX =   ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000  ///< Reserve animatable property indices, @SINCE_1_1.18
+    ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,       ///< @SINCE_1_1.18
+    ANIMATABLE_PROPERTY_END_INDEX   = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices, @SINCE_1_1.18
   };
 
   /**
@@ -79,17 +102,10 @@ public:
       // Event side properties
 
       /**
-       * @DEPRECATED_1_1.16. Use IMAGE instead.
-       * @brief name "resourceUrl", type string.
-       * @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,
+      IMAGE = PROPERTY_START_INDEX,
 
       /**
        * @brief name "preMultipliedAlpha", type Boolean.
@@ -98,6 +114,24 @@ public:
        */
       PRE_MULTIPLIED_ALPHA,
 
+      /**
+       * @brief name "placeholderImage", type string.
+       *
+       * placeholder image is shown when image view is waiting for the image to load.
+       * @SINCE_2_2.24
+       */
+      PLACEHOLDER_IMAGE,
+
+      /**
+       * @brief name "enableTransitionEffect", type Boolean
+       *
+       * This effect is a crossfade effect when the image is replaced.
+       * the default duration of the crossfade effect is 1.5 seconds.
+       * if the placeholder is enabled, the cross effect applies when the image is changed from a placeholder image to a new image.
+       * if not, the cross effect applies when a new image is shown or is changed from the previous image to a new image.
+       * @SINCE_2_2.24
+       */
+      ENABLE_TRANSITION_EFFECT,
 
       // Animatable properties
 
@@ -111,7 +145,6 @@ public:
   };
 
 public:
-
   /**
    * @brief Creates an uninitialized ImageView.
    * @SINCE_1_0.0
@@ -129,47 +162,77 @@ public:
   static ImageView New();
 
   /**
-   * @DEPRECATED_1_2_8, use New( const std::string& ) instead.
-   *
-   * @brief Creates an initialized ImageView from an Image instance.
+   * @brief Creates an initialized ImageView from an URL to an image resource.
    *
-   * If the handle is empty, ImageView will not display anything.
+   * If the string is empty, ImageView will not display anything.
    *
    * @SINCE_1_0.0
-   * @param[in] image The Image instance to display
+   * @REMARK_INTERNET
+   * @REMARK_STORAGE
+   * @param[in] url The url of the image resource to display
    * @return A handle to a newly allocated ImageView
    */
-  static ImageView New( Image image ) DALI_DEPRECATED_API;
+  static ImageView New(const std::string& url);
 
   /**
-   * @brief Creates an initialized ImageView from an URL to an image resource.
+   * @brief Creates an initialized ImageView from a URL to an image resource.
    *
    * If the string is empty, ImageView will not display anything.
    *
-   * @SINCE_1_0.0
+   * @SINCE_1_1.10
    * @REMARK_INTERNET
    * @REMARK_STORAGE
    * @param[in] url The url of the image resource to display
+   * @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.
+   *       However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
+   *       The content of the area not covered by the actual image is undefined and will not be cleared.
    */
-  static ImageView New( const std::string& url );
+  static ImageView New(const std::string& url, ImageDimensions size);
 
   /**
-   * @brief Creates an initialized ImageView from a URL to an image resource.
+   * @brief Create an initialized ImageView with additional behaviour.
+   *
+   * @SINCE_2_1.8
+   * @param[in] additionalBehaviour Additional control behaviour
+   * @return A handle to a newly allocated Dali ImageView
+   *
+   * @note ImageView will not display anything.
+   */
+  static ImageView New(ControlBehaviour additionalBehaviour);
+
+  /**
+   * @brief Creates an initialized ImageView from an URL to an image resource with additional behaviour.
    *
    * If the string is empty, ImageView will not display anything.
    *
-   * @SINCE_1_1.10
+   * @SINCE_2_1.8
    * @REMARK_INTERNET
    * @REMARK_STORAGE
+   * @param[in] additionalBehaviour Additional control behaviour
    * @param[in] url The url of the image resource to display
-   * @param [in] size The width and height to which to fit the loaded image
+   * @return A handle to a newly allocated ImageView
+   */
+  static ImageView New(ControlBehaviour additionalBehaviour, const std::string& url);
+
+  /**
+   * @brief Creates an initialized ImageView from a URL to an image resource with additional behaviour.
+   *
+   * If the string is empty, ImageView will not display anything.
+   *
+   * @SINCE_2_1.8
+   * @REMARK_INTERNET
+   * @REMARK_STORAGE
+   * @param[in] additionalBehaviour Additional control behaviour
+   * @param[in] url The url of the image resource to display
+   * @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.
    *       However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
    *       The content of the area not covered by the actual image is undefined and will not be cleared.
    */
-  static ImageView New( const std::string& url, ImageDimensions size );
+  static ImageView New(ControlBehaviour additionalBehaviour, const std::string& url, ImageDimensions size);
 
   /**
    * @brief Destructor.
@@ -185,7 +248,15 @@ public:
    * @SINCE_1_0.0
    * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
    */
-  ImageView( const ImageView& imageView );
+  ImageView(const ImageView& imageView);
+
+  /**
+   * @brief Move constructor
+   * @SINCE_1_9.23
+   *
+   * @param[in] rhs A reference to the moved handle
+   */
+  ImageView(ImageView&& rhs) noexcept;
 
   /**
    * @brief Assignment operator.
@@ -194,7 +265,16 @@ public:
    * @param[in] imageView The ImageView to assign from
    * @return The updated ImageView
    */
-  ImageView& operator=( const ImageView& imageView );
+  ImageView& operator=(const ImageView& imageView);
+
+  /**
+   * @brief Move assignment
+   * @SINCE_1_9.23
+   *
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this
+   */
+  ImageView& operator=(ImageView&& rhs) noexcept;
 
   /**
    * @brief Downcasts a handle to ImageView handle.
@@ -206,18 +286,7 @@ public:
    * @param[in] handle Handle to an object
    * @return Handle to a ImageView or an uninitialized handle
    */
-  static ImageView DownCast( BaseHandle handle );
-
-  /**
-   * @DEPRECATED_1_2_8, use SetImage( const std::string& ) instead.
-   *
-   * @brief Sets this ImageView from an Image instance.
-   *
-   * If the handle is empty, ImageView will display nothing
-   * @SINCE_1_0.0
-   * @param[in] image The Image instance to display.
-   */
-  void SetImage( Image image ) DALI_DEPRECATED_API;
+  static ImageView DownCast(BaseHandle handle);
 
   /**
    * @brief Sets this ImageView from the given URL.
@@ -229,7 +298,7 @@ public:
    * @REMARK_STORAGE
    * @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 the given URL.
@@ -242,21 +311,9 @@ public:
    * @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
-   * @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
-   * @return The Image instance currently used by the ImageView
-   */
-  Image GetImage() const DALI_DEPRECATED_API;
+  void SetImage(const std::string& url, ImageDimensions size);
 
 public: // Not intended for application developers
-
   /// @cond internal
   /**
    * @brief Creates a handle using the Toolkit::Internal implementation.
@@ -264,7 +321,7 @@ public: // Not intended for application developers
    * @SINCE_1_0.0
    * @param[in] implementation The ImageView implementation
    */
-  DALI_INTERNAL ImageView( Internal::ImageView& implementation );
+  DALI_INTERNAL ImageView(Internal::ImageView& implementation);
 
   /**
    * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
@@ -272,9 +329,8 @@ public: // Not intended for application developers
    * @SINCE_1_0.0
    * @param[in] internal A pointer to the internal CustomActor
    */
-  DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
+  DALI_INTERNAL ImageView(Dali::Internal::CustomActor* internal);
   /// @endcond
-
 };
 
 /**
@@ -284,4 +340,4 @@ public: // Not intended for application developers
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_IMAGE_VIEW_H__
+#endif // DALI_TOOLKIT_IMAGE_VIEW_H