From 2dd62787719d810f4f47963a0e7a9312fc7e7f55 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Oct 2014 15:26:47 +0200 Subject: [PATCH] Size parent is now queried directly from the widget. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/interface_element.h | 1 + code/nel/src/gui/interface_element.cpp | 37 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index a8a04b454..0f9b271ce 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -494,6 +494,7 @@ namespace NLGUI void setPosParent( const std::string &id ); void getPosParent( std::string &id ) const; void setSizeParent( const std::string &id ); + void getSizeParent( std::string &id ) const; void setSerializable( bool b ){ serializable = b; } bool IsSerializable() const{ return serializable; } diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 0e7458f3a..a18b8e71d 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -154,7 +154,9 @@ namespace NLGUI else if( name == "sizeparent" ) { - return CWidgetManager::getInstance()->getParser()->getParentSizeAssociation( (CInterfaceElement*)this ); + std::string sp; + getSizeParent( sp ); + return sp; } else if( name == "global_color" ) @@ -301,8 +303,8 @@ namespace NLGUI getPosParent( pp ); xmlNewProp( node, BAD_CAST "posparent", BAD_CAST pp.c_str() ); xmlNewProp( node, BAD_CAST "sizeref", BAD_CAST getSizeRefAsString().c_str() ); - xmlNewProp( node, BAD_CAST "sizeparent", - BAD_CAST CWidgetManager::getInstance()->getParser()->getParentSizeAssociation( (CInterfaceElement*)this ).c_str() ); + getSizeParent( pp ); + xmlNewProp( node, BAD_CAST "sizeparent", BAD_CAST pp.c_str() ); xmlNewProp( node, BAD_CAST "global_color", BAD_CAST toString( _ModulateGlobalColor ).c_str() ); xmlNewProp( node, BAD_CAST "render_layer", BAD_CAST toString( _RenderLayer ).c_str() ); @@ -1598,6 +1600,35 @@ namespace NLGUI } } + void CInterfaceElement::getSizeParent( std::string &id ) const + { + CInterfaceElement *p = getParentSize(); + + // If there's no parent set then the size parent is the parent + if( p == NULL ) + { + id = "parent"; + return; + } + + // If the size parent is the same as the group parent, then the size parent is the parent ofc + if( p == getParent() ) + { + id = "parent"; + return; + } + + // If the size parent is in the parent group, use the short Id + if( p->isInGroup( getParent() ) ) + { + id = p->getShortId(); + return; + } + + // Otherwise use the full Id + id = p->getId(); + } + void CInterfaceElement::registerDeletionWatcher( IDeletionWatcher *watcher ) { std::vector< IDeletionWatcher* >::iterator itr