mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 04:40:53 +00:00
CHANGED: #1471 Widget definition inheritance is now supported in the GUI editor. www.youtube.com/watch?v=VG_TnZiGjBk
--HG-- branch : gsoc2012-gui-editor
This commit is contained in:
parent
4d2932ccef
commit
acb385fbe9
5 changed files with 98 additions and 1 deletions
|
@ -43,11 +43,19 @@ namespace GUIEditor
|
|||
{
|
||||
std::string name;
|
||||
std::string GUIName;
|
||||
std::string ancestor;
|
||||
std::string description;
|
||||
bool isAbstract;
|
||||
std::string icon;
|
||||
bool resolved;
|
||||
|
||||
std::vector< SPropEntry > props;
|
||||
|
||||
SWidgetInfo()
|
||||
{
|
||||
resolved = false;
|
||||
isAbstract = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ namespace GUIEditor
|
|||
while( itr.hasNext() )
|
||||
parseGUIWidget( "widgets/" + itr.next() );
|
||||
|
||||
resolveInheritance();
|
||||
|
||||
widgetInfo = NULL;
|
||||
}
|
||||
|
||||
|
@ -119,6 +121,9 @@ namespace GUIEditor
|
|||
if( key == "guiname" )
|
||||
info.GUIName = value.toStdString();
|
||||
else
|
||||
if( key == "ancestor" )
|
||||
info.ancestor = value.toStdString();
|
||||
else
|
||||
if( key == "description" )
|
||||
info.description = value.toStdString();
|
||||
else
|
||||
|
@ -202,7 +207,66 @@ namespace GUIEditor
|
|||
|
||||
reader.readNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool propCompare( const SPropEntry &left, const SPropEntry &right )
|
||||
{
|
||||
return left.propName < right.propName;
|
||||
}
|
||||
|
||||
void CWidgetPropParser::resolveInheritance()
|
||||
{
|
||||
for( std::map< std::string, SWidgetInfo >::iterator itr = widgetInfo->begin(); itr != widgetInfo->end(); ++itr )
|
||||
{
|
||||
resolveInheritanceFor( itr->first );
|
||||
std::sort( itr->second.props.begin(), itr->second.props.end(), propCompare );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CWidgetPropParser::resolveInheritanceFor( const std::string name )
|
||||
{
|
||||
if( name.empty() )
|
||||
return;
|
||||
|
||||
std::map< std::string, SWidgetInfo >::iterator itr =
|
||||
widgetInfo->find( name );
|
||||
if( itr == widgetInfo->end() )
|
||||
return;
|
||||
|
||||
SWidgetInfo *info = &(itr->second);
|
||||
if( info->resolved )
|
||||
return;
|
||||
|
||||
if( info->ancestor.empty() )
|
||||
return;
|
||||
|
||||
std::vector< SPropEntry > &props = info->props;
|
||||
|
||||
std::map< std::string, SWidgetInfo >::iterator itr2 =
|
||||
widgetInfo->find( info->ancestor );
|
||||
if( itr2 == widgetInfo->end() )
|
||||
return;
|
||||
SWidgetInfo *info2 = &(itr2->second);
|
||||
|
||||
do
|
||||
{
|
||||
for( std::vector< SPropEntry >::iterator propItr = info2->props.begin(); propItr != info2->props.end(); ++propItr )
|
||||
props.push_back( *propItr );
|
||||
|
||||
if( !info2->resolved && !info2->ancestor.empty() )
|
||||
{
|
||||
itr2 = widgetInfo->find( info2->ancestor );
|
||||
if( itr2 != widgetInfo->end() )
|
||||
info2 = &(itr2->second);
|
||||
else
|
||||
info2 = NULL;
|
||||
}
|
||||
}
|
||||
while( ( info2 != NULL ) && !info2->resolved && !info2->ancestor.empty() );
|
||||
|
||||
info->resolved = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ namespace GUIEditor
|
|||
void parseGUIWidgetXML( QFile &file );
|
||||
QString parseGUIWidgetHeader( QXmlStreamReader &reader );
|
||||
void parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName );
|
||||
void resolveInheritance();
|
||||
void resolveInheritanceFor( const std::string name );
|
||||
|
||||
std::map< std::string, SWidgetInfo > *widgetInfo;
|
||||
};
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<header>
|
||||
<name>CtrlBase</name>
|
||||
<guiname>cb</guiname>
|
||||
<ancestor>InterfaceElement</ancestor>
|
||||
<description></description>
|
||||
<abstract>true</abstract>
|
||||
<icon></icon>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<widget>
|
||||
<header>
|
||||
<name>InterfaceGroup</name>
|
||||
<guiname>ig</guiname>
|
||||
<ancestor>CtrlBase</ancestor>
|
||||
<description></description>
|
||||
<abstract>false</abstract>
|
||||
<icon></icon>
|
||||
</header>
|
||||
<properties>
|
||||
<property>
|
||||
<name>on_enter</name>
|
||||
<type>string</type>
|
||||
<default>handler</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_enter_params</name>
|
||||
<type>string</type>
|
||||
<default>params</default>
|
||||
</property>
|
||||
</properties>
|
||||
</widget>
|
Loading…
Reference in a new issue