No need for free floating elements when we can simply reparent to the top window...

--HG--
branch : dfighter-tools
hg/feature/light_cycle
dfighter1985 10 years ago
parent e7ab56beea
commit a658be39b7

@ -533,7 +533,6 @@ namespace NLGUI
NLMISC::CRefPtr< CViewBase > _CapturedView; NLMISC::CRefPtr< CViewBase > _CapturedView;
NLMISC::CRefPtr< CInterfaceElement > draggedElement; // the element that we're currently dragging NLMISC::CRefPtr< CInterfaceElement > draggedElement; // the element that we're currently dragging
std::vector< NLMISC::CRefPtr< CInterfaceElement > > _OrphanElements; // elements that were dragged out of their parents
bool startDragging(); bool startDragging();
void stopDragging(); void stopDragging();

@ -1037,8 +1037,6 @@ namespace NLGUI
setCapturePointerRight(NULL); setCapturePointerRight(NULL);
_CapturedView = NULL; _CapturedView = NULL;
_OrphanElements.clear();
resetColorProps(); resetColorProps();
resetAlphaRolloverSpeedProps(); resetAlphaRolloverSpeedProps();
resetGlobalAlphasProps(); resetGlobalAlphasProps();
@ -2041,15 +2039,6 @@ namespace NLGUI
} }
} }
std::vector< NLMISC::CRefPtr< CInterfaceElement > >::iterator oeitr = _OrphanElements.begin();
while( oeitr != _OrphanElements.end() )
{
CInterfaceElement *e = *oeitr;
CViewBase *v = dynamic_cast< CViewBase* >( e );
v->draw();
++oeitr;
}
if( draggedElement != NULL ) if( draggedElement != NULL )
{ {
CInterfaceElement *e = draggedElement; CInterfaceElement *e = draggedElement;
@ -2411,44 +2400,20 @@ namespace NLGUI
if (!CCtrlDraggable::getDraggedSheet()) if (!CCtrlDraggable::getDraggedSheet())
{ {
if( CInterfaceElement::getEditorMode() ) // Take the top most control.
uint nMaxDepth = 0;
const std::vector< CCtrlBase* >& _CtrlsUnderPointer = getCtrlsUnderPointer();
for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--)
{ {
std::vector< NLMISC::CRefPtr< CInterfaceElement > >::reverse_iterator itr = _OrphanElements.rbegin(); CCtrlBase *ctrl= _CtrlsUnderPointer[i];
while( itr != _OrphanElements.rend() ) if (ctrl && ctrl->isCapturable() && ctrl->isInGroup( pNewCurrentWnd ) )
{ {
CInterfaceElement *e = *itr; uint d = ctrl->getDepth( pNewCurrentWnd );
if (d > nMaxDepth)
int x = getPointer()->getXReal();
int y = getPointer()->getYReal();
if( e->isIn( x, y ) )
{ {
_CapturedView = static_cast< CViewBase* >( e ); nMaxDepth = d;
setCapturePointerLeft( ctrl );
captured = true; captured = true;
break;
}
++itr;
}
}
if( !captured )
{
// Take the top most control.
uint nMaxDepth = 0;
const std::vector< CCtrlBase* >& _CtrlsUnderPointer = getCtrlsUnderPointer();
for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--)
{
CCtrlBase *ctrl= _CtrlsUnderPointer[i];
if (ctrl && ctrl->isCapturable() && ctrl->isInGroup( pNewCurrentWnd ) )
{
uint d = ctrl->getDepth( pNewCurrentWnd );
if (d > nMaxDepth)
{
nMaxDepth = d;
setCapturePointerLeft( ctrl );
captured = true;
}
} }
} }
} }
@ -2690,7 +2655,7 @@ namespace NLGUI
e->setParent( NULL ); e->setParent( NULL );
draggedElement = e; draggedElement = e;
return true; return true;
} }
@ -2700,20 +2665,16 @@ namespace NLGUI
{ {
CInterfaceGroup *g = getGroupUnder( draggedElement->getXReal(), draggedElement->getYReal() ); CInterfaceGroup *g = getGroupUnder( draggedElement->getXReal(), draggedElement->getYReal() );
CInterfaceElement *e = draggedElement; CInterfaceElement *e = draggedElement;
CInterfaceGroup *tw = getTopWindow();
if( g == NULL )
g = tw;
e->setParent( g ); e->setParent( g );
e->setIdRecurse( e->getShortId() ); e->setIdRecurse( e->getShortId() );
e->setParentPos( g ); e->setParentPos( g );
e->setParentSize( g ); e->setParentSize( g );
g->addElement( e );
if( g != NULL )
{
g->addElement( e );
}
else
_OrphanElements.push_back( draggedElement );
checkCoords();
draggedElement = NULL; draggedElement = NULL;
} }
@ -3513,8 +3474,6 @@ namespace NLGUI
CWidgetManager::~CWidgetManager() CWidgetManager::~CWidgetManager()
{ {
_OrphanElements.clear();
for (uint32 i = 0; i < _MasterGroups.size(); ++i) for (uint32 i = 0; i < _MasterGroups.size(); ++i)
{ {
delete _MasterGroups[i].Group; delete _MasterGroups[i].Group;

Loading…
Cancel
Save