From bd7cb1eea3d4e3d974279b8f4b5e412a1c65bda1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 24 Sep 2014 18:45:52 +0200 Subject: [PATCH] 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 --- code/nel/include/nel/gui/interface_group.h | 1 + code/nel/src/gui/interface_group.cpp | 30 ++++++++++++++++++++++ code/nel/src/gui/widget_manager.cpp | 19 +++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/gui/interface_group.h b/code/nel/include/nel/gui/interface_group.h index ff0efac3b..daf6d2d53 100644 --- a/code/nel/include/nel/gui/interface_group.h +++ b/code/nel/include/nel/gui/interface_group.h @@ -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); diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 4d37eda1c..05f210568 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -911,6 +911,31 @@ namespace NLGUI } } + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::addElement (CInterfaceElement *child, sint eltOrder /*= -1*/) + { + if (!child) + { + nlwarning(" : 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(); } diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 5b131ee36..e44fa4d15 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -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; } }