Dragged elements will no longer disappear.

This commit is contained in:
dfighter1985 2014-09-24 16:20:25 +02:00
parent 17dcb2acf9
commit 574d24e5e3
2 changed files with 20 additions and 2 deletions

View file

@ -532,7 +532,8 @@ namespace NLGUI
NLMISC::CRefPtr< CViewBase > _CapturedView; NLMISC::CRefPtr< CViewBase > _CapturedView;
NLMISC::CRefPtr< CInterfaceElement > draggedElement; 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();

View file

@ -1036,6 +1036,8 @@ namespace NLGUI
setCapturePointerLeft(NULL); setCapturePointerLeft(NULL);
setCapturePointerRight(NULL); setCapturePointerRight(NULL);
_CapturedView = NULL; _CapturedView = NULL;
_OrphanElements.clear();
resetColorProps(); resetColorProps();
resetAlphaRolloverSpeedProps(); resetAlphaRolloverSpeedProps();
@ -2039,6 +2041,15 @@ 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;
@ -2657,7 +2668,11 @@ namespace NLGUI
void CWidgetManager::stopDragging() void CWidgetManager::stopDragging()
{ {
draggedElement = NULL; if( draggedElement != NULL )
{
_OrphanElements.push_back( draggedElement );
draggedElement = NULL;
}
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -3454,6 +3469,8 @@ 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;