Canvas: ensure z-index is updated on adding new child.

This commit is contained in:
Thomas Geymayer 2013-02-26 12:47:53 +01:00
parent a4ae7b2059
commit 50de873453
2 changed files with 7 additions and 4 deletions

View File

@ -193,6 +193,9 @@ namespace canvas
_transform->addChild( element->getMatrixTransform() );
_children.push_back( ChildList::value_type(child, element) );
// ...and ensure correct ordering
handleZIndexChanged( --_children.end() );
return;
}
@ -239,13 +242,13 @@ namespace canvas
{
if( node->getParent()->getParent() == _node
&& node->getNameString() == "z-index" )
return handleZIndexChanged(node->getParent(), node->getIntValue());
return handleZIndexChanged( findChild(node->getParent()),
node->getIntValue() );
}
//----------------------------------------------------------------------------
void Group::handleZIndexChanged(SGPropertyNode* node, int z_index)
void Group::handleZIndexChanged(ChildList::iterator child, int z_index)
{
ChildList::iterator child = findChild(node);
if( child == _children.end() )
return;

View File

@ -73,7 +73,7 @@ namespace canvas
virtual void childRemoved(SGPropertyNode * child);
virtual void childChanged(SGPropertyNode * child);
void handleZIndexChanged(SGPropertyNode* node, int z_index);
void handleZIndexChanged(ChildList::iterator child, int z_index = 0);
ChildList::iterator findChild(const SGPropertyNode* node);
};