Changed draw ordering to take into account the depth of the node in the hierarchy
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / node.cpp
index 1b74e67..db5798f 100644 (file)
@@ -59,6 +59,7 @@ Node::Node()
   mExclusiveRenderTask( NULL ),
   mAttachment( NULL ),
   mChildren(),
+  mDepth(0u),
   mDirtyFlags(AllFlags),
   mIsRoot( false ),
   mInheritOrientation( true ),
@@ -95,6 +96,11 @@ void Node::Attach( NodeAttachment& object )
 
   mAttachment = &object;
   SetAllDirtyFlags();
+
+  if( mIsActive )
+  {
+    mAttachment->ConnectedToSceneGraph();
+  }
 }
 
 void Node::SetRoot(bool isRoot)
@@ -244,6 +250,7 @@ void Node::SetParent(Node& parentNode)
   DALI_ASSERT_ALWAYS(mParent == NULL);
 
   mParent = &parentNode;
+  mDepth = mParent->GetDepth() + 1u;
 }
 
 void Node::RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex, std::set<Node*>& connectedNodes,  std::set<Node*>& disconnectedNodes )
@@ -262,6 +269,7 @@ void Node::RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex, std
 
   // Remove back-pointer to parent
   mParent = NULL;
+  mDepth = 0u;
 
   // Remove all child pointers
   mChildren.Clear();