Add API to UpdateProxy
[platform/core/uifw/dali-core.git] / dali / devel-api / update / update-proxy.h
index 2ea1194..0698b9a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_UPDATE_PROXY_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -18,6 +18,9 @@
  *
  */
 
+// EXTERNAL INCLUDES
+#include <cstdint>
+
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/math/matrix.h>
@@ -25,7 +28,6 @@
 
 namespace Dali
 {
-
 namespace Internal DALI_INTERNAL
 {
 class UpdateProxy;
@@ -43,95 +45,137 @@ class UpdateProxy;
 class DALI_CORE_API UpdateProxy
 {
 public:
+  /**
+   * @brief Given the Actor ID, this retrieves that Actor's local position.
+   * @param[in]   id        The Actor ID
+   * @param[out]  position  Set to the Actor's current position, if Actor ID is valid
+   * @return Whether the method call was successful or not.
+   */
+  bool GetPosition(uint32_t id, Vector3& position) const;
 
   /**
-   * @brief Given the Actor ID, this retrieves that Actor's position.
-   * @param[in]  id  The Actor ID
-   * @return If valid Actor ID, then the Actor's position is returned.
+   * @brief Allows setting an Actor's local position from the Frame callback function for the current frame only.
+   * @param[in]  id        The Actor ID
+   * @param[in]  position  The position to set
+   * @return Whether the method call was successful or not.
+   * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
    */
-  Vector3 GetPosition( unsigned int id ) const;
+  bool SetPosition(uint32_t id, const Vector3& position);
 
   /**
-   * @brief Allows setting an Actor's position from the Frame callback function.
+   * @brief Allows baking an Actor's local position from the Frame callback function.
    * @param[in]  id        The Actor ID
-   * @param[in]  position  The position to set.
-   * @note This will get reset to the internally calculated value in the next frame, so will have to be set again.
+   * @param[in]  position  The position to bake
+   * @return Whether the method call was successful or not.
+   * @note The value is saved so will cause undesired effects if this property is being animated.
    */
-  void SetPosition( unsigned int id, const Vector3& position );
+  bool BakePosition(uint32_t id, const Vector3& position);
 
   /**
    * @brief Given the Actor ID, this retrieves that Actor's size.
-   * @param[in]  id  The Actor ID
-   * @return If valid Actor ID, then Actor's size is returned, otherwise Vector3::ZERO.
+   * @param[in]   id    The Actor ID
+   * @param[out]  size  Set to the Actor's current size, if Actor ID is valid
+   * @return Whether the method call was successful or not.
    */
-  const Vector3& GetSize( unsigned int id ) const;
+  bool GetSize(uint32_t id, Vector3& size) const;
 
   /**
-   * @brief Allows setting an Actor's size from the Frame callback function.
+   * @brief Allows setting an Actor's size from the Frame callback function for the current frame only.
    * @param[in]  id    The Actor ID
-   * @param[in]  size  The size to set.
-   * @note This will get reset to the internally calculated value in the next frame, so will have to be set again.
+   * @param[in]  size  The size to set
+   * @return Whether the method call was successful or not.
+   * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
    */
-  void SetSize( unsigned int id, const Vector3& size );
+  bool SetSize(uint32_t id, const Vector3& size);
 
   /**
-   * @brief Given the Actor ID, this retrieves that Actor's position and size.
+   * @brief Allows baking an Actor's size from the Frame callback function.
+   * @param[in]  id    The Actor ID
+   * @param[in]  size  The size to bake
+   * @return Whether the method call was successful or not.
+   * @note The value is saved so will cause undesired effects if this property is being animated.
+   */
+  bool BakeSize(uint32_t id, const Vector3& size);
+
+  /**
+   * @brief Given the Actor ID, this retrieves that Actor's local position and size.
    * @param[in]   id        The Actor ID
-   * @param[out]  position  If valid Actor ID, then Actor's position is set
-   * @param[out]  size      If valid Actor ID, then Actor's size is set
+   * @param[out]  position  Set to the Actor's current position, if Actor ID is valid
+   * @param[out]  size      Set to the Actor's current size, if Actor ID is valid
+   * @return Whether the method call was successful or not.
    */
-  void GetPositionAndSize( unsigned int id, Vector3& position, Vector3& size ) const;
+  bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const;
 
   /**
-   * @brief Given the Actor ID, this retrieves that Actor's color.
+   * @brief Given the Actor ID, this retrieves that Actor's world position and size.
    * @param[in]   id        The Actor ID
-   * @return If valid Actor ID, then Actor's color is returned, otherwise Vector4::ZERO.
+   * @param[out]  position  Set to the Actor's current world position, if Actor ID is valid
+   * @param[out]  scale     Set to the Actor's current world scale, if Actor ID is valid
+   * @param[out]  size      Set to the Actor's current size, if Actor ID is valid
+   * @return Whether the method call was successful or not.
    */
-  Vector4 GetWorldColor( unsigned int id ) const;
+  bool GetWorldPositionScaleAndSize(uint32_t id, Vector3& position, Vector3& scale, Vector3& size) const;
 
   /**
-   * @brief Allows setting an Actor's color from the Frame callback function.
+   * @brief Given the Actor ID, this retrieves that Actor's local scale.
+   * @param[in]   id     The Actor ID
+   * @param[out]  scale  Set to the Actor's current scale, if Actor ID is valid
+   * @return Whether the method call was successful or not.
+   */
+  bool GetScale(uint32_t id, Vector3& scale) const;
+
+  /**
+   * @brief Allows setting an Actor's local scale from the Frame callback function for the current frame only.
    * @param[in]  id     The Actor ID
-   * @param[in]  color  The color to set
-   * @note This will get reset to the internally calculated value in the next frame, so will have to be set again.
+   * @param[in]  scale  The scale to set
+   * @return Whether the method call was successful or not.
+   * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
    */
-  void SetWorldColor( unsigned int id, const Vector4& color ) const;
+  bool SetScale(uint32_t id, const Vector3& scale);
 
   /**
-   * @brief Given the Actor ID, this retrieves that Actor's world-matrix and size.
-   * @param[in]   id           The Actor ID
-   * @param[out]  worldMatrix  If valid Actor ID, then Actor's world matrix is set
-   * @param[out]  size         If valid Actor ID, then Actor's size is set
+   * @brief Allows baking an Actor's local scale from the Frame callback function.
+   * @param[in]  id     The Actor ID
+   * @param[in]  scale  The scale to bake
+   * @return Whether the method call was successful or not.
+   * @note The value is saved so will cause undesired effects if this property is being animated.
    */
-  void GetWorldMatrixAndSize( unsigned int id, Matrix& worldMatrix, Vector3& size ) const;
+  bool BakeScale(uint32_t id, const Vector3& scale);
 
   /**
-   * @brief Given the Actor ID, this retrieves that Actor's world-matrix.
-   * @param[in]  id  The Actor ID
-   * @return If valid Actor ID, then Actor's world matrix is returned, otherwise Matrix::IDENTITY.
+   * @brief Given the Actor ID, this retrieves that Actor's local color.
+   * @param[in]   id     The Actor ID
+   * @param[out]  color  Set to the Actor's current color, if Actor ID is valid
+   * @return Whether the method call was successful or not.
    */
-  const Matrix& GetWorldMatrix( unsigned int id ) const;
+  bool GetColor(uint32_t id, Vector4& color) const;
 
   /**
-   * @brief Allows the setting an Actor's world-matrix from the Frame callback function.
-   * @param[in]  id           The Actor ID
-   * @param[in]  worldMatrix  The world matrix to set.
-   * @note This will get reset to the internally calculated value in the next frame, so will have to be set again.
-   * @note This will only set the world matrix for that particular actor.
-   *       The world matrices of the children will not change and will have to be manually changed in the callback
-   *       as well (if required).
+   * @brief Allows setting an Actor's local color from the Frame callback function for the current frame only.
+   * @param[in]  id     The Actor ID
+   * @param[in]  color  The color to set
+   * @return Whether the method call was successful or not.
+   * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
    */
-  void SetWorldMatrix( unsigned int id, const Matrix& worldMatrix );
+  bool SetColor(uint32_t id, const Vector4& color);
 
-public: // Not intended for application developers
+  /**
+   * @brief Allows baking an Actor's local color from the Frame callback function.
+   * @param[in]  id     The Actor ID
+   * @param[in]  color  The color to bake
+   * @return Whether the method call was successful or not.
+   * @note The value is saved so will cause undesired effects if this property is being animated.
+   */
+  bool BakeColor(uint32_t id, const Vector4& color);
 
+public: // Not intended for application developers
   /// @cond internal
 
   /**
    * @brief Constructor.
    * @param[in]  impl  A reference to the internal object.
    */
-  DALI_INTERNAL UpdateProxy( Internal::UpdateProxy& impl );
+  DALI_INTERNAL UpdateProxy(Internal::UpdateProxy& impl);
 
   /**
    * @brief Destructor.
@@ -140,15 +184,14 @@ public: // Not intended for application developers
 
   // Not copyable or movable
 
-  UpdateProxy( const UpdateProxy& )            = delete; ///< Deleted copy constructor
-  UpdateProxy( UpdateProxy&& )                 = delete; ///< Deleted move constructor
-  UpdateProxy& operator=( const UpdateProxy& ) = delete; ///< Deleted copy assignment operator
-  UpdateProxy& operator=( UpdateProxy&& )      = delete; ///< Deleted move assignment operator
+  UpdateProxy(const UpdateProxy&) = delete;            ///< Deleted copy constructor
+  UpdateProxy(UpdateProxy&&)      = delete;            ///< Deleted move constructor
+  UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator
+  UpdateProxy& operator=(UpdateProxy&&) = delete;      ///< Deleted move assignment operator
 
   /// @endcond
 
 private:
-
   /// @cond internal
   Internal::UpdateProxy& mImpl;
   /// @endcond