mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-26 16:56:19 +00:00
Pos and Size parent setters should now use the widget directly as well.
This commit is contained in:
parent
6b3e8d3766
commit
78e64abd69
1 changed files with 52 additions and 23 deletions
|
@ -1534,17 +1534,36 @@ namespace NLGUI
|
||||||
|
|
||||||
void CInterfaceElement::setPosParent( const std::string &id )
|
void CInterfaceElement::setPosParent( const std::string &id )
|
||||||
{
|
{
|
||||||
std::string Id = stripId( id );
|
// Parent or empty id simply means the group parent
|
||||||
|
if( ( id == "parent" ) || ( id.empty() ) )
|
||||||
if( Id != "parent" )
|
|
||||||
{
|
{
|
||||||
std::string idParent;
|
setParentPos( getParent() );
|
||||||
if( _Parent != NULL )
|
return;
|
||||||
idParent = _Parent->getId() + ":";
|
|
||||||
else
|
|
||||||
idParent = "ui:";
|
|
||||||
CWidgetManager::getInstance()->getParser()->addParentPositionAssociation( this, idParent + Id );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CInterfaceElement *pp = NULL;
|
||||||
|
|
||||||
|
// Check if it's a short Id
|
||||||
|
std::string::size_type idx = id.find( "ui:" );
|
||||||
|
if( idx == std::string::npos )
|
||||||
|
{
|
||||||
|
// If it is, find the widget in the parent group and set as posparent
|
||||||
|
CInterfaceGroup *p = getParent();
|
||||||
|
if( p != NULL )
|
||||||
|
{
|
||||||
|
pp = p->findFromShortId( id );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If it is not, find using the widgetmanager
|
||||||
|
// TODO: refactor, shouldn't use a singleton
|
||||||
|
pp = CWidgetManager::getInstance()->getElementFromId( id );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pp != NULL )
|
||||||
|
setParentPos( pp );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInterfaceElement::getPosParent( std::string &id ) const
|
void CInterfaceElement::getPosParent( std::string &id ) const
|
||||||
|
@ -1579,25 +1598,35 @@ namespace NLGUI
|
||||||
|
|
||||||
void CInterfaceElement::setSizeParent( const std::string &id )
|
void CInterfaceElement::setSizeParent( const std::string &id )
|
||||||
{
|
{
|
||||||
std::string Id = stripId( id );
|
// Parent or empty id simply means the group parent
|
||||||
std::string idParent;
|
if( ( id == "parent" ) || ( id.empty() ) )
|
||||||
|
|
||||||
if( Id != "parent" )
|
|
||||||
{
|
{
|
||||||
if( _Parent != NULL )
|
setParentSize( getParent() );
|
||||||
idParent = _Parent->getId() + ":";
|
return;
|
||||||
else
|
}
|
||||||
idParent = "ui:";
|
|
||||||
CWidgetManager::getInstance()->getParser()->addParentSizeAssociation( this, idParent + Id );
|
CInterfaceElement *pp = NULL;
|
||||||
|
|
||||||
|
// Check if it's a short Id
|
||||||
|
std::string::size_type idx = id.find( "ui:" );
|
||||||
|
if( idx == std::string::npos )
|
||||||
|
{
|
||||||
|
// If it is, find the widget in the parent group and set as posparent
|
||||||
|
CInterfaceGroup *p = getParent();
|
||||||
|
if( p != NULL )
|
||||||
|
{
|
||||||
|
pp = p->findFromShortId( id );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( _Parent != NULL )
|
// If it is not, find using the widgetmanager
|
||||||
{
|
// TODO: refactor, shouldn't use a singleton
|
||||||
idParent = _Parent->getId();
|
pp = CWidgetManager::getInstance()->getElementFromId( id );
|
||||||
CWidgetManager::getInstance()->getParser()->addParentSizeAssociation( this, idParent );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( pp != NULL )
|
||||||
|
setParentSize( pp );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInterfaceElement::getSizeParent( std::string &id ) const
|
void CInterfaceElement::getSizeParent( std::string &id ) const
|
||||||
|
|
Loading…
Reference in a new issue