[Tizen] Modified Layout direction property 86/147086/1 accepted/tizen/4.0/unified/20170907.192416 accepted/tizen/4.0/unified/20170913.003416 submit/tizen/20170912.010434 submit/tizen_4.0/20170901.082413 submit/tizen_4.0/20170907.133944 submit/tizen_4.0/20170908.031457
authortaeyoon0.lee <taeyoon0.lee@samsung.com>
Wed, 30 Aug 2017 12:43:15 +0000 (21:43 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 1 Sep 2017 01:50:32 +0000 (10:50 +0900)
 - LAYOUT_DIRECTION_INHERITANCE to INHERIT_LAYOUT_DIRECTION
 - Added behavior by INHERIT_LAYOUT_DIRECTION

Change-Id: Ia911a834821bd4fa38d44c7fb93d100ac4514450

automated-tests/src/dali/utc-Dali-Actor.cpp
dali/devel-api/actors/actor-devel.h
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h

index 98a6362..ca98cef 100644 (file)
@@ -6163,11 +6163,16 @@ int UtcDaliActorLayoutDirectionProperty(void)
   actor1.Add( actor2 );
   gLayoutDirectionType = DevelActor::LayoutDirection::LTR;
   DevelActor::LayoutDirectionChangedSignal( actor2 ).Connect( LayoutDirectionChanged );
+
+  DALI_TEST_EQUALS( actor1.GetProperty< bool >( DevelActor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
   actor1.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, DevelActor::LayoutDirection::RTL );
+  DALI_TEST_EQUALS( actor1.GetProperty< bool >( DevelActor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
+
   DALI_TEST_EQUALS( actor1.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
   DALI_TEST_EQUALS( actor2.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
   DALI_TEST_EQUALS( gLayoutDirectionType, DevelActor::LayoutDirection::RTL, TEST_LOCATION );
 
+  actor1.SetProperty( DevelActor::Property::INHERIT_LAYOUT_DIRECTION, true );
   actor0.Add( actor1 );
   DALI_TEST_EQUALS( actor1.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
   DALI_TEST_EQUALS( actor2.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
@@ -6182,9 +6187,9 @@ int UtcDaliActorLayoutDirectionProperty(void)
   actor3.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
   actor5.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, DevelActor::LayoutDirection::LTR );
 
-  DALI_TEST_EQUALS( actor8.GetProperty< bool >( DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE ), true, TEST_LOCATION );
-  actor8.SetProperty( DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE, false );
-  DALI_TEST_EQUALS( actor8.GetProperty< bool >( DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE ), false, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor8.GetProperty< bool >( DevelActor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
+  actor8.SetProperty( DevelActor::Property::INHERIT_LAYOUT_DIRECTION, false );
+  DALI_TEST_EQUALS( actor8.GetProperty< bool >( DevelActor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
 
   actor7.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
 
@@ -6205,5 +6210,9 @@ int UtcDaliActorLayoutDirectionProperty(void)
   DALI_TEST_EQUALS( actor8.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
   DALI_TEST_EQUALS( actor9.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
 
+  actor8.SetProperty( DevelActor::Property::INHERIT_LAYOUT_DIRECTION, true );
+  DALI_TEST_EQUALS( actor8.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
+  DALI_TEST_EQUALS( actor9.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
+
   END_TEST;
 }
index 22085a9..0468d10 100644 (file)
@@ -120,7 +120,7 @@ enum Type
 
   /**
    * @brief The direction of layout.
-   * @details Name "layoutDirection", type Property::STRING.
+   * @details Name "layoutDirection", type Property::INTEGER, @see LayoutDirection::Type for supported values.
    */
   LAYOUT_DIRECTION = CLIPPING_MODE + 5,
 
@@ -128,7 +128,7 @@ enum Type
    * @brief Determines whether child actors inherit the layout direction from a parent.
    * @details Name "layoutDirectionInheritance", type Property::BOOLEAN.
    */
-  LAYOUT_DIRECTION_INHERITANCE = CLIPPING_MODE + 6
+  INHERIT_LAYOUT_DIRECTION = CLIPPING_MODE + 6
 };
 
 } // namespace Property
@@ -149,8 +149,8 @@ namespace LayoutDirection
 
 enum Type
 {
-  LTR,   ///< Left to Right direction (Default).
-  RTL    ///< Right to Left direction.
+  LTR,   ///< Layout direction is from Left to Right direction (Default).
+  RTL    ///< Layout direction is from Right to Left direction.
 };
 
 } // namespace
index 5a97133..9f5c1fb 100644 (file)
@@ -213,7 +213,7 @@ DALI_PROPERTY( "opacity",                   FLOAT,    true,  true,  true,  Dali:
 DALI_PROPERTY( "screenPosition",            VECTOR2,  false, false, false, Dali::DevelActor::Property::SCREEN_POSITION )
 DALI_PROPERTY( "positionUsesAnchorPoint",   BOOLEAN,  true,  false, false, Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT )
 DALI_PROPERTY( "layoutDirection",           STRING,  true,  false, false, Dali::DevelActor::Property::LAYOUT_DIRECTION )
-DALI_PROPERTY( "layoutDirectionInheritance",    BOOLEAN,  true,  false, false, Dali::DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE )
+DALI_PROPERTY( "inheritLayoutDirection",    BOOLEAN,  true,  false, false, Dali::DevelActor::Property::INHERIT_LAYOUT_DIRECTION )
 DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
 
 // Signals
@@ -2124,7 +2124,7 @@ Actor::Actor( DerivedType derivedType )
   mInheritScale( true ),
   mPositionUsesAnchorPoint( true ),
   mVisible( true ),
-  mLayoutDirectionInheritance( true ),
+  mInheritLayoutDirection( true ),
   mLayoutDirection( DevelActor::LayoutDirection::LTR ),
   mDrawMode( DrawMode::NORMAL ),
   mPositionInheritanceMode( Node::DEFAULT_POSITION_INHERITANCE_MODE ),
@@ -2887,24 +2887,22 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
     case Dali::DevelActor::Property::LAYOUT_DIRECTION:
     {
       Dali::DevelActor::LayoutDirection::Type direction = mLayoutDirection;
-      bool flag = false;
 
       if( Scripting::GetEnumerationProperty< DevelActor::LayoutDirection::Type >( property, LAYOUT_DIRECTION_TABLE, LAYOUT_DIRECTION_TABLE_COUNT, direction ) )
       {
-        flag = mLayoutDirectionInheritance;
-        mLayoutDirectionInheritance = true;
+        mInheritLayoutDirection = true;
         InheritLayoutDirectionRecursively( this, direction );
-        mLayoutDirectionInheritance = flag;
+        mInheritLayoutDirection = false;
       }
       break;
     }
 
-    case Dali::DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE:
+    case Dali::DevelActor::Property::INHERIT_LAYOUT_DIRECTION:
     {
       bool value = false;
-      if( property.Get( value ) && value != mLayoutDirectionInheritance )
+      if( property.Get( value ) )
       {
-        mLayoutDirectionInheritance = value;
+        SetInheritLayoutDirection( value );
       }
       break;
     }
@@ -4157,9 +4155,9 @@ bool Actor::GetCachedPropertyValue( Property::Index index, Property::Value& valu
       break;
     }
 
-    case Dali::DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE:
+    case Dali::DevelActor::Property::INHERIT_LAYOUT_DIRECTION:
     {
-      value = mLayoutDirectionInheritance;
+      value = IsLayoutDirectionInherited();
       break;
     }
 
@@ -5333,9 +5331,27 @@ void Actor::LowerBelow( Internal::Actor& target )
   }
 }
 
+void Actor::SetInheritLayoutDirection( bool inherit )
+{
+  if( mInheritLayoutDirection != inherit )
+  {
+    mInheritLayoutDirection = inherit;
+
+    if( inherit && mParent )
+    {
+      InheritLayoutDirectionRecursively( this, mParent->mLayoutDirection );
+    }
+  }
+}
+
+bool Actor::IsLayoutDirectionInherited() const
+{
+  return mInheritLayoutDirection;
+}
+
 void Actor::InheritLayoutDirectionRecursively( ActorPtr actor, Dali::DevelActor::LayoutDirection::Type direction )
 {
-  if( actor && actor->mLayoutDirectionInheritance )
+  if( actor && actor->mInheritLayoutDirection )
   {
     if( actor->mLayoutDirection != direction)
     {
@@ -5353,7 +5369,6 @@ void Actor::InheritLayoutDirectionRecursively( ActorPtr actor, Dali::DevelActor:
       }
     }
   }
-
 }
 
 } // namespace Internal
index 5b3098c..b542de5 100644 (file)
@@ -1921,6 +1921,18 @@ private:
   void SetVisibleInternal( bool visible, SendMessage::Type sendMessage );
 
   /**
+   * Set whether a child actor inherits it's parent's layout direction. Default is to inherit.
+   * @param[in] inherit - true if the actor should inherit layout direction, false otherwise.
+   */
+  void SetInheritLayoutDirection( bool inherit );
+
+  /**
+   * Returns whether the actor inherits it's parent's layout direction.
+   * @return true if the actor inherits it's parent's layout direction, false otherwise.
+   */
+  bool IsLayoutDirectionInherited() const;
+
+  /**
    * @brief Propagates layout direction recursively.
    * @param[in] actor The actor for seting layout direction.
    * @param[in] direction New layout direction.
@@ -1982,7 +1994,7 @@ protected:
   bool mInheritScale                               : 1; ///< Cached: Whether the parent's scale should be inherited.
   bool mPositionUsesAnchorPoint                    : 1; ///< Cached: Whether the position uses the anchor point or not.
   bool mVisible                                    : 1; ///< Cached: Whether the actor is visible or not.
-  bool mLayoutDirectionInheritance                 : 1; ///< Whether the actor inherits the layout direction from parent.
+  bool mInheritLayoutDirection                     : 1; ///< Whether the actor inherits the layout direction from parent.
   DevelActor::LayoutDirection::Type mLayoutDirection  : 1; ///< Layout direction, Left to Right or Right to Left.
   DrawMode::Type mDrawMode                         : 2; ///< Cached: How the actor and its children should be drawn
   PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited