MODIFIED: Preliminary support for a little cleanup when removing a widget from it's parent group ( for example when moving the widget ).
--HG-- branch : gsoc2012-gui-editor
This commit is contained in:
parent
660fb00895
commit
363154e241
4 changed files with 27 additions and 6 deletions
|
@ -124,6 +124,8 @@ namespace NLGUI
|
||||||
REFLECT_LUA_METHOD("getViewText", luaGetViewText)
|
REFLECT_LUA_METHOD("getViewText", luaGetViewText)
|
||||||
REFLECT_EXPORT_END
|
REFLECT_EXPORT_END
|
||||||
|
|
||||||
|
void onRemoved();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
enum {NumTexture= 3};
|
enum {NumTexture= 3};
|
||||||
|
|
|
@ -486,6 +486,9 @@ namespace NLGUI
|
||||||
void setSerializable( bool b ){ serializable = b; }
|
void setSerializable( bool b ){ serializable = b; }
|
||||||
bool IsSerializable() const{ return serializable; }
|
bool IsSerializable() const{ return serializable; }
|
||||||
|
|
||||||
|
/// Called when the widget is removed from it's parent group
|
||||||
|
virtual void onRemoved(){}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool editorSelected;
|
bool editorSelected;
|
||||||
|
|
|
@ -64,8 +64,8 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
if( _ViewText != NULL )
|
if( _ViewText != NULL )
|
||||||
{
|
{
|
||||||
if( getParent() != NULL )
|
if( _Parent != NULL )
|
||||||
getParent()->delElement( _ViewText );
|
_Parent->delView( _ViewText );
|
||||||
_ViewText = NULL;
|
_ViewText = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -967,6 +967,13 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
void CCtrlTextButton::onRemoved()
|
||||||
|
{
|
||||||
|
if( _ViewText != NULL )
|
||||||
|
{
|
||||||
|
if( _Parent != NULL )
|
||||||
|
_Parent->delView( _ViewText, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1084,9 +1084,12 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
if (_Views[i] == child)
|
if (_Views[i] == child)
|
||||||
{
|
{
|
||||||
if (!dontDelete) delete _Views[i];
|
CViewBase *v = _Views[i];
|
||||||
_Views.erase(_Views.begin()+i);
|
_Views.erase(_Views.begin()+i);
|
||||||
delEltOrder (child);
|
delEltOrder (child);
|
||||||
|
child->onRemoved();
|
||||||
|
child->setParent( NULL );
|
||||||
|
if (!dontDelete) delete v;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1100,9 +1103,12 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
if (_Controls[i] == child)
|
if (_Controls[i] == child)
|
||||||
{
|
{
|
||||||
if (!dontDelete) delete _Controls[i];
|
CCtrlBase *c = _Controls[i];
|
||||||
_Controls.erase(_Controls.begin()+i);
|
_Controls.erase(_Controls.begin()+i);
|
||||||
delEltOrder (child);
|
delEltOrder (child);
|
||||||
|
child->onRemoved();
|
||||||
|
child->setParent( NULL );
|
||||||
|
if (!dontDelete) delete c;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1116,9 +1122,12 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
if (_ChildrenGroups[i] == child)
|
if (_ChildrenGroups[i] == child)
|
||||||
{
|
{
|
||||||
if (!dontDelete) delete _ChildrenGroups[i];
|
CInterfaceGroup *g = _ChildrenGroups[i];
|
||||||
_ChildrenGroups.erase(_ChildrenGroups.begin()+i);
|
_ChildrenGroups.erase(_ChildrenGroups.begin()+i);
|
||||||
delEltOrder (child);
|
delEltOrder (child);
|
||||||
|
child->onRemoved();
|
||||||
|
child->setParent( NULL );
|
||||||
|
if (!dontDelete) delete g;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue