X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fflex-container%2Fflex-container-impl.cpp;h=e1849bf997c111850bcc265f547df79f28454a6a;hp=1ccd84038e010ecdd6307587ac69cde7e879c03c;hb=314c314b2b44e77d5f9b48056c83bc9f33f58130;hpb=caf7677175a0e8b9c690d4f2ab73adc295f22c0e diff --git a/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp b/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp old mode 100644 new mode 100755 index 1ccd840..e1849bf --- a/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp +++ b/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -175,7 +176,6 @@ bool IsNodeDirty( void *itemNodes ) // style properties are changed. So should always return true here. return true; } - } // Unnamed namespace Toolkit::FlexContainer FlexContainer::New() @@ -205,12 +205,42 @@ FlexContainer::~FlexContainer() mChildrenNodes.clear(); } -void FlexContainer::SetContentDirection( Toolkit::FlexContainer::ContentDirection contentDirection ) +void FlexContainer::SetContentDirection( Toolkit::FlexContainer::ContentDirection contentDirection) { if( mContentDirection != contentDirection ) { - mContentDirection = contentDirection; - mRootNode.node->style.direction = static_cast( mContentDirection ); + Dali::CustomActor ownerActor(GetOwner()); + + if( Toolkit::FlexContainer::INHERIT != contentDirection ) + { + mContentDirection = contentDirection; + + ownerActor.SetProperty( Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION, false ); + + if( Toolkit::FlexContainer::LTR == contentDirection ) + { + ownerActor.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::LEFT_TO_RIGHT); + } + else + { + ownerActor.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT); + } + } + else + { + ownerActor.SetProperty( Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION, true ); + + Dali::LayoutDirection::Type layoutDirection = static_cast( ownerActor.GetParent().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + + if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection ) + { + mContentDirection = Toolkit::FlexContainer::RTL; + } + else + { + mContentDirection = Toolkit::FlexContainer::LTR; + } + } RelayoutRequest(); } @@ -465,12 +495,6 @@ Property::Value FlexContainer::GetProperty( BaseObject* object, Property::Index void FlexContainer::OnChildAdd( Actor& child ) { - Control::OnChildAdd( child ); - - // Anchor actor to top left of the container - child.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - child.SetParentOrigin( ParentOrigin::TOP_LEFT ); - // Create a new node for the child. FlexItemNode childNode; childNode.actor = child; @@ -478,6 +502,8 @@ void FlexContainer::OnChildAdd( Actor& child ) childNode.node->get_child = GetChildNodeAtIndex; childNode.node->is_dirty = IsNodeDirty; mChildrenNodes.push_back(childNode); + + Control::OnChildAdd( child ); } void FlexContainer::OnChildRemove( Actor& child ) @@ -505,6 +531,13 @@ void FlexContainer::OnRelayout( const Vector2& size, RelayoutContainer& containe Actor child = mChildrenNodes[i].actor.GetHandle(); if( child ) { + // Anchor actor to top left of the container + if( child.GetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >() ) + { + child.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + } + child.SetParentOrigin( ParentOrigin::TOP_LEFT ); + float negotiatedWidth = child.GetRelayoutSize(Dimension::WIDTH); float negotiatedHeight = child.GetRelayoutSize(Dimension::HEIGHT); @@ -562,11 +595,33 @@ void FlexContainer::OnSizeSet( const Vector3& size ) RelayoutRequest(); } + + Control::OnSizeSet( size ); } -void FlexContainer::OnSizeAnimation( Animation& animation, const Vector3& targetSize ) +void FlexContainer::OnLayoutDirectionChanged( Dali::Actor actor, Dali::LayoutDirection::Type type ) { - // @todo Animate the children to their target size and position + Toolkit::FlexContainer flexContainer = Toolkit::FlexContainer::DownCast(actor); + Toolkit::FlexContainer::ContentDirection direction; + + if( type == Dali::LayoutDirection::RIGHT_TO_LEFT ) + { + direction = Toolkit::FlexContainer::RTL; + } + else + { + direction = Toolkit::FlexContainer::LTR; + } + + Toolkit::Internal::FlexContainer &flexContainerImpl = GetImpl( flexContainer ); + + if( flexContainerImpl.mContentDirection != direction ) + { + Dali::CustomActor ownerActor(flexContainerImpl.GetOwner()); + flexContainerImpl.mContentDirection = direction; + + flexContainerImpl.RelayoutRequest(); + } } void FlexContainer::ComputeLayout() @@ -640,7 +695,29 @@ void FlexContainer::ComputeLayout() } // Calculate the layout - layoutNode( mRootNode.node, Self().GetMaximumSize().x, Self().GetMaximumSize().y, mRootNode.node->style.direction ); + css_direction_t nodeLayoutDirection = CSS_DIRECTION_INHERIT; + switch( mContentDirection ) + { + case Dali::Toolkit::FlexContainer::LTR: + { + nodeLayoutDirection = CSS_DIRECTION_LTR; + break; + } + + case Dali::Toolkit::FlexContainer::RTL: + { + nodeLayoutDirection = CSS_DIRECTION_RTL; + break; + } + + case Dali::Toolkit::FlexContainer::INHERIT: + { + nodeLayoutDirection = CSS_DIRECTION_INHERIT; + break; + } + } + + layoutNode( mRootNode.node, Self().GetMaximumSize().x, Self().GetMaximumSize().y, nodeLayoutDirection); } } @@ -735,6 +812,10 @@ Actor FlexContainer::GetNextKeyboardFocusableActor(Actor currentFocusedActor, To } while ( !mChildrenNodes[nextFocusedActorIndex].actor.GetHandle().IsKeyboardFocusable() ); break; } + default: + { + break; + } } if( nextFocusedActorIndex != currentFocusedActorIndex ) @@ -774,6 +855,8 @@ void FlexContainer::OnInitialize() { // Initialize the node for the flex container itself Dali::Actor self = Self(); + self.LayoutDirectionChangedSignal().Connect( this, &FlexContainer::OnLayoutDirectionChanged ); + mRootNode.actor = self; mRootNode.node = new_css_node(); mRootNode.node->context = &mChildrenNodes;