diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index 9bedd1186..8beab9272 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -121,6 +121,7 @@ namespace NLGUI // help to serialize an action handler static void serialAH(NLMISC::IStream &f, IActionHandler *&ah); + static std::string stripId( const std::string &fullId ); /// Parse the element and initalize it virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); @@ -288,6 +289,7 @@ namespace NLGUI const std::string &defVal); // Parse tools + static std::string HotSpotToString( THotSpot spot ); static THotSpot convertHotSpot (const char *ptr); // static void convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef); static NLMISC::CRGBA convertColor (const char *ptr); diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 6cf364d23..75a605915 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -160,8 +160,11 @@ namespace NLGUI /// Association builders : associate an element of the interface with the string ID of /// another element used as reference for position values void addParentPositionAssociation (CInterfaceElement *element, const std::string &parentID); + std::string getParentPosAssociation( CInterfaceElement *element ) const; void addParentSizeAssociation (CInterfaceElement *element, const std::string &parentID); + std::string getParentSizeAssociation( CInterfaceElement *element ) const; void addParentSizeMaxAssociation (CInterfaceElement *element, const std::string &parentID); + std::string getParentSizeMaxAssociation( CInterfaceElement *element ) const; /// LUA Class Association builder : associate a lua script to a group (called for each group after every document parsed) void addLuaClassAssociation(CInterfaceGroup *group, const std::string &luaScript); diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h index ebc0dd607..d059b1e77 100644 --- a/code/nel/include/nel/gui/parser.h +++ b/code/nel/include/nel/gui/parser.h @@ -45,6 +45,9 @@ namespace NLGUI virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; virtual void addParentSizeMaxAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0; + virtual std::string getParentPosAssociation( CInterfaceElement *element ) const = 0; + virtual std::string getParentSizeAssociation( CInterfaceElement *element ) const = 0; + virtual std::string getParentSizeMaxAssociation( CInterfaceElement *element ) const = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0; virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0; diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 50177bf23..486a036ef 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -73,6 +73,15 @@ namespace NLGUI return _Id; } + std::string CInterfaceElement::stripId( const std::string &fullId ) + { + std::string id = fullId; + std::string::size_type i = id.find_last_of( ':' ); + if( i != std::string::npos ) + id = id.substr( i + 1, id.size() - 1 ); + return id; + } + // ------------------------------------------------------------------------------------------------ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) { @@ -186,35 +195,6 @@ namespace NLGUI if (ptr) { parseSizeRef(ptr.getDatas()); - sint32 nWhat = 0; - const char *seekPtr = ptr.getDatas(); - while (*seekPtr != 0) - { - if ((*seekPtr=='w')||(*seekPtr=='W')) - { - _SizeRef |= 1; - nWhat = 1; - } - - if ((*seekPtr=='h')||(*seekPtr=='H')) - { - _SizeRef |= 2; - nWhat = 2; - } - - if ((*seekPtr>='1')&&(*seekPtr<='9')) - { - if (nWhat != 0) - { - if (nWhat == 1) - _SizeDivW = *seekPtr-'0'; - if (nWhat == 2) - _SizeDivH = *seekPtr-'0'; - } - } - - ++seekPtr; - } } // snapSize(); @@ -249,6 +229,64 @@ namespace NLGUI else return "false"; } + else + if( name == "x" ) + { + return NLMISC::toString( getX() ); + } + else + if( name == "y" ) + { + return NLMISC::toString( getY() ); + } + else + if( name == "w" ) + { + return NLMISC::toString( getW() ); + } + else + if( name == "h" ) + { + return NLMISC::toString( getH() ); + } + else + if( name == "posref" ) + { + std::string posref; + posref = HotSpotToString( getParentPosRef() ); + posref += " "; + posref += HotSpotToString( getPosRef() ); + return posref; + } + else + if( name == "sizeref" ) + { + return getSizeRefAsString(); + } + if( name == "posparent" ) + { + return CWidgetManager::getInstance()->getParser()->getParentPosAssociation( (CInterfaceElement*)this ); + } + else + if( name == "sizeparent" ) + { + return CWidgetManager::getInstance()->getParser()->getParentSizeAssociation( (CInterfaceElement*)this ); + } + else + if( name == "global_color" ) + { + return toString( _ModulateGlobalColor ); + } + else + if( name == "render_layer" ) + { + return toString( _RenderLayer ); + } + else + if( name == "avoid_resize_parent" ) + { + return toString( _AvoidResizeParent ); + } return ""; } @@ -263,7 +301,22 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ std::string CInterfaceElement::getSizeRefAsString() const { - return "IMPLEMENT ME!"; + std::string s; + if( ( _SizeRef & 1 ) != 0 ) + { + s += "w"; + if( _SizeDivW < 10 ) + s += toString( _SizeDivW ); + } + + if( ( _SizeRef & 2 ) != 0 ) + { + s += "h"; + if( _SizeDivH < 10 ) + s += toString( _SizeDivH ); + } + + return s; } // ------------------------------------------------------------------------------------------------ @@ -704,6 +757,49 @@ namespace NLGUI } } + std::string CInterfaceElement::HotSpotToString( THotSpot spot ) + { + switch( spot ) + { + case Hotspot_TL: + return "TL"; + break; + + case Hotspot_TM: + return "TM"; + break; + + case Hotspot_TR: + return "TR"; + break; + + case Hotspot_ML: + return "ML"; + break; + + case Hotspot_MM: + return "MM"; + break; + + case Hotspot_MR: + return "MR"; + break; + + case Hotspot_BL: + return "BL"; + break; + + case Hotspot_BM: + return "BM"; + break; + + case Hotspot_BR: + return "BR"; + break; + } + + return ""; + } // ------------------------------------------------------------------------------------------------ THotSpot CInterfaceElement::convertHotSpot (const char *ptr) diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index afd118ef5..3d4ae975b 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -1969,18 +1969,48 @@ namespace NLGUI _ParentPositionsMap.insert (std::map::value_type(element, parent)); } + std::string CInterfaceParser::getParentPosAssociation( CInterfaceElement *element ) const + { + std::map< CInterfaceElement*, std::string >::const_iterator itr = + _ParentPositionsMap.find( element ); + if( itr == _ParentPositionsMap.end() ) + return "parent"; + else + return CInterfaceElement::stripId( itr->second ); + } + // ---------------------------------------------------------------------------- void CInterfaceParser::addParentSizeAssociation(CInterfaceElement* element, const std::string& parent) { _ParentSizesMap.insert (std::map::value_type(element, parent)); } + std::string CInterfaceParser::getParentSizeAssociation( CInterfaceElement *element ) const + { + std::map< CInterfaceElement*, std::string >::const_iterator itr = + _ParentSizesMap.find( element ); + if( itr == _ParentSizesMap.end() ) + return "parent"; + else + return CInterfaceElement::stripId( itr->second ); + } + // ---------------------------------------------------------------------------- void CInterfaceParser::addParentSizeMaxAssociation (CInterfaceElement *element, const std::string &parent) { _ParentSizesMaxMap.insert (std::map::value_type(element, parent)); } + std::string CInterfaceParser::getParentSizeMaxAssociation( CInterfaceElement *element ) const + { + std::map< CInterfaceElement*, std::string >::const_iterator itr = + _ParentSizesMap.find( element ); + if( itr == _ParentSizesMap.end() ) + return "parent"; + else + return CInterfaceElement::stripId( itr->second ); + } + // ---------------------------------------------------------------------------- void CInterfaceParser::addLuaClassAssociation (CInterfaceGroup *group, const std::string &luaScript) { diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp index d9e27ecbc..4fd41d1e5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp @@ -91,25 +91,34 @@ namespace GUIEditor void CPropBrowserCtrl::setupProperty( const SPropEntry &prop, const CInterfaceElement *element ) { QtVariantProperty *p = NULL; + QVariant v; if( prop.propType == "string" ) { p = propertyMgr->addProperty( QVariant::String, prop.propName.c_str() ); - p->setValue( element->getProperty( prop.propName ).c_str() ); + v = element->getProperty( prop.propName ).c_str(); } else if( prop.propType == "bool" ) { p = propertyMgr->addProperty( QVariant::Bool, prop.propName.c_str() ); bool value = false; - if( element->getProperty( prop.propName ) == "true" ) - value = true; - - p->setValue( value ); + NLMISC::fromString( element->getProperty( prop.propName ), value ); + v = value; } + else + if( prop.propType == "int" ) + { + p = propertyMgr->addProperty( QVariant::Int, prop.propName.c_str() ); + sint32 value = 0; + NLMISC::fromString( element->getProperty( prop.propName ), value ); + v = value; + } + if( p == NULL ) return; + p->setValue( v ); browser->addProperty( p ); } } \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml index e8a3f0aa2..d4454ce07 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml @@ -1,7 +1,7 @@
InterfaceElement - ie + CInterfaceElement true @@ -17,5 +17,60 @@ bool true + + x + int + 0 + + + y + int + 0 + + + w + int + 0 + + + h + int + 0 + + + posref + string + BL BL + + + sizeref + string + + + + posparent + string + parent + + + sizeparent + string + parent + + + global_color + bool + true + + + render_layer + int + 0 + + + avoid_resize_parent + bool + false + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml index d11ceb180..1db3ddf46 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml @@ -1,7 +1,7 @@
InterfaceGroup - ig + CInterfaceGroup CtrlBase false