From 5e726cc138f3211a7037c62f8b97e1dfc1e7a76f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 28 Jul 2012 00:17:41 +0200 Subject: [PATCH] CHANGED: #1471 Implemented property querying for CCtrlBase and CInterfaceGroup. --- code/nel/include/nel/gui/ctrl_base.h | 4 +- code/nel/include/nel/gui/interface_element.h | 1 + code/nel/include/nel/gui/interface_parser.h | 1 + code/nel/include/nel/gui/parser.h | 1 + code/nel/src/gui/ctrl_base.cpp | 82 +++++++++++- code/nel/src/gui/interface_element.cpp | 17 ++- code/nel/src/gui/interface_group.cpp | 119 +++++++++++++++++- code/nel/src/gui/interface_parser.cpp | 10 ++ .../gui_editor/widgets/ControlBase.xml | 39 +++++- .../gui_editor/widgets/InterfaceGroup.xml | 115 +++++++++++++++++ 10 files changed, 374 insertions(+), 15 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_base.h b/code/nel/include/nel/gui/ctrl_base.h index d163447d6..4cbdd0add 100644 --- a/code/nel/include/nel/gui/ctrl_base.h +++ b/code/nel/include/nel/gui/ctrl_base.h @@ -30,7 +30,7 @@ namespace NLGUI public: // Tooltip mode - enum TToolTipParentType + enum TToolTipParentType { TTMouse= 0, // The tooltip is displayed relatively to the mouse when it appears TTCtrl= 1, // The tooltip is displayed relatively to the ctrl it comes from when it apeears @@ -56,6 +56,8 @@ namespace NLGUI /// Destructor virtual ~CCtrlBase(); + static std::string tooltipParentToString( TToolTipParentType type ); + // special parse virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup); diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index 8beab9272..657823756 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -341,6 +341,7 @@ namespace NLGUI // set sizeref as a string, like "wh", "wh5" .... void setSizeRef(const std::string &sizeref); std::string getSizeRefAsString() const; + std::string getSizeRefAsString( const sint32 &sizeRef, const sint32 &sizeDivW, const sint32 &sizeDivH ) const; // export some properties REFLECT_EXPORT_START(CInterfaceElement, CReflectable) diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 75a605915..060e2395a 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -168,6 +168,7 @@ namespace NLGUI /// 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); + std::string getLuaClassAssociation( CInterfaceGroup *group ) const; /** * Accessors diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h index d059b1e77..5cc2652d4 100644 --- a/code/nel/include/nel/gui/parser.h +++ b/code/nel/include/nel/gui/parser.h @@ -48,6 +48,7 @@ namespace NLGUI 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 std::string getLuaClassAssociation( CInterfaceGroup *group ) 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/ctrl_base.cpp b/code/nel/src/gui/ctrl_base.cpp index cef775e8d..f3b96bef6 100644 --- a/code/nel/src/gui/ctrl_base.cpp +++ b/code/nel/src/gui/ctrl_base.cpp @@ -60,6 +60,26 @@ namespace NLGUI return false; } + std::string CCtrlBase::tooltipParentToString( TToolTipParentType type ) + { + switch( type ) + { + case TTMouse: + return "mouse"; + break; + + case TTWindow: + return "win"; + break; + + case TTSpecialWindow: + return "special"; + break; + } + + return ""; + } + // *************************************************************************** bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) { @@ -76,7 +96,7 @@ namespace NLGUI _ContextHelp = ucstring(propPtr); - if (strlen(propPtr) > 2) + if( !editorMode && ( strlen(propPtr) > 2 ) ) { if ((propPtr[0] == 'u') && (propPtr[1] == 'i')) _ContextHelp = CI18N::get ((const char *) prop); @@ -86,7 +106,10 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" ); if ((bool)prop && strlen((const char*)prop)>0) { - _ContextHelp = CI18N::get ((const char *) prop); + if( !editorMode ) + _ContextHelp = CI18N::get ((const char *) prop); + else + _ContextHelp = (const char*)prop; } // get dynamic toolTip ActionHandler @@ -147,6 +170,16 @@ namespace NLGUI std::string CCtrlBase::getProperty( const std::string &name ) const { + if( name == "tooltip" ) + { + return _ContextHelp.toString(); + } + else + if( name == "tooltip_i18n" ) + { + return _ContextHelp.toString(); + } + else if( name == "on_tooltip" ) { return _OnContextHelp.toString(); @@ -156,8 +189,49 @@ namespace NLGUI { return _OnContextHelpParams.toString(); } - - return CInterfaceElement::getProperty( name ); + else + if( name == "tooltip_parent" ) + { + return tooltipParentToString( _ToolTipParent ); + } + else + if( name == "tooltip_special_parent" ) + { + return _ToolTipSpecialParent.toString(); + } + else + if( name == "tooltip_posref" ) + { + std::string s; + if( ( _ToolTipParentPosRef == Hotspot_TTAuto ) && ( _ToolTipPosRef == Hotspot_TTAuto ) ) + return "auto"; + else{ + s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRef ); + s += " "; + s += CInterfaceElement::HotSpotToString( _ToolTipPosRef ); + return s; + } + } + else + if( name == "tooltip_posref_alt" ) + { + std::string s; + if( ( _ToolTipParentPosRef == Hotspot_TTAuto ) && ( _ToolTipPosRef == Hotspot_TTAuto ) ) + return "auto"; + else{ + s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRef ); + s += " "; + s += CInterfaceElement::HotSpotToString( _ToolTipPosRef ); + return s; + } + } + else + if( name == "instant_help" ) + { + return toString( _ToolTipInstant ); + } + else + return CInterfaceElement::getProperty( name ); } // *************************************************************************** diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 486a036ef..7f6d5c6d0 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -261,7 +261,7 @@ namespace NLGUI else if( name == "sizeref" ) { - return getSizeRefAsString(); + return getSizeRefAsString( _SizeRef, _SizeDivW, _SizeDivH ); } if( name == "posparent" ) { @@ -300,20 +300,25 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ std::string CInterfaceElement::getSizeRefAsString() const + { + return getSizeRefAsString( _SizeRef, _SizeDivW, _SizeDivH ); + } + + std::string CInterfaceElement::getSizeRefAsString( const sint32 &sizeRef, const sint32 &sizeDivW, sint32 const &sizeDivH ) const { std::string s; - if( ( _SizeRef & 1 ) != 0 ) + if( ( sizeRef & 1 ) != 0 ) { s += "w"; - if( _SizeDivW < 10 ) - s += toString( _SizeDivW ); + if( sizeDivW < 10 ) + s += toString( sizeDivW ); } if( ( _SizeRef & 2 ) != 0 ) { s += "h"; - if( _SizeDivH < 10 ) - s += toString( _SizeDivH ); + if( sizeDivH < 10 ) + s += toString( sizeDivH ); } return s; diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 2baa6633c..c03a238b6 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -355,6 +355,96 @@ namespace NLGUI std::string CInterfaceGroup::getProperty( const std::string &name ) const { + if( name == "overlappable" ) + { + return NLMISC::toString( _Overlappable ); + } + else + if( name == "escapable" ) + { + return NLMISC::toString( _Escapable ); + } + else + if( name == "child_resize_w" ) + { + return NLMISC::toString( _ResizeFromChildW ); + } + else + if( name == "child_resize_h" ) + { + return NLMISC::toString( _ResizeFromChildH ); + } + else + if( name == "child_resize_wmargin" ) + { + return NLMISC::toString( _ResizeFromChildWMargin ); + } + else + if( name == "child_resize_hmargin" ) + { + return NLMISC::toString( _ResizeFromChildHMargin ); + } + else + if( name == "on_active" ) + { + return getOnActiveHandler(); + } + else + if( name == "on_active_params" ) + { + return getOnActiveParams(); + } + else + if( name == "on_deactive" ) + { + return getOnDeactiveHandler(); + } + else + if( name == "on_deactive_params" ) + { + return getOnDeactiveParams(); + } + else + if( name == "max_w" ) + { + return NLMISC::toString( _MaxW ); + } + else + if( name == "max_h" ) + { + return NLMISC::toString( _MaxH ); + } + else + if( name == "max_sizeref" ) + { + return getSizeRefAsString( _GroupSizeRef, _SizeDivW, _SizeDivH ); + } + else + if( name == "max_sizeparent" ) + { + return CWidgetManager::getInstance()->getParser()->getParentSizeMaxAssociation( (CInterfaceElement*)this ); + } + else + if( name == "group_onclick_r" ) + { + return getRightClickHandler(); + } + else + if( name == "group_params_r" ) + { + return getRightClickHandlerParams(); + } + else + if( name == "group_onclick_l" ) + { + return getLeftClickHandler(); + } + else + if( name == "group_params_l" ) + { + return getLeftClickHandlerParams(); + } + else if( name == "on_enter" ) { return getAHOnEnter(); @@ -364,8 +454,33 @@ namespace NLGUI { return getAHOnEnterParams(); } - - return CCtrlBase::getProperty( name ); + else + if( name == "win_priority" ) + { + return NLMISC::toString( _Priority ); + } + else + if( name == "use_cursor" ) + { + return NLMISC::toString( _UseCursor ); + } + else + if( name == "on_escape" ) + { + return getAHOnEscape(); + } + else + if( name == "on_escape_params" ) + { + return getAHOnEscapeParams(); + } + else + if( name == "lua_class" ) + { + return CWidgetManager::getInstance()->getParser()->getLuaClassAssociation( (CInterfaceGroup*)this ); + } + else + return CCtrlBase::getProperty( name ); } diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 3d4ae975b..5bcec4210 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -2017,6 +2017,16 @@ namespace NLGUI _LuaClassAssociation.insert (std::map::value_type(group, luaScript)); } + std::string CInterfaceParser::getLuaClassAssociation( CInterfaceGroup *group ) const + { + std::map< CInterfaceGroup*, std::string >::const_iterator itr = + _LuaClassAssociation.find( group ); + if( itr == _LuaClassAssociation.end() ) + return ""; + else + return itr->second; + } + // *************************************************************************** const std::string &CInterfaceParser::getDefine(const std::string &id) const { diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml index 809ccacfd..a88932411 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml @@ -8,15 +8,50 @@ + + tooltip + string + + + + tooltip_i18n + string + + on_tooltip string - handler + on_tooltip_params string - params + + + + tooltip_parent + string + + + + tooltip_special_parent + string + + + + tooltip_posref + string + auto + + + tooltip_posref_alt + string + auto + + + instant_help + bool + 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 1db3ddf46..f1ca3497b 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 @@ -8,6 +8,96 @@ + + overlappable + bool + true + + + escapable + bool + false + + + child_resize_w + bool + false + + + child_resize_h + bool + false + + + child_resize_wmargin + int + 0 + + + child_resize_hmargin + int + 0 + + + on_active + string + + + + on_active_params + string + + + + on_deactive + string + + + + on_deactive_params + string + + + + max_w + int + 16384 + + + max_h + int + 16384 + + + max_sizeref + string + + + + max_sizeparent + string + parent + + + group_onclick_r + string + + + + group_params_r + string + + + + group_onclick_l + string + + + + group_params_l + string + + on_enter string @@ -18,5 +108,30 @@ string params + + win_proprity + int + 3 + + + use_cursor + bool + true + + + on_escape + string + + + + on_escape_params + string + + + + lua_class + string + +