Public Types | Public Member Functions | Friends

gnash::DisplayList Class Reference

A list of on-stage DisplayObjects, ordered by depth. More...

#include <DisplayList.h>

List of all members.

Public Types

typedef std::list
< DisplayObject * > 
container_type
typedef container_type::iterator iterator
typedef
container_type::const_iterator 
const_iterator
typedef
container_type::reverse_iterator 
reverse_iterator
typedef
container_type::const_reverse_iterator 
const_reverse_iterator

Public Member Functions

 DisplayList ()
 ~DisplayList ()
void placeDisplayObject (DisplayObject *ch, int depth)
 Place a new DisplayObject at the specified depth, replacing any existing DisplayObject at the same depth.
void replaceDisplayObject (DisplayObject *ch, int depth, bool use_old_cxform, bool use_old_matrix)
 Replace the old DisplayObject at the specified depth with the given new DisplayObject.
void swapDepths (DisplayObject *ch, int depth)
 Change depth of the given DisplayObjects in the list, swapping with any existing DisplayObject at target depth.
void moveDisplayObject (int depth, const SWFCxForm *color_xform, const SWFMatrix *mat, int *ratio, int *clip_depth)
 Updates the transform properties of the object at the specified depth, unless its get_accept_anim_moves() returns false.
void removeDisplayObject (int depth)
 Removes the object at the specified depth.
void removeUnloaded ()
 Remove all unloaded DisplayObject from the list.
bool unload ()
void destroy ()
 destroy all DisplayObjects in this DisplayList
void add (DisplayObject *ch, bool replace)
 Add a DisplayObject in the list, maintaining depth-order.
void removeDisplayObject (DisplayObject *obj)
 Removes the specified DisplayObject.
DisplayObjectremoveDisplayObjectAt (int index)
 Removes the DisplayObject at the specified index.
void insertDisplayObject (DisplayObject *obj, int index)
 Inserts a DisplayObject at the specified index (depth).
void addDisplayObject (DisplayObject *obj)
 Adds a DisplayObject at the top of the DisplayList.
void display (Renderer &renderer, const Transform &xform)
 Display the list's DisplayObjects.
void omit_display ()
DisplayObjectgetDisplayObjectAtDepth (int depth) const
 May return NULL.
DisplayObjectgetDisplayObjectByName (string_table &st, string_table::key name, bool caseless) const
 If there are multiples, returns the *first* match only!
template<class V >
void visitForward (V &visitor)
 Visit each DisplayObject in the list in depth order (lower depth first).
template<class V >
void visitBackward (V &visitor)
 Visit each DisplayObject in the list in reverse depth order (higher depth first).
template<class V >
void visitBackward (V &visitor) const
template<class V >
void visitAll (V &visitor)
 Visit each and all DisplayObject in the list.
template<class V >
void visitAll (V &visitor) const
void dump () const
 dump list to logfile/stderr
void add_invalidated_bounds (InvalidatedRanges &ranges, bool force)
size_t size () const
 Return number of elements in the list.
bool empty () const
 Return true if the list contains no elements.
int getNextHighestDepth () const
 Return the next highest available depth.
void sort ()
 Sort list by depth (lower depths first).
void mergeDisplayList (DisplayList &newList)
 merge the given display list
bool operator== (const DisplayList &other) const
bool operator!= (const DisplayList &other) const
void testInvariant () const

Friends

std::ostream & operator<< (std::ostream &, const DisplayList &)
 Output operator.

Detailed Description

A list of on-stage DisplayObjects, ordered by depth.

Any MovieClip has an associated DisplayList that may change from frame to frame due to control tags instructing when to add or remove DisplayObjects from the stage.


Member Typedef Documentation

typedef container_type::const_iterator gnash::DisplayList::const_iterator
typedef container_type::const_reverse_iterator gnash::DisplayList::const_reverse_iterator
typedef container_type::iterator gnash::DisplayList::iterator
typedef container_type::reverse_iterator gnash::DisplayList::reverse_iterator

Constructor & Destructor Documentation

gnash::DisplayList::DisplayList (  )  [inline]
gnash::DisplayList::~DisplayList (  )  [inline]

Member Function Documentation

void gnash::DisplayList::add ( DisplayObject ch,
bool  replace 
)

Add a DisplayObject in the list, maintaining depth-order.

Parameters:
ch The DisplayObject to add
replace If true the given DisplayObject would replace any pre-existing DisplayObject at the same depth.

References gnash::DisplayObject::get_depth(), and testInvariant().

void gnash::DisplayList::add_invalidated_bounds ( InvalidatedRanges ranges,
bool  force 
)
void gnash::DisplayList::addDisplayObject ( DisplayObject obj  ) 

Adds a DisplayObject at the top of the DisplayList.

This implements AS3 DisplayObjectContainer.addChild().

