Merge "Update cursor position when the default font style is changed" into devel...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / flex-node.cpp
index c2157f1..cbac8b2 100644 (file)
@@ -46,7 +46,7 @@ YGSize MeasureChild(YGNodeRef child, float width, YGMeasureMode measureModeWidth
   // Get the Node from the YGNodeRef
   Toolkit::Flex::Node* childNode =  static_cast<Toolkit::Flex::Node*>(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 )
+void 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,13 +113,19 @@ 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 );
@@ -130,7 +136,7 @@ void Node::AddChild( Actor child, MeasureCallback measureFunction, int index )
 
 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 +158,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 );