Deprecate inheritance modes for position 55/60355/3
authorFerran Sole <ferran.sole@samsung.com>
Thu, 25 Feb 2016 12:29:50 +0000 (12:29 +0000)
committerFerran Sole <ferran.sole@samsung.com>
Tue, 1 Mar 2016 11:24:46 +0000 (11:24 +0000)
Position will now behave as rotation and scale: either is inherited
from parent or it isn't

If an actor uses one of the following modes for position inheritance:
USE_PARENT_POSITION
USE_PARENT_POSITION_PLUS_LOCAL_POSITION

has to be changed so the actor's anchor point and parent origin is
at the CENTER and in the case of USE_PARENT_POSITION make sure that local
position is (0,0,0)

Change-Id: Iaed9e9763dcabaaaa764b4baa4b987e710bc1929

dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/internal/update/nodes/node.cpp
dali/internal/update/nodes/node.h
dali/public-api/actors/actor-enumerations.h
dali/public-api/actors/actor.h

index da3e0ba..8982e29 100644 (file)
@@ -229,6 +229,7 @@ DALI_PROPERTY( "heightForWidth",    BOOLEAN,  true,  false, false, Dali::Actor::
 DALI_PROPERTY( "padding",           VECTOR4,  true,  false, false, Dali::Actor::Property::PADDING )
 DALI_PROPERTY( "minimumSize",       VECTOR2,  true,  false, false, Dali::Actor::Property::MINIMUM_SIZE )
 DALI_PROPERTY( "maximumSize",       VECTOR2,  true,  false, false, Dali::Actor::Property::MAXIMUM_SIZE )
+DALI_PROPERTY( "inheritPosition",   BOOLEAN,  true,  false, false, Dali::Actor::Property::INHERIT_POSITION )
 DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
 
 // Signals
@@ -751,6 +752,20 @@ PositionInheritanceMode Actor::GetPositionInheritanceMode() const
   return mPositionInheritanceMode;
 }
 
+void Actor::SetInheritPosition( bool inherit )
+{
+  mInheritPosition = inherit;
+  if( NULL != mNode )
+  {
+    SetInheritPositionMessage( GetEventThreadServices(), *mNode, inherit );
+  }
+}
+
+bool Actor::IsPositionInherited() const
+{
+  return mInheritPosition;
+}
+
 void Actor::SetOrientation( const Radian& angle, const Vector3& axis )
 {
   Vector3 normalizedAxis( axis.x, axis.y, axis.z );
@@ -1927,6 +1942,7 @@ Actor::Actor( DerivedType derivedType )
   mDerivedRequiresWheelEvent( false ),
   mOnStageSignalled( false ),
   mInsideOnSizeSet( false ),
+  mInheritPosition( true ),
   mInheritOrientation( true ),
   mInheritScale( true ),
   mDrawMode( DrawMode::NORMAL ),
@@ -2463,6 +2479,12 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
       break;
     }
 
+    case Dali::Actor::Property::INHERIT_POSITION:
+    {
+      SetInheritPosition( property.Get< bool >() );
+      break;
+    }
+
     case Dali::Actor::Property::INHERIT_ORIENTATION:
     {
       SetInheritOrientation( property.Get< bool >() );
@@ -2970,6 +2992,12 @@ Property::Value Actor::GetDefaultProperty( Property::Index index ) const
       break;
     }
 
