Added setDrawable(uint,Drawable*) method.

This commit is contained in:
Robert Osfield
2002-11-18 16:14:00 +00:00
parent b89e7282ed
commit 42fb3c5987
2 changed files with 44 additions and 18 deletions

View File

@@ -84,9 +84,21 @@ bool Geode::replaceDrawable( Drawable *origDrawable, Drawable *newDrawable )
{
if (newDrawable==NULL || origDrawable==newDrawable) return false;
DrawableList::iterator itr = findDrawable(origDrawable);
if (itr!=_drawables.end())
unsigned int pos = findDrawableNum(origDrawable);
if (pos<_drawables.size())
{
return setDrawable(pos,newDrawable);
}
return false;
}
bool Geode::setDrawable( unsigned int i, Drawable* newDrawable )
{
if (i<_drawables.size() && newDrawable)
{
Drawable* origDrawable = _drawables[i].get();
int delta = 0;
if (origDrawable->getAppCallback()) --delta;
if (newDrawable->getAppCallback()) ++delta;
@@ -100,7 +112,7 @@ bool Geode::replaceDrawable( Drawable *origDrawable, Drawable *newDrawable )
// note ref_ptr<> automatically handles decrementing origGset's reference count,
// and inccrementing newGset's reference count.
*itr = newDrawable;
_drawables[i] = newDrawable;
// register as parent of child.
newDrawable->addParent(this);