From a658be39b71bf9d16946b3e3e89944bd2b027fd9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 24 Sep 2014 22:59:40 +0200 Subject: [PATCH] No need for free floating elements when we can simply reparent to the top window... --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/widget_manager.h | 1 - code/nel/src/gui/widget_manager.cpp | 73 +++++------------------ 2 files changed, 16 insertions(+), 58 deletions(-) diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index ccf561d45..8bd9052e5 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -533,7 +533,6 @@ namespace NLGUI NLMISC::CRefPtr< CViewBase > _CapturedView; 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(); void stopDragging(); diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 771bcf50e..40df50cb2 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -1037,8 +1037,6 @@ namespace NLGUI setCapturePointerRight(NULL); _CapturedView = NULL; - _OrphanElements.clear(); - resetColorProps(); resetAlphaRolloverSpeedProps(); 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 ) { CInterfaceElement *e = draggedElement; @@ -2411,44 +2400,20 @@ namespace NLGUI 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(); - while( itr != _OrphanElements.rend() ) + CCtrlBase *ctrl= _CtrlsUnderPointer[i]; + if (ctrl && ctrl->isCapturable() && ctrl->isInGroup( pNewCurrentWnd ) ) { - CInterfaceElement *e = *itr; - - int x = getPointer()->getXReal(); - int y = getPointer()->getYReal(); - - if( e->isIn( x, y ) ) + uint d = ctrl->getDepth( pNewCurrentWnd ); + if (d > nMaxDepth) { - _CapturedView = static_cast< CViewBase* >( e ); + nMaxDepth = d; + setCapturePointerLeft( ctrl ); 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 ); draggedElement = e; - + return true; } @@ -2700,20 +2665,16 @@ namespace NLGUI { CInterfaceGroup *g = getGroupUnder( draggedElement->getXReal(), draggedElement->getYReal() ); CInterfaceElement *e = draggedElement; + CInterfaceGroup *tw = getTopWindow(); + + if( g == NULL ) + g = tw; e->setParent( g ); e->setIdRecurse( e->getShortId() ); e->setParentPos( g ); e->setParentSize( g ); - - if( g != NULL ) - { - g->addElement( e ); - } - else - _OrphanElements.push_back( draggedElement ); - - checkCoords(); + g->addElement( e ); draggedElement = NULL; } @@ -3513,8 +3474,6 @@ namespace NLGUI CWidgetManager::~CWidgetManager() { - _OrphanElements.clear(); - for (uint32 i = 0; i < _MasterGroups.size(); ++i) { delete _MasterGroups[i].Group;