+    case Dali::Actor::Property::INHERIT_POSITION:
+    {
+      value = IsPositionInherited();
+      break;
+    }
+
     case Dali::Actor::Property::INHERIT_ORIENTATION:
     {
       value = IsOrientationInherited();
index 362b0b5..1ff3035 100644 (file)
@@ -486,6 +486,16 @@ public:
   PositionInheritanceMode GetPositionInheritanceMode() const;
 
   /**
+   * @copydoc Dali::Actor::SetInheritPosition()
+   */
+  void SetInheritPosition( bool inherit );
+
+  /**
+   * @copydoc Dali::Actor::IsPositionInherited()
+   */
+  bool IsPositionInherited() const;
+
+  /**
    * Sets the orientation of the Actor.
    * @param [in] angleRadians The new orientation angle in radians.
    * @param [in] axis The new axis of orientation.
@@ -1825,6 +1835,7 @@ protected:
   bool mDerivedRequiresWheelEvent                  : 1; ///< Whether the derived actor type requires wheel event signals
   bool mOnStageSignalled                           : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
   bool mInsideOnSizeSet                            : 1; ///< Whether we are inside OnSizeSet
+  bool mInheritPosition                            : 1; ///< Cached: Whether the parent's position should be inherited.
   bool mInheritOrientation                         : 1; ///< Cached: Whether the parent's orientation should be inherited.
   bool mInheritScale                               : 1; ///< Cached: Whether the parent's scale should be inherited.
   DrawMode::Type mDrawMode                         : 2; ///< Cached: How the actor and its children should be drawn
index cf4e92a..52fad10 100644 (file)
@@ -71,6 +71,7 @@ Node::Node()
   mDepth(0u),
   mDirtyFlags(AllFlags),
   mIsRoot( false ),
+  mInheritPosition( true ),
   mInheritOrientation( true ),
   mInheritScale( true ),
   mDrawMode( DrawMode::NORMAL ),
index 1f9478a..7e24335 100644 (file)
@@ -506,6 +506,20 @@ public:
   }
 
   /**
+   * Set whether the Node inherits position.
+   * @param[in] inherit True if the parent position is inherited.
+   */
+  void SetInheritPosition(bool inherit)
+  {
+    if (inherit != mInheritPosition)
+    {
+      mInheritPosition = inherit;
+      mPositionInheritanceMode = inherit ?  INHERIT_PARENT_POSITION : DONT_INHERIT_POSITION;
+      SetDirtyFlag(TransformFlag);
+    }
+  }
+
+  /**
    * Set the position inheritance mode.
    * @see Dali::Actor::PositionInheritanceMode
    * @param[in] mode The new position inheritance mode.
@@ -1041,11 +1055,12 @@ protected:
   int  mDirtyFlags:8;                               ///< A composite set of flags for each of the Node properties
 
   bool mIsRoot:1;                                    ///< True if the node cannot have a parent
+  bool mInheritPosition:1;                           ///< Whether the parent's position should be inherited.
   bool mInheritOrientation:1;                        ///< Whether the parent's orientation should be inherited.
   bool mInheritScale:1;                              ///< Whether the parent's scale should be inherited.
 
   DrawMode::Type          mDrawMode:2;               ///< How the Node and its children should be drawn
-  PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough
+  PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough.
   ColorMode               mColorMode:2;              ///< Determines whether mWorldColor is inherited, 2 bits is enough
 
   // Changes scope, should be at end of class
@@ -1098,6 +1113,17 @@ inline void SetPositionInheritanceModeMessage( EventThreadServices& eventThreadS
   new (slot) LocalType( &node, &Node::SetPositionInheritanceMode, mode );
 }
 
+inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
+{
+  typedef MessageValue1< Node, bool > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &node, &Node::SetInheritPosition, inherit );
+}
+
 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
 {
   typedef MessageValue1< Node, bool > LocalType;
index eeb6f78..fea5c33 100644 (file)
@@ -41,6 +41,7 @@ enum ColorMode
 };
 
 /**
+ * @DEPRECATED_1_1.24 Use SetInheritPosition instead
  * @brief Actor position inheritance mode.
  * @SINCE_1_0.0
  */
index ff2e5a2..24ce48f 100644 (file)
@@ -295,7 +295,7 @@ public:
       INHERIT_ORIENTATION,                                ///< name "inheritOrientation",    type bool @SINCE_1_0.0
       INHERIT_SCALE,                                      ///< name "inheritScale",          type bool @SINCE_1_0.0
       COLOR_MODE,                                         ///< name "colorMode",             type std::string @SINCE_1_0.0
-      POSITION_INHERITANCE,                               ///< name "positionInheritance",   type std::string @SINCE_1_0.0
+      POSITION_INHERITANCE,                               ///< name "positionInheritance",   type std::string @DEPRECATED_1_1.24 Use INHERIT_POSITION instead
       DRAW_MODE,                                          ///< name "drawMode",              type std::string @SINCE_1_0.0
       SIZE_MODE_FACTOR,                                   ///< name "sizeModeFactor",        type Vector3 @SINCE_1_0.0
       WIDTH_RESIZE_POLICY,                                ///< name "widthResizePolicy",     type String @SINCE_1_0.0
@@ -306,6 +306,7 @@ public:
       PADDING,                                            ///< name "padding",               type Vector4 @SINCE_1_0.0
       MINIMUM_SIZE,                                       ///< name "minimumSize",           type Vector2 @SINCE_1_0.0
       MAXIMUM_SIZE,                                       ///< name "maximumSize",           type Vector2 @SINCE_1_0.0
+      INHERIT_POSITION,                                   ///< name "inheritPosition", type bool @SINCE_1_1.24
     };
   };
 
@@ -758,6 +759,7 @@ public:
   Vector3 GetCurrentWorldPosition() const;
 
   /**
+   * @DEPRECATED_1_1.24 Use SetInheritPosition instead
    * @brief Set the actors position inheritance mode.
    *
    * The default is to inherit.
@@ -770,6 +772,21 @@ public:
   void SetPositionInheritanceMode( PositionInheritanceMode mode );
 
   /**
+   * @brief Set whether a child actor inherits it's parent's position.
+   *
+   * Default is to inherit.
+   * Switching this off means that using SetPosition() sets the actor's world position3
+   * @SINCE_1_1.24
+   * @param[in] inherit - true if the actor should inherit position, false otherwise.
+   * @pre The Actor has been initialized.
+   */
+  inline void SetInheritPosition( bool inherit )
+  {
+    SetProperty(Property::INHERIT_POSITION, inherit );
+  }
+
+  /**
+   * @DEPRECATED_1_1.24 Use IsPositionInherited
    * @brief Returns the actors position inheritance mode.
    *
    * @SINCE_1_0.0
@@ -779,6 +796,18 @@ public:
   PositionInheritanceMode GetPositionInheritanceMode() const;
 
   /**
+   * @brief Returns whether the actor inherits its parent's position.
+   *
+   * @SINCE_1_1.24
+   * @return True if the actor inherits its parent position, false if it uses world position.
+   * @pre The Actor has been initialized.
+   */
+  inline bool IsPositionInherited() const
+  {
+    return GetProperty(Property::INHERIT_POSITION ).Get<bool>();
+  }
+
+  /**
    * @brief Sets the orientation of the Actor.
    *
    * An actor's orientation is the rotation from its default orientation, and the rotation is centered around its anchor-point.