diff --git a/code/nel/include/nel/gui/ctrl_base.h b/code/nel/include/nel/gui/ctrl_base.h
index 28eeb2cd0..71e6cad56 100644
--- a/code/nel/include/nel/gui/ctrl_base.h
+++ b/code/nel/include/nel/gui/ctrl_base.h
@@ -171,7 +171,9 @@ namespace NLGUI
THotSpot _ToolTipPosRefAlt : 6;
protected:
void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS);
+ void convertTooltipHotSpot(const char *prop, THotSpot &HS );
static std::string TooltipHotSpotToString( THotSpot parent, THotSpot child );
+ static std::string TooltipHotSpotToString( THotSpot HS );
void mapAHString( const std::string &key, const std::string &value );
std::string getAHString( const std::string &key ) const;
diff --git a/code/nel/src/gui/ctrl_base.cpp b/code/nel/src/gui/ctrl_base.cpp
index f0a2c2f89..98cda02f4 100644
--- a/code/nel/src/gui/ctrl_base.cpp
+++ b/code/nel/src/gui/ctrl_base.cpp
@@ -220,28 +220,22 @@ namespace NLGUI
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;
- }
+ return TooltipHotSpotToString( _ToolTipPosRef );
+ }
+ else
+ if( name == "tooltip_parent_posref" )
+ {
+ return TooltipHotSpotToString( _ToolTipParentPosRef );
}
else
if( name == "tooltip_posref_alt" )
{
- std::string s;
- if( ( _ToolTipParentPosRefAlt == Hotspot_TTAuto ) && ( _ToolTipPosRefAlt == Hotspot_TTAuto ) )
- return "auto";
- else{
- s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRefAlt );
- s += " ";
- s += CInterfaceElement::HotSpotToString( _ToolTipPosRefAlt );
- return s;
- }
+ return TooltipHotSpotToString( _ToolTipPosRefAlt );
+ }
+ else
+ if( name == "tooltip_parent_posref_alt" )
+ {
+ return TooltipHotSpotToString( _ToolTipParentPosRefAlt );
}
else
if( name == "instant_help" )
@@ -293,21 +287,65 @@ namespace NLGUI
else
if( name == "tooltip_posref" )
{
- THotSpot parentHS;
THotSpot HS;
- convertTooltipHotSpot( value.c_str(), parentHS, HS );
- _ToolTipParentPosRef = parentHS;
+ convertTooltipHotSpot( value.c_str(), HS );
_ToolTipPosRef = HS;
+
+ // When auto is set, both of them need to be auto
+ if( _ToolTipPosRef == Hotspot_TTAuto )
+ _ToolTipParentPosRef = Hotspot_TTAuto;
+ else
+ if( _ToolTipParentPosRef == Hotspot_TTAuto )
+ _ToolTipParentPosRef = _ToolTipPosRef;
+
+ return;
+ }
+ else
+ if( name == "tooltip_parent_posref" )
+ {
+ THotSpot HS;
+ convertTooltipHotSpot( value.c_str(), HS );
+ _ToolTipParentPosRef = HS;
+
+ // When auto is set, both of them need to be auto
+ if( _ToolTipParentPosRef == Hotspot_TTAuto )
+ _ToolTipPosRef = Hotspot_TTAuto;
+ else
+ if( _ToolTipPosRef == Hotspot_TTAuto )
+ _ToolTipPosRef = _ToolTipParentPosRef;
+
return;
}
else
if( name == "tooltip_posref_alt" )
{
- THotSpot parentHS;
THotSpot HS;
- convertTooltipHotSpot( value.c_str(), parentHS, HS );
- _ToolTipParentPosRefAlt = parentHS;
+ convertTooltipHotSpot( value.c_str(), HS );
_ToolTipPosRefAlt = HS;
+
+ // When auto is set, both of them need to be auto
+ if( _ToolTipPosRefAlt == Hotspot_TTAuto )
+ _ToolTipParentPosRefAlt = Hotspot_TTAuto;
+ else
+ if( _ToolTipParentPosRefAlt == Hotspot_TTAuto )
+ _ToolTipPosRefAlt = _ToolTipParentPosRefAlt;
+
+ return;
+ }
+ else
+ if( name == "tooltip_parent_posref_alt" )
+ {
+ THotSpot HS;
+ convertTooltipHotSpot( value.c_str(), HS );
+ _ToolTipParentPosRefAlt = HS;
+
+ // When auto is set, both of them need to be auto
+ if( _ToolTipParentPosRefAlt == Hotspot_TTAuto )
+ _ToolTipPosRefAlt = Hotspot_TTAuto;
+ else
+ if( _ToolTipPosRefAlt == Hotspot_TTAuto )
+ _ToolTipPosRefAlt = _ToolTipParentPosRefAlt;
+
return;
}
else
@@ -374,6 +412,21 @@ namespace NLGUI
}
}
+ void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &HS )
+ {
+ if(prop)
+ {
+ const char *ptr = (const char*)prop;
+ if(stricmp(ptr, "auto")==0)
+ {
+ HS = Hotspot_TTAuto;
+ }
+ else if(strlen(ptr)==2)
+ {
+ HS = convertHotSpot(ptr);
+ }
+ }
+ }
std::string CCtrlBase::TooltipHotSpotToString( THotSpot parent, THotSpot child )
{
@@ -393,6 +446,20 @@ namespace NLGUI
return s;
}
+ std::string CCtrlBase::TooltipHotSpotToString( THotSpot HS )
+ {
+ std::string s;
+ if( HS == Hotspot_TTAuto )
+ {
+ s = "auto";
+ }
+ else
+ {
+ s = HotSpotToString( HS );
+ }
+ return s;
+ }
+
// ***************************************************************************
bool CCtrlBase::emptyContextHelp() const
{
diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp
index 4a839cbee..017b4e5a7 100644
--- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp
+++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp
@@ -102,6 +102,83 @@ namespace
};
+ class NelPosRefTT
+ {
+ public:
+
+ enum NELPosRef
+ {
+ TTPOSREF_BL = 0,
+ TTPOSREF_BM = 1,
+ TTPOSREF_BR = 2,
+ TTPOSREF_ML = 3,
+ TTPOSREF_MM = 4,
+ TTPOSREF_MR = 5,
+ TTPOSREF_TL = 6,
+ TTPOSREF_TM = 7,
+ TTPOSREF_TR = 8,
+ TTPOSREF_AUTO = 9
+ };
+
+ static int fromString( const std::string &s )
+ {
+ int r = -1;
+
+ if( s == "BL" )
+ r = TTPOSREF_BL;
+ else
+ if( s == "BM" )
+ r = TTPOSREF_BM;
+ else
+ if( s == "BR" )
+ r = TTPOSREF_BR;
+ else
+ if( s == "ML" )
+ r = TTPOSREF_ML;
+ else
+ if( s == "MM" )
+ r = TTPOSREF_MM;
+ else
+ if( s == "MR" )
+ r = TTPOSREF_MR;
+ else
+ if( s == "TL" )
+ r = TTPOSREF_TL;
+ else
+ if( s == "TM" )
+ r = TTPOSREF_TM;
+ else
+ if( s == "TR" )
+ r = TTPOSREF_TR;
+ else
+ r = TTPOSREF_AUTO;
+
+ return r;
+ }
+
+ static std::string toString( int value )
+ {
+ std::string v;
+
+ switch( value )
+ {
+ case TTPOSREF_BL: v = "BL"; break;
+ case TTPOSREF_BM: v = "BM"; break;
+ case TTPOSREF_BR: v = "BR"; break;
+ case TTPOSREF_ML: v = "ML"; break;
+ case TTPOSREF_MM: v = "MM"; break;
+ case TTPOSREF_MR: v = "MR"; break;
+ case TTPOSREF_TL: v = "TL"; break;
+ case TTPOSREF_TM: v = "TM"; break;
+ case TTPOSREF_TR: v = "TR"; break;
+ case TTPOSREF_AUTO: v = "auto"; break;
+ }
+
+ return v;
+ }
+ };
+
+
class NelButtonType
{
public:
@@ -201,6 +278,12 @@ namespace GUIEditor
variantFactory = new QtVariantEditorFactory;
enumFactory = new QtEnumEditorFactory;
+
+ ttPairs[ "tooltip_posref" ] = "tooltip_parent_posref";
+ ttPairs[ "tooltip_parent_posref" ] = "tooltip_posref";
+ ttPairs[ "tooltip_posref_alt" ] = "tooltip_parent_posref_alt";
+ ttPairs[ "tooltip_parent_posref_alt" ] = "tooltip_posref_alt";
+
}
CPropBrowserCtrl::~CPropBrowserCtrl()
@@ -363,6 +446,56 @@ namespace GUIEditor
e->setProperty( propName.toUtf8().constData(), v );
}
+ else
+ if( type == "posreftt" )
+ {
+ CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement );
+ if( e == NULL )
+ return;
+
+ std::string v = NelPosRefTT::toString( value );
+ if( v.empty() )
+ return;
+
+ e->setProperty( propName.toUtf8().constData(), v );
+
+ // When auto is set as posref for a tooltip, it's pair MUST be auto as well
+ // When we set anything other than auto, the pair MUST not be auto either
+ // Only need to set the widget here, since the actual property is changed in the GUI library automatically
+ {
+ // Find the pair
+ std::map< std::string, std::string >::const_iterator ttItr =
+ ttPairs.find( n );
+
+ // Found!
+ if( ttItr != ttPairs.end() )
+ {
+
+ // Find the QtProperty that belongs to the pair
+ std::map< std::string, QtProperty* >::const_iterator pItr =
+ ttPosRefProps.find( ttItr->second );
+
+ // Found!
+ if( pItr != ttPosRefProps.end() )
+ {
+ disablePropertyWatchers();
+
+ if( value == NelPosRefTT::TTPOSREF_AUTO )
+ enumMgr->setValue( pItr->second, NelPosRefTT::TTPOSREF_AUTO );
+ else
+ {
+ int v = NelPosRefTT::fromString( pItr->second->valueText().toUtf8().constData() );
+ if( v == NelPosRefTT::TTPOSREF_AUTO )
+ {
+ enumMgr->setValue( pItr->second, value );
+ }
+ }
+
+ enablePropertyWatchers();
+ }
+ }
+ }
+ }
}
void CPropBrowserCtrl::enablePropertyWatchers()
@@ -389,6 +522,7 @@ namespace GUIEditor
SWidgetInfo &w = itr->second;
nameToType.clear();
+ ttPosRefProps.clear();
std::vector< SPropEntry >::const_iterator pItr;
for( pItr = w.props.begin(); pItr != w.props.end(); ++pItr )
@@ -490,6 +624,42 @@ namespace GUIEditor
return;
}
else
+ if( prop.propType == "posreftt" )
+ {
+ std::string j = element->getProperty( prop.propName );
+ if( j.empty() )
+ return;
+
+ int e = -1;
+ e = NelPosRefTT::fromString( j );
+ if( e == -1 )
+ return;
+
+ QtProperty *pp = enumMgr->addProperty( prop.propName.c_str() );
+ if( pp == NULL )
+ return;
+
+ QStringList enums;
+ enums.push_back( "BL" );
+ enums.push_back( "BM" );
+ enums.push_back( "BR" );
+ enums.push_back( "ML" );
+ enums.push_back( "MM" );
+ enums.push_back( "MR" );
+ enums.push_back( "TL" );
+ enums.push_back( "TM" );
+ enums.push_back( "TR" );
+ enums.push_back( "auto" );
+
+ enumMgr->setEnumNames( pp, enums );
+ enumMgr->setValue( pp, e );
+ browser->addProperty( pp );
+
+ ttPosRefProps[ prop.propName ] = pp;
+
+ return;
+ }
+ else
if( prop.propType == "string" )
{
p = propertyMgr->addProperty( QVariant::String, prop.propName.c_str() );
diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.h b/code/studio/src/plugins/gui_editor/property_browser_ctrl.h
index efb785d9b..bec4004d3 100644
--- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.h
+++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.h
@@ -77,6 +77,8 @@ namespace GUIEditor
std::string currentElement;
std::map< std::string, SWidgetInfo > widgetInfo;
std::map< std::string, std::string > nameToType;
+ std::map< std::string, QtProperty * > ttPosRefProps; // Tooltip posref properties
+ std::map< std::string, std::string > ttPairs;
};
}
diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlBase.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlBase.xml
index 5c334dea5..732930348 100644
--- a/code/studio/src/plugins/gui_editor/widgets/CtrlBase.xml
+++ b/code/studio/src/plugins/gui_editor/widgets/CtrlBase.xml
@@ -37,17 +37,27 @@
tooltip_special_parent
string
-
+
tooltip_posref
- string
+ posreftt
auto
-
+
+
+ tooltip_parent_posref
+ posreftt
+ auto
+
tooltip_posref_alt
- string
+ posreftt
auto
-
+
+
+ tooltip_parent_posref_alt
+ posreftt
+ auto
+
instant_help
bool