本文整理汇总了C++中shared_ptr::BelongsToLayer方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::BelongsToLayer方法的具体用法?C++ shared_ptr::BelongsToLayer怎么用?C++ shared_ptr::BelongsToLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::BelongsToLayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitElement
bool GraphicsElementManager::InitElement( shared_ptr<GraphicsElement> pElement, int layer_index )
{
int element_index = GetVacantSlotIndex();
m_vecpElement[element_index] = pElement;
m_vecpElement[element_index]->SetGraphicsElementManager( this );
m_vecpElement[element_index]->ChangeScale( m_fScale );
m_vecpElement[element_index]->SetElementIndex( element_index );
pElement->m_pSelf = pElement;
// if( pElement->GetElementType() != GraphicsElement::TYPE_GROUP )
if( pElement->BelongsToLayer() )
{
// GraphicsElementGroup and CombinedPrimitiveElement do not belong to layer
bool res = RegisterToLayer( element_index, layer_index );
if( !res )
return false;
m_vecpElement[element_index]->SetLayerIndex( layer_index );
}
return true;
}
示例2: RemoveElement
bool GraphicsElementManager::RemoveElement( shared_ptr<GraphicsElement> pElement )
{
if( !pElement // invalid argument
|| !(pElement->m_pManager) ) // already released
{
return false;
}
pElement->OnRemovalRequested();
int element_id = pElement->GetElementIndex();
// callback triggered by element removal
// - used by effect manager to remove effect which is currently being applied to removed element 'pElement'
if( m_pCallbackPtr.get() )
m_pCallbackPtr->OnDestroyed( pElement );
// if( pElement->GetElementType() != GraphicsElement::TYPE_GROUP )
if( pElement->BelongsToLayer() )
{
RemoveFromLayer( pElement );
}
// remove the element from the group to which it currently belongs
int group_id = pElement->GetGroupID();
shared_ptr<GraphicsElementGroup> pGroup;
if( 0 <= group_id
&& GetElement(group_id)->GetElementType() == GraphicsElement::TYPE_GROUP
&& ( pGroup = dynamic_pointer_cast< GraphicsElementGroup, GraphicsElement >(GetElement(group_id)) ) )
{
pGroup->RemoveElementFromGroup( pElement );
}
// SAFE_DELETE( m_vecpElement[element_id] );
m_vecpElement[element_id].reset();
pElement->Release();
return true;
}