Parameters:
obj The DisplayObject to insert. This should already be removed from any other DisplayLists. It should not be the owner of this DisplayList or any parent of that owner.

References gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), testInvariant(), and gnash::DisplayObject::unloaded().

Referenced by gnash::DisplayObjectContainer::addChild().

void gnash::DisplayList::destroy (  ) 
void gnash::DisplayList::display ( Renderer renderer,
const Transform xform 
)
void gnash::DisplayList::dump (  )  const
bool gnash::DisplayList::empty (  )  const [inline]

Return true if the list contains no elements.

DisplayObject * gnash::DisplayList::getDisplayObjectAtDepth ( int  depth  )  const
DisplayObject * gnash::DisplayList::getDisplayObjectByName ( string_table st,
string_table::key  name,
bool  caseless 
) const

If there are multiples, returns the *first* match only!

References gnash::key::e, and testInvariant().

Referenced by gnash::MovieTester::findDisplayItemByName().

int gnash::DisplayList::getNextHighestDepth (  )  const

Return the next highest available depth.

Placing an object at the depth returned by this function should result in a DisplayObject that is displayd above all others

References gnash::DisplayObject::get_depth(), and testInvariant().

Referenced by gnash::MovieClip::getNextHighestDepth().

void gnash::DisplayList::insertDisplayObject ( DisplayObject obj,
int  index 
)

Inserts a DisplayObject at the specified index (depth).

If a DisplayObject is already at that index, it is moved up. This implements AS3 DisplayObjectContainer.addChildAt().

Parameters:
obj The DisplayObject to insert. This should already be removed from any other DisplayLists. It should not be the owner of this DisplayList or any parent of that owner.
index The index at which to insert the DisplayObject.

References gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), testInvariant(), and gnash::DisplayObject::unloaded().

Referenced by gnash::DisplayObjectContainer::addChildAt().

void gnash::DisplayList::mergeDisplayList ( DisplayList newList  ) 
void gnash::DisplayList::moveDisplayObject ( int  depth,
const SWFCxForm color_xform,
const SWFMatrix mat,
int *  ratio,
int *  clip_depth 
)

Updates the transform properties of the object at the specified depth, unless its get_accept_anim_moves() returns false.

See DisplayObject::get_accept_anim_moves()

Parameters:
color_xform The color tranform to assign to the DisplayObject at the given depth. If NULL the orignial color transform will be kept.
mat The SWFMatrix tranform to assign to the DisplayObject at the given depth. If NULL the orignial SWFMatrix will be kept.
ratio The new ratio value to assign to the DisplayObject at the given depth. If NULL the original ratio will be kept.

Not used at the moment.

References _, gnash::DisplayObject::get_accept_anim_moves(), getDisplayObjectAtDepth(), IF_VERBOSE_MALFORMED_SWF, gnash::DisplayObject::set_ratio(), gnash::DisplayObject::setCxForm(), gnash::DisplayObject::setMatrix(), testInvariant(), and gnash::DisplayObject::unloaded().

void gnash::DisplayList::omit_display (  ) 
bool gnash::DisplayList::operator!= ( const DisplayList other  )  const [inline]
bool gnash::DisplayList::operator== ( const DisplayList other  )  const [inline]
void gnash::DisplayList::placeDisplayObject ( DisplayObject ch,
int  depth 
)

Place a new DisplayObject at the specified depth, replacing any existing DisplayObject at the same depth.

If a DisplayObject is replaced, it's unload() method is invoked.

If applicable, the event_id::LOAD event associated with the given DisplayObject is called as last step of addition.

Parameters:
ch the new DisplayObject to be added into the list.
depth depth at which the new DisplayObject is placed.

References gnash::DisplayObject::destroy(), gnash::DisplayObject::extend_invalidated_bounds(), gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), testInvariant(), gnash::DisplayObject::unload(), and gnash::DisplayObject::unloaded().

Referenced by main(), and gnash::MovieClip::placeDisplayObject().

void gnash::DisplayList::removeDisplayObject ( DisplayObject obj  ) 

Removes the specified DisplayObject.

Other DisplayObjects are left untouched. This implements AS3 DisplayObjectContainer.removeChild().

Parameters:
obj The DisplayObject to remove.
void gnash::DisplayList::removeDisplayObject ( int  depth  ) 
DisplayObject * gnash::DisplayList::removeDisplayObjectAt ( int  index  ) 

Removes the DisplayObject at the specified index.

Other DisplayObjects are left untouched. This implements AS3 DisplayObjectContainer.removeChildAt().

Parameters:
index The index from which to remove the DisplayObject.
Returns:
The DisplayObject removed, or 0 if none was removed.

Referenced by gnash::DisplayObjectContainer::removeChildAt().

void gnash::DisplayList::removeUnloaded (  ) 

Remove all unloaded DisplayObject from the list.

