CHANGED: #1471 implemented property querying for CInterfaceElement.
This commit is contained in:
parent
14ac62dbad
commit
f245e69063
8 changed files with 235 additions and 37 deletions
|
@ -121,6 +121,7 @@ namespace NLGUI
|
||||||
// help to serialize an action handler
|
// help to serialize an action handler
|
||||||
static void serialAH(NLMISC::IStream &f, IActionHandler *&ah);
|
static void serialAH(NLMISC::IStream &f, IActionHandler *&ah);
|
||||||
|
|
||||||
|
static std::string stripId( const std::string &fullId );
|
||||||
|
|
||||||
/// Parse the element and initalize it
|
/// Parse the element and initalize it
|
||||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||||
|
@ -288,6 +289,7 @@ namespace NLGUI
|
||||||
const std::string &defVal);
|
const std::string &defVal);
|
||||||
|
|
||||||
// Parse tools
|
// Parse tools
|
||||||
|
static std::string HotSpotToString( THotSpot spot );
|
||||||
static THotSpot convertHotSpot (const char *ptr); //
|
static THotSpot convertHotSpot (const char *ptr); //
|
||||||
static void convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef);
|
static void convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef);
|
||||||
static NLMISC::CRGBA convertColor (const char *ptr);
|
static NLMISC::CRGBA convertColor (const char *ptr);
|
||||||
|
|
|
@ -160,8 +160,11 @@ namespace NLGUI
|
||||||
/// Association builders : associate an element of the interface with the string ID of
|
/// Association builders : associate an element of the interface with the string ID of
|
||||||
/// another element used as reference for position values
|
/// another element used as reference for position values
|
||||||
void addParentPositionAssociation (CInterfaceElement *element, const std::string &parentID);
|
void addParentPositionAssociation (CInterfaceElement *element, const std::string &parentID);
|
||||||
|
std::string getParentPosAssociation( CInterfaceElement *element ) const;
|
||||||
void addParentSizeAssociation (CInterfaceElement *element, const std::string &parentID);
|
void addParentSizeAssociation (CInterfaceElement *element, const std::string &parentID);
|
||||||
|
std::string getParentSizeAssociation( CInterfaceElement *element ) const;
|
||||||
void addParentSizeMaxAssociation (CInterfaceElement *element, const std::string &parentID);
|
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)
|
/// 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);
|
void addLuaClassAssociation(CInterfaceGroup *group, const std::string &luaScript);
|
||||||
|
|
|
@ -45,6 +45,9 @@ namespace NLGUI
|
||||||
virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
|
virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
|
||||||
virtual void addParentSizeMaxAssociation( 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 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, 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 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;
|
virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0;
|
||||||
|
|
|
@ -73,6 +73,15 @@ namespace NLGUI
|
||||||
return _Id;
|
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)
|
bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
|
||||||
{
|
{
|
||||||
|
@ -186,35 +195,6 @@ namespace NLGUI
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
parseSizeRef(ptr.getDatas());
|
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();
|
// snapSize();
|
||||||
|
@ -249,6 +229,64 @@ namespace NLGUI
|
||||||
else
|
else
|
||||||
return "false";
|
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 "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -263,7 +301,22 @@ namespace NLGUI
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
std::string CInterfaceElement::getSizeRefAsString() const
|
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)
|
THotSpot CInterfaceElement::convertHotSpot (const char *ptr)
|
||||||
|
|
|
@ -1969,18 +1969,48 @@ namespace NLGUI
|
||||||
_ParentPositionsMap.insert (std::map<CInterfaceElement*,std::string>::value_type(element, parent));
|
_ParentPositionsMap.insert (std::map<CInterfaceElement*,std::string>::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)
|
void CInterfaceParser::addParentSizeAssociation(CInterfaceElement* element, const std::string& parent)
|
||||||
{
|
{
|
||||||
_ParentSizesMap.insert (std::map<CInterfaceElement*,std::string>::value_type(element, parent));
|
_ParentSizesMap.insert (std::map<CInterfaceElement*,std::string>::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)
|
void CInterfaceParser::addParentSizeMaxAssociation (CInterfaceElement *element, const std::string &parent)
|
||||||
{
|
{
|
||||||
_ParentSizesMaxMap.insert (std::map<CInterfaceElement*,std::string>::value_type(element, parent));
|
_ParentSizesMaxMap.insert (std::map<CInterfaceElement*,std::string>::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)
|
void CInterfaceParser::addLuaClassAssociation (CInterfaceGroup *group, const std::string &luaScript)
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,25 +91,34 @@ namespace GUIEditor
|
||||||
void CPropBrowserCtrl::setupProperty( const SPropEntry &prop, const CInterfaceElement *element )
|
void CPropBrowserCtrl::setupProperty( const SPropEntry &prop, const CInterfaceElement *element )
|
||||||
{
|
{
|
||||||
QtVariantProperty *p = NULL;
|
QtVariantProperty *p = NULL;
|
||||||
|
QVariant v;
|
||||||
|
|
||||||
if( prop.propType == "string" )
|
if( prop.propType == "string" )
|
||||||
{
|
{
|
||||||
p = propertyMgr->addProperty( QVariant::String, prop.propName.c_str() );
|
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
|
else
|
||||||
if( prop.propType == "bool" )
|
if( prop.propType == "bool" )
|
||||||
{
|
{
|
||||||
p = propertyMgr->addProperty( QVariant::Bool, prop.propName.c_str() );
|
p = propertyMgr->addProperty( QVariant::Bool, prop.propName.c_str() );
|
||||||
bool value = false;
|
bool value = false;
|
||||||
if( element->getProperty( prop.propName ) == "true" )
|
NLMISC::fromString( element->getProperty( prop.propName ), value );
|
||||||
value = true;
|
v = value;
|
||||||
|
|
||||||
p->setValue( 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 )
|
if( p == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
p->setValue( v );
|
||||||
browser->addProperty( p );
|
browser->addProperty( p );
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<widget>
|
<widget>
|
||||||
<header>
|
<header>
|
||||||
<name>InterfaceElement</name>
|
<name>InterfaceElement</name>
|
||||||
<guiname>ie</guiname>
|
<guiname>CInterfaceElement</guiname>
|
||||||
<description></description>
|
<description></description>
|
||||||
<abstract>true</abstract>
|
<abstract>true</abstract>
|
||||||
<icon></icon>
|
<icon></icon>
|
||||||
|
@ -17,5 +17,60 @@
|
||||||
<type>bool</type>
|
<type>bool</type>
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</property>
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>x</name>
|
||||||
|
<type>int</type>
|
||||||
|
<default>0</default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>y</name>
|
||||||
|
<type>int</type>
|
||||||
|
<default>0</default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>w</name>
|
||||||
|
<type>int</type>
|
||||||
|
<default>0</default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>h</name>
|
||||||
|
<type>int</type>
|
||||||
|
<default>0</default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>posref</name>
|
||||||
|
<type>string</type>
|
||||||
|
<default>BL BL</default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>sizeref</name>
|
||||||
|
<type>string</type>
|
||||||
|
<default></default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>posparent</name>
|
||||||
|
<type>string</type>
|
||||||
|
<default>parent</default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>sizeparent</name>
|
||||||
|
<type>string</type>
|
||||||
|
<default>parent</default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>global_color</name>
|
||||||
|
<type>bool</type>
|
||||||
|
<default>true</default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>render_layer</name>
|
||||||
|
<type>int</type>
|
||||||
|
<default>0</default>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>avoid_resize_parent</name>
|
||||||
|
<type>bool</type>
|
||||||
|
<default>false</default>
|
||||||
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<widget>
|
<widget>
|
||||||
<header>
|
<header>
|
||||||
<name>InterfaceGroup</name>
|
<name>InterfaceGroup</name>
|
||||||
<guiname>ig</guiname>
|
<guiname>CInterfaceGroup</guiname>
|
||||||
<ancestor>CtrlBase</ancestor>
|
<ancestor>CtrlBase</ancestor>
|
||||||
<description></description>
|
<description></description>
|
||||||
<abstract>false</abstract>
|
<abstract>false</abstract>
|
||||||
|
|
Loading…
Reference in a new issue