Add widget to a new parent when the widget being dragged is dropped, otherwise add it to the orphanlist so that it's drawn anyways. NOTE: The dropped widget can be clipped. If it is clipped, it never shows up even tho it's there.

--HG--
branch : dfighter-tools
This commit is contained in:
dfighter1985 2014-09-24 18:45:52 +02:00
parent f9dbef7df7
commit bd7cb1eea3
3 changed files with 49 additions and 1 deletions

View file

@ -57,6 +57,7 @@ namespace NLGUI
CInterfaceElement* findFromShortId(const std::string &id);
/// Dynamic creation
virtual void addElement (CInterfaceElement *child, sint eltOrder = -1 );
virtual void addView (CViewBase *child , sint eltOrder = -1);
virtual void addCtrl (CCtrlBase *child, sint eltOrder = -1);
virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1);

View file

@ -911,6 +911,31 @@ namespace NLGUI
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceGroup::addElement (CInterfaceElement *child, sint eltOrder /*= -1*/)
{
if (!child)
{
nlwarning("<CInterfaceGroup::addView> : tried to add a NULL view");
return;
}
if( child->isGroup() )
{
addGroup( static_cast< CInterfaceGroup* >( child ), eltOrder );
}
else
if( child->isCtrl() )
{
addCtrl( static_cast< CCtrlBase* >( child ), eltOrder );
}
else
if( child->isView() )
{
addView( static_cast< CViewBase* >( child ), eltOrder );
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceGroup::addView (CViewBase *child, sint eltOrder /*= -1*/)
{
@ -1312,6 +1337,11 @@ namespace NLGUI
for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++)
{
CViewBase *pVB = *ite;
if( pVB->getName() == "=MARKED=" )
{
nlinfo( "=MARKED=" );
}
if (pVB->getActive())
pVB->draw();
}

View file

@ -2673,7 +2673,24 @@ namespace NLGUI
{
if( draggedElement != NULL )
{
_OrphanElements.push_back( draggedElement );
CInterfaceGroup *g = getGroupUnder( draggedElement->getXReal(), draggedElement->getYReal() );
if( g != NULL )
{
CInterfaceElement *e = draggedElement;
e->setName( "=MARKED=" );
e->setParent( g );
e->setIdRecurse( e->getShortId() );
g->addElement( e );
e->setParentPos( g );
e->setParentSize( g );
checkCoords();
}
else
_OrphanElements.push_back( draggedElement );
draggedElement = NULL;
}
}