From: taeyoon0.lee Date: Wed, 30 Aug 2017 12:43:15 +0000 (+0900) Subject: Modified Layout direction property X-Git-Tag: dali_1.2.56~3^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=6b31f8550d0a11ccdf09aedbcddb33549f47cdd7 Modified Layout direction property - LAYOUT_DIRECTION_INHERITANCE to INHERIT_LAYOUT_DIRECTION - Added behavior by INHERIT_LAYOUT_DIRECTION Change-Id: Ia911a834821bd4fa38d44c7fb93d100ac4514450 --- diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 98a6362..786be23 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -6135,42 +6135,47 @@ int UtcDaliActorLayoutDirectionProperty(void) tet_infoline( "Check layout direction property" ); Actor actor0 = Actor::New(); - DALI_TEST_EQUALS( actor0.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor0.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Stage::GetCurrent().Add( actor0 ); application.SendNotification(); application.Render(); Actor actor1 = Actor::New(); - DALI_TEST_EQUALS( actor1.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor1.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Actor actor2 = Actor::New(); - DALI_TEST_EQUALS( actor2.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor2.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Actor actor3 = Actor::New(); - DALI_TEST_EQUALS( actor3.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor3.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Actor actor4 = Actor::New(); - DALI_TEST_EQUALS( actor4.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor4.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Actor actor5 = Actor::New(); - DALI_TEST_EQUALS( actor5.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor5.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Actor actor6 = Actor::New(); - DALI_TEST_EQUALS( actor6.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor6.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Actor actor7 = Actor::New(); - DALI_TEST_EQUALS( actor7.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor7.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Actor actor8 = Actor::New(); - DALI_TEST_EQUALS( actor8.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor8.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Actor actor9 = Actor::New(); - DALI_TEST_EQUALS( actor9.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); + DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); 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< 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( actor1.GetProperty< bool >( DevelActor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION ); + + DALI_TEST_EQUALS( actor1.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor2.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::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 ); + DALI_TEST_EQUALS( actor1.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor2.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); Stage::GetCurrent().Add( actor3 ); actor3.Add( actor4 ); @@ -6182,28 +6187,32 @@ 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" ); - DALI_TEST_EQUALS( actor3.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION ); - DALI_TEST_EQUALS( actor4.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION ); - DALI_TEST_EQUALS( actor5.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); - DALI_TEST_EQUALS( actor6.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); - DALI_TEST_EQUALS( actor7.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION ); - 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 ); + DALI_TEST_EQUALS( actor3.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor4.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor5.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor6.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor7.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor8.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); actor8.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" ); - 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 ); + DALI_TEST_EQUALS( actor8.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION ); + + actor7.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, DevelActor::LayoutDirection::LTR ); + DALI_TEST_EQUALS( actor7.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor8.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION ); - actor7.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "LTR" ); - DALI_TEST_EQUALS( actor7.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION ); - 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< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); + DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION ); END_TEST; } diff --git a/dali/devel-api/actors/actor-devel.h b/dali/devel-api/actors/actor-devel.h index 22085a9..20d136e 100644 --- a/dali/devel-api/actors/actor-devel.h +++ b/dali/devel-api/actors/actor-devel.h @@ -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. + RTL ///< Layout direction is from Right to Left direction. }; } // namespace diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 5a97133..f7df4d4 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -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,21 @@ 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; - InheritLayoutDirectionRecursively( this, direction ); - mLayoutDirectionInheritance = flag; + mInheritLayoutDirection = false; + InheritLayoutDirectionRecursively( this, direction, true ); } 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; } @@ -4153,13 +4150,13 @@ bool Actor::GetCachedPropertyValue( Property::Index index, Property::Value& valu case Dali::DevelActor::Property::LAYOUT_DIRECTION: { - value = Scripting::GetLinearEnumerationName< DevelActor::LayoutDirection::Type >( mLayoutDirection, LAYOUT_DIRECTION_TABLE, LAYOUT_DIRECTION_TABLE_COUNT ); + value = mLayoutDirection; break; } - case Dali::DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE: + case Dali::DevelActor::Property::INHERIT_LAYOUT_DIRECTION: { - value = mLayoutDirectionInheritance; + value = IsLayoutDirectionInherited(); break; } @@ -5333,9 +5330,27 @@ void Actor::LowerBelow( Internal::Actor& target ) } } -void Actor::InheritLayoutDirectionRecursively( ActorPtr actor, Dali::DevelActor::LayoutDirection::Type direction ) +void Actor::SetInheritLayoutDirection( bool inherit ) { - if( actor && actor->mLayoutDirectionInheritance ) + 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, bool set ) +{ + if( actor && ( actor->mInheritLayoutDirection || set ) ) { if( actor->mLayoutDirection != direction) { @@ -5353,7 +5368,6 @@ void Actor::InheritLayoutDirectionRecursively( ActorPtr actor, Dali::DevelActor: } } } - } } // namespace Internal diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 5b3098c..1a45748 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -1921,11 +1921,23 @@ 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. */ - void InheritLayoutDirectionRecursively( ActorPtr actor, Dali::DevelActor::LayoutDirection::Type direction ); + void InheritLayoutDirectionRecursively( ActorPtr actor, Dali::DevelActor::LayoutDirection::Type direction, bool set = false ); protected: @@ -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