Removed DisplayObjects still in the list are those on which onUnload event handlers were defined..

NOTE: we don't call the function recursively in the contained elements, as that should not be needed (ie: any inned thing will not be accessible anyway)

References testInvariant(), and gnash::DisplayObject::unloaded().

void gnash::DisplayList::replaceDisplayObject ( DisplayObject ch,
int  depth,
bool  use_old_cxform,
bool  use_old_matrix 
)

Replace the old DisplayObject at the specified depth with the given new DisplayObject.

Calls unload on the removed DisplayObject.

Parameters:
ch the new DisplayObject to be put
depth depth to be replaced
use_old_cxform true: set the new DisplayObject's SWFCxForm to the old one. false: keep the new DisplayObject's SWFCxForm.
use_old_matrix true: set the new DisplayObject's transformation SWFMatrix to the old one. false: keep the new DisplayObject's transformation SWFMatrix.

References gnash::DisplayObject::add_invalidated_bounds(), gnash::DisplayObject::destroy(), gnash::DisplayObject::extend_invalidated_bounds(), gnash::getCxForm(), gnash::getMatrix(), gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::setCxForm(), gnash::DisplayObject::setMatrix(), testInvariant(), gnash::DisplayObject::unload(), and gnash::DisplayObject::unloaded().

size_t gnash::DisplayList::size (  )  const [inline]

Return number of elements in the list.

Referenced by checkScribbling(), main(), gnash::DisplayObjectContainer::numChildren(), removeDisplayObject(), and testAll().

void gnash::DisplayList::sort (  ) 

Sort list by depth (lower depths first).

You only need calling this method if depth of DisplayObjects on the list has been externally changed. Usually it is DisplayList itself assigning depths, so won't need to call it.

A notable use for this is backing up a specific state and restoring it later. Restore step would need reordering.

Referenced by main().

void gnash::DisplayList::swapDepths ( DisplayObject ch,
int  depth 
)

Change depth of the given DisplayObjects in the list, swapping with any existing DisplayObject at target depth.

List ordering will be maintained by this function.

Any DisplayObject affected by this operation (none on invalid call, 1 if new depth is not occupied, 2 otherwise) will be:

Parameters:
ch The DisplayObject to apply depth swapping to. If not found in the list, an error is raised and no other action is taken.
depth The new depth to assign to the given DisplayObject. If occupied by another DisplayObject, the target DisplayObject will get the current depth of the first. If target depth equals the current depth of DisplayObject, an assertion fails, as I think the caller should check this instead.

References gnash::DisplayObject::get_depth(), gnash::DisplayObject::getTarget(), IF_VERBOSE_ASCODING_ERRORS, gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::staticDepthOffset, testInvariant(), and gnash::DisplayObject::transformedByScript().

Referenced by gnash::MovieClip::swapDepths().

void gnash::DisplayList::testInvariant (  )  const [inline]
bool gnash::DisplayList::unload (  ) 

Unload the DisplayObjects in this DisplayList removing all but the ones with on onUnload event defined (checked by calling unload on them) and keeping the others, w/out depth-shifting them.

Return true if any child was kept (as they had onUnload defined)

References gnash::DisplayObject::destroy(), gnash::DisplayObject::isDestroyed(), testInvariant(), and gnash::DisplayObject::unload().

template<class V >
void gnash::DisplayList::visitAll ( V &  visitor  )  [inline]

Visit each and all DisplayObject in the list.

Scan happens in arbitrary order, if order is important use visitBackward or visitForward

The visitor functor will receive a DisplayObject pointer, it's return value is not used so can return void.

NOTE: all elements in the list are visited, even the removed ones (unloaded) TODO: inspect if worth providing an arg to skip removed

Referenced by gnash::MovieClip::mouseEnabled().

template<class V >
void gnash::DisplayList::visitAll ( V &  visitor  )  const [inline]
template<class V >
void gnash::DisplayList::visitBackward ( V &  visitor  )  [inline]

Visit each DisplayObject in the list in reverse depth order (higher depth first).

The visitor functor will receive a DisplayObject pointer; must return true if it wants next item or false to exit the loop.

NOTE: all elements in the list are visited, even the removed ones (unloaded) TODO: inspect if worth providing an arg to skip removed

template<class V >
void gnash::DisplayList::visitBackward ( V &  visitor  )  const [inline]
template<class V >
void gnash::DisplayList::visitForward ( V &  visitor  )  [inline]

Visit each DisplayObject in the list in depth order (lower depth first).

The visitor functor will receive a DisplayObject pointer; must return true if it wants next item or false to exit the loop.

NOTE: all elements in the list are visited, even the removed ones (unloaded) TODO: inspect if worth providing an arg to skip removed


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const DisplayList  
) [friend]

Output operator.


The documentation for this class was generated from the following files: