X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Flayouting%2Fflex-node.cpp;h=194adae113c0fb584291ab6e37041f4c6f52229e;hb=eccbcc0637034cc96bc6d392b297a9d99e86c442;hp=c2157f13a1164ce37bb945706949b6f8e54a26be;hpb=94676883816fd9006acf918be6d8ff2141910f8d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/layouting/flex-node.cpp b/dali-toolkit/devel-api/layouting/flex-node.cpp index c2157f1..194adae 100644 --- a/dali-toolkit/devel-api/layouting/flex-node.cpp +++ b/dali-toolkit/devel-api/layouting/flex-node.cpp @@ -46,7 +46,7 @@ YGSize MeasureChild(YGNodeRef child, float width, YGMeasureMode measureModeWidth // Get the Node from the YGNodeRef Toolkit::Flex::Node* childNode = static_cast(YGNodeGetContext(child)); - YGSize childSize = YGSize{.width = 1, .height = 1}; // Initialise variable. + YGSize childSize{ 1, 1 }; // Initialise variable. DALI_ASSERT_DEBUG( childNode ); @@ -101,11 +101,11 @@ Node::~Node() DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Destructor() <<\n"); } -void Node::AddChild( Actor child, MeasureCallback measureFunction, int index ) +Node* Node::AddChild( Actor child, Extents margin, MeasureCallback measureFunction, int index ) { if( child ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "AddChild[%s] to node[%p] at index:%d\n", child.GetName().c_str(), mImpl->mYogaNode, index ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "AddChild[%s] to node[%p] at index:%d\n", child.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str(), mImpl->mYogaNode, index ); NodePtr childNode( new Node() ); @@ -113,24 +113,34 @@ void Node::AddChild( Actor child, MeasureCallback measureFunction, int index ) childNode->mImpl->mMeasureCallback = measureFunction; childNode->mImpl->mActor = child; - Vector2 minumumSize = child.GetMinimumSize(); - Vector2 maximumSize = child.GetMaximumSize(); + Vector2 minumumSize = child.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE ); + Vector2 maximumSize = child.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE ); + YGNodeStyleSetMaxWidth( childNode->mImpl->mYogaNode, maximumSize.width ); YGNodeStyleSetMaxHeight( childNode->mImpl->mYogaNode, maximumSize.height ); YGNodeStyleSetMinWidth( childNode->mImpl->mYogaNode, minumumSize.width ); YGNodeStyleSetMinHeight( childNode->mImpl->mYogaNode, minumumSize.height ); + YGNodeStyleSetMargin( childNode->mImpl->mYogaNode, YGEdgeLeft, margin.start ); + YGNodeStyleSetMargin( childNode->mImpl->mYogaNode, YGEdgeTop, margin.top ); + YGNodeStyleSetMargin( childNode->mImpl->mYogaNode, YGEdgeRight, margin.end ); + YGNodeStyleSetMargin( childNode->mImpl->mYogaNode, YGEdgeBottom, margin.bottom ); + YGNodeSetMeasureFunc( childNode->mImpl->mYogaNode, &MeasureChild ); YGNodeInsertChild( mImpl->mYogaNode, childNode->mImpl->mYogaNode, index ); + Node* result = childNode.get(); mImpl->mChildNodes.emplace_back( std::move(childNode) ); + + return result;; } + return nullptr; } void Node::RemoveChild( Actor child ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "RemoveChild child:[%s] from internal nodeCount[%d] childCount[%d]\n", child.GetName().c_str(), YGNodeGetChildCount( mImpl->mYogaNode ), mImpl->mChildNodes.size() ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "RemoveChild child:[%s] from internal nodeCount[%d] childCount[%d]\n", child.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str(), YGNodeGetChildCount( mImpl->mYogaNode ), mImpl->mChildNodes.size() ); auto iterator = std::find_if( mImpl->mChildNodes.begin(),mImpl->mChildNodes.end(), [&child]( NodePtr& childNode ){ return childNode->mImpl->mActor.GetHandle() == child;}); @@ -152,7 +162,7 @@ SizeTuple Node::MeasureNode( float width, int widthMode, float height, int heigh Toolkit::Flex::SizeTuple nodeSize{8,8}; // Default size set to 8,8 to aid bug detection. if( mImpl->mMeasureCallback && mImpl->mActor.GetHandle() ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MeasureNode MeasureCallback executing on %s\n", mImpl->mActor.GetHandle().GetName().c_str() ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MeasureNode MeasureCallback executing on %s\n", mImpl->mActor.GetHandle().GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() ); nodeSize = mImpl->mMeasureCallback( mImpl->mActor.GetHandle(), width, widthMode, height, heightMode ); } DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MeasureNode nodeSize width:%f height:%f\n", nodeSize.width, nodeSize.height ); @@ -244,6 +254,78 @@ Dali::Toolkit::Flex::Alignment Node::GetFlexItemsAlignment() const return static_cast( YGNodeStyleGetAlignItems( mImpl->mYogaNode )); } +void Node::SetFlexAlignmentSelf( Dali::Toolkit::Flex::Alignment flexAlignmentSelf ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Set flex alignment self [%d] on mYogaNode[%p]\n", flexAlignmentSelf, mImpl->mYogaNode ) + + YGNodeStyleSetAlignSelf( mImpl->mYogaNode, static_cast(flexAlignmentSelf) ); +} + +Dali::Toolkit::Flex::Alignment Node::GetFlexAlignmentSelf() const +{ + return static_cast(YGNodeStyleGetAlignSelf( mImpl->mYogaNode )); +} + +void Node::SetFlexPositionType( Dali::Toolkit::Flex::PositionType flexPositionType ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Set flex position type [%d] on mYogaNode[%p]\n", flexPositionType, mImpl->mYogaNode ) + + YGNodeStyleSetPositionType( mImpl->mYogaNode, static_cast(flexPositionType) ); +} + +Dali::Toolkit::Flex::PositionType Node::GetFlexPositionType() const +{ + return static_cast(YGNodeStyleGetPositionType( mImpl->mYogaNode )); +} + +void Node::SetFlexAspectRatio( float flexAspectRatio ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Set flex aspect ratio [%d] on mYogaNode[%p]\n", flexAspectRatio, mImpl->mYogaNode ) + + YGNodeStyleSetAspectRatio( mImpl->mYogaNode, static_cast(flexAspectRatio) ); +} + +float Node::GetFlexAspectRatio() const +{ + return static_cast(YGNodeStyleGetAspectRatio( mImpl->mYogaNode )); +} + +void Node::SetFlexBasis( float flexBasis ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Set flex basis [%d] on mYogaNode[%p]\n", flexBasis, mImpl->mYogaNode ) + + YGNodeStyleSetFlexBasis( mImpl->mYogaNode, static_cast(flexBasis) ); +} + +float Node::GetFlexBasis() const +{ + return static_cast(YGNodeStyleGetFlexBasis( mImpl->mYogaNode ).value); +} + +void Node::SetFlexShrink( float flexShrink ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Set flex shrink [%d] on mYogaNode[%p]\n", flexShrink, mImpl->mYogaNode ) + + YGNodeStyleSetFlexShrink( mImpl->mYogaNode, static_cast(flexShrink) ); +} + +float Node::GetFlexShrink() const +{ + return static_cast(YGNodeStyleGetFlexShrink( mImpl->mYogaNode )); +} + +void Node::SetFlexGrow( float flexGrow ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Set flex grow [%d] on mYogaNode[%p]\n", flexGrow, mImpl->mYogaNode ) + + YGNodeStyleSetFlexGrow( mImpl->mYogaNode, static_cast(flexGrow) ); +} + +float Node::GetFlexGrow() const +{ + return static_cast(YGNodeStyleGetFlexGrow( mImpl->mYogaNode )); +} + float Node::GetFlexWidth() const { float flexWidth = YGNodeLayoutGetWidth( mImpl->mYogaNode );