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 );
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( 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;
}
/**
* @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,
* @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
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
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
mInheritScale( true ),
mPositionUsesAnchorPoint( true ),
mVisible( true ),
- mLayoutDirectionInheritance( true ),
+ mInheritLayoutDirection( true ),
mLayoutDirection( DevelActor::LayoutDirection::LTR ),
mDrawMode( DrawMode::NORMAL ),
mPositionInheritanceMode( Node::DEFAULT_POSITION_INHERITANCE_MODE ),
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;
}
break;
}
- case Dali::DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE:
+ case Dali::DevelActor::Property::INHERIT_LAYOUT_DIRECTION:
{
- value = mLayoutDirectionInheritance;
+ value = IsLayoutDirectionInherited();
break;
}
}
}
+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)
{
}
}
}
-
}
} // namespace Internal
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.
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