Gnash  0.8.11dev
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
gnash::DisplayObject Class Referenceabstract

DisplayObject is the base class for all DisplayList objects. More...

#include <DisplayObject.h>

Inheritance diagram for gnash::DisplayObject:
gnash::GcResource gnash::Bitmap gnash::InteractiveObject gnash::MorphShape gnash::Shape gnash::StaticText gnash::Video gnash::Button gnash::DisplayObjectContainer gnash::TextField gnash::MovieClip gnash::Movie gnash::BitmapMovie gnash::SWFMovie

Classes

class  MaskRenderer
 Render a dynamic mask for a specified DisplayObject. More...
 

Public Types

enum  BlendMode {
  BLENDMODE_UNDEFINED = 0, BLENDMODE_NORMAL = 1, BLENDMODE_LAYER, BLENDMODE_MULTIPLY,
  BLENDMODE_SCREEN, BLENDMODE_LIGHTEN, BLENDMODE_DARKEN, BLENDMODE_DIFFERENCE,
  BLENDMODE_ADD, BLENDMODE_SUBTRACT, BLENDMODE_INVERT, BLENDMODE_ALPHA,
  BLENDMODE_ERASE, BLENDMODE_OVERLAY, BLENDMODE_HARDLIGHT = 14
}
 
typedef std::vector< const action_buffer * > BufferList
 
typedef std::map< event_id, BufferListEvents
 

Public Member Functions

 DisplayObject (movie_root &mr, as_object *object, DisplayObject *parent)
 Construct a DisplayObject. More...
 
virtual ~DisplayObject ()
 
virtual as_environmentget_environment ()
 Return a reference to the variable scope of this DisplayObject. More...
 
virtual void visitNonProperties (KeyVisitor &) const
 Enumerate any non-proper properties. More...
 
DisplayObjectparent () const
 Return the parent of this DisplayObject, or NULL if the DisplayObject has no parent. More...
 
void set_parent (DisplayObject *parent)
 Set the parent of this DisplayObject. More...
 
virtual MovieClipto_movie ()
 
int get_depth () const
 
void set_depth (int d)
 
int getVolume () const
 Get sound volume for this DisplayObject. More...
 
void setVolume (int vol)
 Set sound volume for this DisplayObject. More...
 
int getWorldVolume () const
 Get concatenated sound volume for this DisplayObject. More...
 
virtual int getDefinitionVersion () const
 DisplayObjects can return the version of the SWF they were parsed from. More...
 
const Transformtransform () const
 
void setMatrix (const SWFMatrix &m, bool updateCache=false)
 Set local transform SWFMatrix for this DisplayObject. More...
 
void set_x_scale (double factor)
 Set the xscale value of current SWFMatrix. More...
 
void set_y_scale (double factor)
 Set the yscale value of current SWFMatrix. More...
 
void set_rotation (double rot)
 Set the rotation value of current SWFMatrix. More...
 
virtual void setWidth (double width)
 Set the width of this DisplayObject, modifying its SWFMatrix. More...
 
virtual void setHeight (double height)
 Set the height of this DisplayObject, modifying its SWFMatrix. More...
 
void setCxForm (const SWFCxForm &cx)
 
std::uint16_t get_ratio () const
 
void set_ratio (std::uint16_t r)
 
int get_clip_depth () const
 
void set_clip_depth (int d)
 See get_clip_depth() More...
 
bool isMaskLayer () const
 
bool isDynamicMask () const
 
DisplayObjectgetMask () const
 Return the DisplayObject masking this instance (if any) More...
 
void setMask (DisplayObject *mask)
 
void set_name (const ObjectURI &uri)
 Set DisplayObject name, initializing the original target member. More...
 
const ObjectURIget_name () const
 
std::unique_ptr< ExecutableCodeget_event_handler (const event_id &id) const
 Get the built-in function handlers code for the given event. More...
 
void add_event_handler (const event_id &id, const action_buffer &code)
 Set a built-in function handler for the given event. More...
 
virtual void display (Renderer &renderer, const Transform &xform)=0
 Render the DisplayObject. More...
 
virtual StaticTextgetStaticText (std::vector< const SWF::TextRecord *> &, size_t &)
 Search for StaticText objects. More...
 
virtual SWFRect getBounds () const =0
 
bool pointInBounds (std::int32_t x, std::int32_t y) const
 Return true if the given point falls in this DisplayObject's bounds. More...
 
virtual bool pointInShape (std::int32_t x, std::int32_t y) const =0
 Return true if the given point falls in this DisplayObject's shape. More...
 
virtual bool pointInVisibleShape (std::int32_t x, std::int32_t y) const
 true if the given point falls in this DisplayObject's visible shape More...
 
virtual Movieget_root () const
 Return the relative root of this DisplayObject. More...
 
virtual MovieClipgetAsRoot ()
 Return the _root ActionScript property of this DisplayObject. More...
 
virtual as_objectpathElement (const ObjectURI &uri)
 
bool get_accept_anim_moves () const
 Return true if PlaceObjects tag are allowed to move this DisplayObject. More...
 
bool isDynamic () const
 Was this DisplayObject dynamically created ? More...
 
void setDynamic ()
 Mark this DisplayObject as dynamically created. More...
 
void transformedByScript ()
 Call this function when the sprite has been transformed due to ActionScript code. More...
 
void set_visible (bool visible)
 Set whether this DisplayObject should be rendered. More...
 
bool visible () const
 
bool hasEventHandler (const event_id &id) const
 Return true if an handler for the given event is defined. More...
 
virtual InteractiveObjecttopmostMouseEntity (std::int32_t, std::int32_t)
 DisplayObjects are not a mouse entity by default. More...
 
virtual const DisplayObjectfindDropTarget (std::int32_t x, std::int32_t y, DisplayObject *dragging) const
 Point coordinates in global twips. More...
 
bool invalidated () const
 Return whether this DisplayObject has been invalidated or not. More...
 
bool childInvalidated () const
 Return whether this DisplayObject has and invalidated child or not. More...
 
virtual void update ()
 Notify a change in the DisplayObject's appearance. More...
 
void set_invalidated ()
 This function marks the DisplayObject as being modified in aspect and keeps track of current invalidated bounds the first time it's called after each call to clear_invalidated(). More...
 
void set_invalidated (const char *debug_file, int debug_line)
 
void extend_invalidated_bounds (const InvalidatedRanges &ranges)
 
void set_child_invalidated ()
 
void clear_invalidated ()
 
virtual void add_invalidated_bounds (InvalidatedRanges &ranges, bool force)
 Add the DisplayObject's invalidated bounds to the given ranges list. More...
 
virtual void omit_display ()
 
virtual void construct (as_object *=nullptr)
 Callback invoked whenever a DisplayObject is placed on stage. More...
 
bool unload ()
 Unload this instance from the stage. More...
 
virtual void getLoadedMovie (Movie *newMovie)
 Accept a loaded Movie. More...
 
bool unloaded () const
 Return true if this DisplayObject was unloaded from the stage. More...
 
virtual void destroy ()
 Mark this DisplayObject as destroyed. More...
 
bool isDestroyed () const
 Return true if this DisplayObject was destroyed. More...
 
bool boundsInClippingArea (Renderer &renderer) const
 
std::string getTargetPath () const
 Return full path to this object, in slash notation. More...
 
const std::string & getOrigTarget () const
 
std::string DSOEXPORT getTarget () const
 Return full path to this object, in dot notation. More...
 
virtual bool isSelectableTextField () const
 Return true if this DisplayObject is a selectable TextField. More...
 
bool DSOEXPORT allowHandCursor () const
 Return true if this DisplayObject allows turning the cursor into an hand shape when it happens to be the one receiving mouse events. More...
 
ObjectURI getNextUnnamedInstanceName ()
 Used to assign a name to unnamed instances. More...
 
BlendMode getBlendMode () const
 
void setBlendMode (BlendMode bm)
 
virtual bool handleFocus ()
 Set the current focus to this DisplayObject. More...
 
virtual void killFocus ()
 Some DisplayObjects require actions on losing focus. More...
 
double rotation () const
 
double scaleX () const
 
double scaleY () const
 
as_objectobject () const
 
virtual void markReachableResources () const
 Mark all reachable resources. More...
 
virtual void markOwnResources () const
 Called by markReachableResources() More...
 
boost::tribool focusRect () const
 
void focusRect (boost::tribool focus)
 
- Public Member Functions inherited from gnash::GcResource
 GcResource (GC &gc)
 Create a Garbage-collected resource associated with a GC. More...
 
void setReachable () const
 Mark this resource as being reachable. More...
 
bool isReachable () const
 Return true if this object is marked as reachable. More...
 
void clearReachable () const
 Clear the reachable flag. More...
 

Static Public Member Functions

static as_value blendMode (const fn_call &fn)
 Getter-setter for blendMode. More...
 

Static Public Attributes

static const int lowerAccessibleBound = -16384
 See also http://www.kirupa.com/developer/actionscript/depths2.htm. More...
 
static const int upperAccessibleBound = 2130690044
 
static const int staticDepthOffset = lowerAccessibleBound
 
static const int removedDepthOffset = -32769
 
static const int noClipDepthValue = -1000000
 

Protected Member Functions

virtual bool unloadChildren ()
 
movie_rootstage () const
 Get the movie_root to which this DisplayObject belongs. More...
 
void saveOriginalTarget ()
 
const Eventsget_event_handlers () const
 
void set_event_handlers (const Events &copyfrom)
 
as_objectgetPathElementSeparator (string_table::key key)
 look for '.', 'this', '..', '_parent', '_level0' and '_root' More...
 
- Protected Member Functions inherited from gnash::GcResource
virtual ~GcResource ()
 Delete this resource. More...
 

Protected Attributes

ObjectURI _name
 Name of this DisplayObject (if any) More...
 
DisplayObject_parent
 
InvalidatedRanges m_old_invalidated_ranges
 Bounds of this DisplayObject instance before first invalidation since last call to clear_invalidated(). More...
 

Detailed Description

DisplayObject is the base class for all DisplayList objects.

It represents a single active element in a movie. This class does not supply any interactivity. The hierarchy of DisplayObjects in a movie provides all visual elements in a SWF. The DisplayObject hierarchy is independent of ActionScript resources, but can be controlled via AS. DisplayObjects that can be controlled through ActionScript have an associated as_object. DisplayObjects such as Shape, do not have an associated object and cannot be referenced in AS. Derived classes include InteractiveObject, StaticText, Bitmap, Video, and Shape. All DisplayObjects may be constructed during SWF parsing. In this case they are constructed using an immutable, non-copyable SWF::DefinitionTag. This tag should never be changed! Most DisplayObjects may also be constructed dynamically. In AS3, Bitmaps and Shapes can be dynamically created. Dynamically-created DisplayObjects must not have a SWF::DefinitionTag! The presence of a definition tag may be used to distinguish static from dynamic DisplayObjects, but tags are not always stored. They are not stored in most InteractiveObjects because most properties can be overridden during SWF execution.

Member Typedef Documentation

§ BufferList

typedef std::vector<const action_buffer*> gnash::DisplayObject::BufferList

§ Events

Member Enumeration Documentation

§ BlendMode

Enumerator
BLENDMODE_UNDEFINED 
BLENDMODE_NORMAL 
BLENDMODE_LAYER 
BLENDMODE_MULTIPLY 
BLENDMODE_SCREEN 
BLENDMODE_LIGHTEN 
BLENDMODE_DARKEN 
BLENDMODE_DIFFERENCE 
BLENDMODE_ADD 
BLENDMODE_SUBTRACT 
BLENDMODE_INVERT 
BLENDMODE_ALPHA 
BLENDMODE_ERASE 
BLENDMODE_OVERLAY 
BLENDMODE_HARDLIGHT 

Constructor & Destructor Documentation

§ DisplayObject()

gnash::DisplayObject::DisplayObject ( movie_root mr,
as_object object,
DisplayObject parent 
)

Construct a DisplayObject.

Parameters
mrThe movie_root containing the DisplayObject hierarchy. All DisplayObjects may need movie_root resources.
objectAn object to be associated with this DisplayObject. If this is non-null, the DisplayObject will be referenceable in ActionScript. Referenceable DisplayObjects may access AS resources through their associated object.
parentThe parent of the new DisplayObject. This may be null.

§ ~DisplayObject()

virtual gnash::DisplayObject::~DisplayObject ( )
inlinevirtual

Member Function Documentation

§ add_event_handler()

void gnash::DisplayObject::add_event_handler ( const event_id id,
const action_buffer code 
)

Set a built-in function handler for the given event.

Mark the DisplayObject as having mouse or Key event handlers if this is the case.

NOTE: this function is only for registering statically-defined event handlers, which are the ones attached to a DisplayObject with a PlaceObject2. It's the DisplayObject's responsibility to properly invoke any user-defined event handler, which are the ones attached to a DisplayObject with ActionScript code.

Parameters
idThe event triggering the handler.
codeAn action buffer to execute when given event is triggered. The buffer is externally owned (not copied), make sure it is kept alive for the whole lifetime of this DisplayObject.

Referenced by gnash::MovieClip::add_display_object(), and set_event_handlers().

§ add_invalidated_bounds()

void gnash::DisplayObject::add_invalidated_bounds ( InvalidatedRanges ranges,
bool  force 
)
virtual

Add the DisplayObject's invalidated bounds to the given ranges list.

NOTE that this method should include the bounds that it covered the last time clear_invalidated() was called, as those need to be rerendered as well (to clear the region previously occupied by this DisplayObject).

That's why it returns the union of old_invalidated_ranges and the current bounds. The function is also used internally by set_invalidated() to update m_old_invalidated_ranges itself (you may notice some kind of circular reference), but that's no problem since old_invalidated_ranges is NULL during that call.

It is used to determine what area needs to be re-rendered. The coordinates are world coordinates (in TWIPS). Only instances with _invalidated flag set are checked unless force is set.

Reimplemented in gnash::MovieClip, gnash::TextField, gnash::InteractiveObject, gnash::Button, gnash::Video, and gnash::Bitmap.

References gnash::geometry::SnappingRanges2d< T >::add(), gnash::SWFRect::expand_to_transformed_rect(), getBounds(), gnash::SWFRect::getRange(), gnash::getWorldMatrix(), m_old_invalidated_ranges, and visible().

Referenced by gnash::Button::add_invalidated_bounds(), gnash::DisplayList::add_invalidated_bounds(), gnash::DisplayList::replaceDisplayObject(), and set_invalidated().

§ allowHandCursor()

bool gnash::DisplayObject::allowHandCursor ( ) const

Return true if this DisplayObject allows turning the cursor into an hand shape when it happens to be the one receiving mouse events.

Whether to use a hand cursor when the mouse is over this DisplayObject.

This depends on the useHandCursor AS property, but:

  1. Only AS-referenceable objects may use a hand cursor (TODO: check Video).
  2. Only objects with a release event may use a hand cursor. CANNOT CONFIRM THE ABOVE, SEE ButtonEventsTest.swf in misc-ming.all
  3. The default value (if the property is not defined) is true.

References gnash::as_object::get_member(), gnash::getObject(), gnash::getVM(), gnash::NSV::PROP_USEHANDCURSOR, and gnash::toBool().

Referenced by gnash::Gui::notifyMouseMove(), and gnash::Gui::setInvalidatedRegions().

§ blendMode()

as_value gnash::DisplayObject::blendMode ( const fn_call fn)
static

Getter-setter for blendMode.

If the blend mode is undefined, it doesn't return a string.

The extra static cast is required to keep OpenBSD happy.

References _, gnash::key::_1, gnash::fn_call::arg(), BLENDMODE_HARDLIGHT, BLENDMODE_NORMAL, BLENDMODE_UNDEFINED, getBlendMode(), gnash::getVM(), LOG_ONCE, gnash::log_unimpl(), gnash::fn_call::nargs, setBlendMode(), and gnash::toNumber().

Referenced by gnash::registerMovieClipNative().

§ boundsInClippingArea()

bool gnash::DisplayObject::boundsInClippingArea ( Renderer renderer) const

Returns true when the DisplayObject bounds intersect with the current rendering clipping area.

There is no need to do any rendering for this DisplayObject when this function returns false because the renderer will not change any pixels in the area where this DisplayObject is placed.

References _, gnash::Renderer::bounds_in_clipping_area(), get_clip_depth(), get_depth(), get_ratio(), getBounds(), gnash::SWFRect::getRange(), getTarget(), gnash::getWorldMatrix(), gnash::SWFRect::height(), isDestroyed(), isDynamic(), isMaskLayer(), noClipDepthValue, gnash::SWFMatrix::transform(), gnash::typeName(), unloaded(), and gnash::SWFRect::width().

Referenced by gnash::DisplayList::display().

§ childInvalidated()

bool gnash::DisplayObject::childInvalidated ( ) const
inline

Return whether this DisplayObject has and invalidated child or not.

Referenced by gnash::MovieClip::add_invalidated_bounds(), and gnash::MovieClip::omit_display().

§ clear_invalidated()

void gnash::DisplayObject::clear_invalidated ( )
inline

Clear invalidated flag and reset m_old_invalidated_bounds to null.

It is very important that each DisplayObject with any m_XXXX_invalidated flag set calls clear_invalidated() during the rendering of one frame. Basically this means each call to display() must match a call to clear_invalidated. This includes no-op display() calls, i.e. when the DisplayObject is outside of the screen. The DisplayList must still call clear_invalidated() even if display() is not necessary.

Not doing so will result in a stale invalidated flag which in turn will prevent the parent to be informed when this DisplayObject (or a child) is invalidated again (see set_invalidated() recursion).

Referenced by gnash::Shape::display(), gnash::MorphShape::display(), gnash::Video::display(), gnash::Bitmap::display(), gnash::StaticText::display(), gnash::Button::display(), gnash::TextField::display(), gnash::MovieClip::display(), gnash::movie_root::display(), and gnash::MovieClip::omit_display().

§ construct()

virtual void gnash::DisplayObject::construct ( as_object = nullptr)
inlinevirtual

Callback invoked whenever a DisplayObject is placed on stage.

This function must be called when the DisplayObject is placed on stage for the first time.

The DisplayObject version of this call sets the original target of the DisplayObject, for soft references to work. If you override the method remember to call saveOriginalTarget() as the first thing.

This handles all ActionScript construction and initialization events.

Reimplemented in gnash::MovieClip, gnash::Button, gnash::SWFMovie, gnash::Bitmap, and gnash::Video.

Referenced by gnash::MovieClip::add_display_object(), gnash::MovieClip::addDisplayListObject(), gnash::MovieClip::attachCharacter(), gnash::Button::construct(), gnash::MovieClip::replace_display_object(), and gnash::Button::set_current_state().

§ destroy()

void gnash::DisplayObject::destroy ( )
virtual

Mark this DisplayObject as destroyed.

A DisplayObject should be destroyed when is removed from the display list and is not more needed for names (target) resolutions. Sprites are needed for names resolution whenever themselves or a contained object has an onUnload event handler defined, in which case we want the event handler to find the 'this' variable w/out attempting to rebind it.

Note: this function can safely release most memory associated with the DisplayObject as it will not be needed anymore.

we may destory a DisplayObject that's not unloaded. (we don't have chance to unload it in current model, see new_child_in_unload_test.c) We don't destroy ourself twice, right ?

Reimplemented in gnash::MovieClip, and gnash::Button.

References gnash::as_object::clearProperties().

Referenced by gnash::Button::destroy(), gnash::DisplayList::destroy(), gnash::MovieClip::destroy(), gnash::DisplayList::mergeDisplayList(), gnash::DisplayList::placeDisplayObject(), gnash::DisplayList::removeDisplayObject(), gnash::DisplayList::replaceDisplayObject(), gnash::Button::set_current_state(), and gnash::DisplayList::unload().

§ display()

virtual void gnash::DisplayObject::display ( Renderer renderer,
const Transform xform 
)
pure virtual

§ extend_invalidated_bounds()

void gnash::DisplayObject::extend_invalidated_bounds ( const InvalidatedRanges ranges)

Calls set_invalidated() and extends old_invalidated_ranges to the given value so that also this area gets re-rendered (used when replacing DisplayObjects).

References gnash::geometry::SnappingRanges2d< T >::add(), m_old_invalidated_ranges, and set_invalidated().

Referenced by gnash::DisplayList::placeDisplayObject(), and gnash::DisplayList::replaceDisplayObject().

§ findDropTarget()

virtual const DisplayObject* gnash::DisplayObject::findDropTarget ( std::int32_t  x,
std::int32_t  y,
DisplayObject dragging 
) const
inlinevirtual

Point coordinates in global twips.

Find highest depth DisplayObject whose shape contains the given point and is not the DisplayObject being dragged or any of its childs.

Reimplemented in gnash::MovieClip.

References gnash::visible().

§ focusRect() [1/2]

boost::tribool gnash::DisplayObject::focusRect ( ) const
inline

§ focusRect() [2/2]

void gnash::DisplayObject::focusRect ( boost::tribool  focus)
inline

§ get_accept_anim_moves()

bool gnash::DisplayObject::get_accept_anim_moves ( ) const
inline

Return true if PlaceObjects tag are allowed to move this DisplayObject.

Once a DisplayObject has been transformed by ActionScript, further transformation trought non-action SWF constrol tags is not allowed.

See scriptTransformed()

Referenced by gnash::DisplayList::mergeDisplayList(), and gnash::DisplayList::moveDisplayObject().

§ get_clip_depth()

int gnash::DisplayObject::get_clip_depth ( ) const
inline

Returns the clipping depth (if any) of this DisplayObject. The parameter tells us to use the DisplayObject as a mask for all the objects contained in the display list from _depth to m_clipping_depth inclusive.

The value returned by get_clip_depth() is only valid when isMaskLayer() returns true!

Referenced by gnash::DisplayList::add_invalidated_bounds(), boundsInClippingArea(), gnash::DisplayList::display(), gnash::MovieClip::duplicateMovieClip(), and gnash::MovieClip::getLoadedMovie().

§ get_depth()

int gnash::DisplayObject::get_depth ( ) const
inline

§ get_environment()

virtual as_environment& gnash::DisplayObject::get_environment ( )
inlinevirtual

Return a reference to the variable scope of this DisplayObject.

Reimplemented in gnash::MovieClip.

Referenced by gnash::TextField::getDefinitionVersion(), and gnash::Button::mouseEvent().

§ get_event_handler()

std::unique_ptr< ExecutableCode > gnash::DisplayObject::get_event_handler ( const event_id id) const

Get the built-in function handlers code for the given event.

NOTE: this function is only for getting statically-defined event handlers, which are the ones attached to a DisplayObject with a PlaceObject2. It's the DisplayObject's responsibility to properly fetch any user-defined event handler, which are the ones attached to a DisplayObject with ActionScript code.

Referenced by gnash::Button::mouseEvent(), and gnash::MovieClip::notifyEvent().

§ get_event_handlers()

const Events& gnash::DisplayObject::get_event_handlers ( ) const
inlineprotected

§ get_name()

const ObjectURI& gnash::DisplayObject::get_name ( ) const
inline

§ get_ratio()

std::uint16_t gnash::DisplayObject::get_ratio ( ) const
inline

§ get_root()

virtual Movie* gnash::DisplayObject::get_root ( ) const
inlinevirtual

Return the relative root of this DisplayObject.

The "relative" is the Movie created by the same SWF definition that contained the definition of this DisplayObject.

The default implementation is to invoke get_root against this DisplayObject's parent.

Reimplemented in gnash::MovieClip.

References get_root(), and test::uri.

Referenced by gnash::sprite_definition::createDisplayObject(), get_root(), getAsRoot(), gnash::TextField::getDefinitionVersion(), gnash::initObjectClass(), gnash::registerBitmapDataNative(), gnash::registerTextFieldNative(), and gnash::DisplayObject::MaskRenderer::~MaskRenderer().

§ getAsRoot()

MovieClip * gnash::DisplayObject::getAsRoot ( )
virtual

Return the _root ActionScript property of this DisplayObject.

By default calls get_root(). The resulting MovieClip may be passed to actionscript methods, so it is not const. As the override in MovieClip may return this, the method cannot be const either.

Reimplemented in gnash::MovieClip.

References get_root().

Referenced by gnash::Function2::call(), gnash::findObject(), gnash::MovieClip::getAsRoot(), and gnash::getDisplayObjectProperty().

§ getBlendMode()

BlendMode gnash::DisplayObject::getBlendMode ( ) const
inline

Referenced by blendMode().

§ getBounds()

virtual SWFRect gnash::DisplayObject::getBounds ( ) const
pure virtual

§ getDefinitionVersion()

virtual int gnash::DisplayObject::getDefinitionVersion ( ) const
inlinevirtual

DisplayObjects can return the version of the SWF they were parsed from.

Reimplemented in gnash::MovieClip, and gnash::TextField.

Referenced by gnash::registerMovieClipNative().

§ getLoadedMovie()

void gnash::DisplayObject::getLoadedMovie ( Movie newMovie)
virtual

Accept a loaded Movie.

Reimplemented in gnash::MovieClip.

References _, LOG_ONCE, gnash::log_unimpl(), gnash::typeName(), and UNUSED.

Referenced by gnash::MovieLoader::clear().

§ getMask()

DisplayObject* gnash::DisplayObject::getMask ( ) const
inline

Return the DisplayObject masking this instance (if any)

Referenced by gnash::MovieClip::pointInHitableShape(), and gnash::MovieClip::pointInVisibleShape().

§ getNextUnnamedInstanceName()

ObjectURI gnash::DisplayObject::getNextUnnamedInstanceName ( )

§ getOrigTarget()

const std::string& gnash::DisplayObject::getOrigTarget ( ) const
inline

Return original target path to this object, in dot notation as of at construction time. This is needed to properly dereference dangling soft-references See testcase misc-swfc.all/soft_reference_test1.sc

References DSOEXPORT.

§ getPathElementSeparator()

as_object* gnash::DisplayObject::getPathElementSeparator ( string_table::key  key)
protected

look for '.', 'this', '..', '_parent', '_level0' and '_root'

NOTE: case insensitive up to SWF6, sensitive from SWF7 up

§ getStaticText()

virtual StaticText* gnash::DisplayObject::getStaticText ( std::vector< const SWF::TextRecord *> &  ,
size_t &   
)
inlinevirtual

Search for StaticText objects.

If this is a StaticText object and contains SWF::TextRecords, these are written to the passed parameter. @ return 0 if this object is not a StaticText or contains no text.

Reimplemented in gnash::InteractiveObject, and gnash::StaticText.

§ getTarget()

std::string gnash::DisplayObject::getTarget ( ) const

§ getTargetPath()

std::string gnash::DisplayObject::getTargetPath ( ) const

§ getVolume()

int gnash::DisplayObject::getVolume ( ) const
inline

Get sound volume for this DisplayObject.

Referenced by getWorldVolume(), and gnash::registerSoundNative().

§ getWorldVolume()

int gnash::DisplayObject::getWorldVolume ( ) const

Get concatenated sound volume for this DisplayObject.

NOTE: the concatenated volume does NOT include global volume settings, which is the one controlled by Sound instances created passing null, undefined or no argument to constructor.

References _parent, getVolume(), and volume.

Referenced by gnash::NetStream_as::play().

§ handleFocus()

virtual bool gnash::DisplayObject::handleFocus ( )
inlinevirtual

Set the current focus to this DisplayObject.

Returns
false if the DisplayObject cannot receive focus, true if it can (and does). Button, Textfield and MovieClip can receive focus. In SWF6 and above, MovieClip can only receive focus if the focusEnabled property evaluates to true.

Reimplemented in gnash::MovieClip, and gnash::Button.

Referenced by gnash::movie_root::setFocus().

§ hasEventHandler()

bool gnash::DisplayObject::hasEventHandler ( const event_id id) const

Return true if an handler for the given event is defined.

NOTE that we look for both clip-defined and user-defined handlers, which is likely error prone since we're doing this in a non-virtual function. Main use for this method is for being called by ::unload() to verify an Unload handler is available.

References gnash::as_object::findProperty().

Referenced by gnash::MovieClip::mouseEnabled(), and gnash::MovieClip::unloadChildren().

§ invalidated()

bool gnash::DisplayObject::invalidated ( ) const
inline

§ isDestroyed()

bool gnash::DisplayObject::isDestroyed ( ) const
inline

§ isDynamic()

bool gnash::DisplayObject::isDynamic ( ) const
inline

Was this DisplayObject dynamically created ?

"Dynamically created" means created trough ActionScript.

NOTE, With current code:

  • Characters created by means of a loadMovie are NOT set as dynamic (should check if they should)
  • Characters created by attachMovie ARE dynamic
  • Characters created by duplicateMovieClip ARE dynamic
  • Characters created by createEmptyMovieClip ARE dynamic
  • Characters created by new Video ARE dynamic
  • Characters created by createTextField ARE dynamic

Referenced by boundsInClippingArea(), gnash::MovieClip::construct(), gnash::DisplayList::mergeDisplayList(), and gnash::MovieClip::notifyEvent().

§ isDynamicMask()

bool gnash::DisplayObject::isDynamicMask ( ) const
inline

Returns true when the DisplayObject (and its childs) is used as a mask for another DisplayObject. isDynamicMask() does not return true when one of its parents is a mask and the DisplayObject itself is not.

NOTE: there's no way to obtain the maskee from a dynamic mask

See also isMaskLayer() and isMask()

Referenced by gnash::DisplayList::display(), gnash::MovieClip::pointInHitableShape(), and gnash::MovieClip::pointInVisibleShape().

§ isMaskLayer()

bool gnash::DisplayObject::isMaskLayer ( ) const
inline

Returns true when the DisplayObject (and its childs) is used as a mask for other DisplayObjects at higher depth (up to get_clip_depth). isMaskLayer() does not return true when one of its parents is a mask and the DisplayObject itself is not.

See also isDynamicMask() and isMask()

Referenced by gnash::DisplayList::add_invalidated_bounds(), boundsInClippingArea(), and gnash::DisplayList::display().

§ isSelectableTextField()

virtual bool gnash::DisplayObject::isSelectableTextField ( ) const
inlinevirtual

Return true if this DisplayObject is a selectable TextField.

This method is used by Gui to set up an appropriate cursor for input textfields.

Reimplemented in gnash::TextField.

References DSOEXPORT.

Referenced by gnash::Gui::notifyMouseMove().

§ killFocus()

virtual void gnash::DisplayObject::killFocus ( )
inlinevirtual

Some DisplayObjects require actions on losing focus.

Default is a no-op. TextField implements this function.

Referenced by gnash::movie_root::setFocus().

§ markOwnResources()

virtual void gnash::DisplayObject::markOwnResources ( ) const
inlinevirtual

Called by markReachableResources()

DisplayObjects should mark their own resources in this function.

Reimplemented in gnash::MovieClip, gnash::Button, and gnash::Video.

Referenced by markReachableResources().

§ markReachableResources()

void gnash::DisplayObject::markReachableResources ( ) const
virtual

Mark all reachable resources.

Try not to override this function in derived classes. This always marks the base class's resources and calls markOwnResources() to take care of any further GC resources.

Reimplemented from gnash::GcResource.

References _parent, markOwnResources(), and gnash::GcResource::setReachable().

§ object()

as_object* gnash::DisplayObject::object ( ) const
inline

References _object.

Referenced by gnash::getObject(), and gnash::isReferenceable().

§ omit_display()

virtual void gnash::DisplayObject::omit_display ( )
inlinevirtual

Called instead of display() when the DisplayObject is not visible on stage. Used to clear the invalidated flags.

Reimplemented in gnash::MovieClip.

Referenced by gnash::DisplayList::display(), and gnash::DisplayList::omit_display().

§ parent()

DisplayObject* gnash::DisplayObject::parent ( ) const
inline

§ pathElement()

as_object * gnash::DisplayObject::pathElement ( const ObjectURI uri)
virtual

Find the object which is one degree removed from us, given the relative pathname.

If the pathname is "..", then return our parent. If the pathname is ".", then return ourself. If the pathname is "_level0" or "_root", then return the root movie.

Otherwise, the name should refer to one our our named DisplayObjects, so we return it.

NOTE: In ActionScript 2.0, top level names (like "_root" and "_level0") are CASE SENSITIVE. Character names in a display list are CASE SENSITIVE. Member names are CASE INSENSITIVE. Gah.

In ActionScript 1.0, everything seems to be CASE INSENSITIVE.

Reimplemented in gnash::MovieClip.

References gnash::caseless(), gnash::string_table::find(), gnash::getName(), gnash::getObject(), gnash::VM::getStringTable(), gnash::movie_root::getVM(), parent(), gnash::NSV::PROP_THIS, stage(), and test::uri.

Referenced by gnash::movie_root::findCharacterByTarget(), gnash::parsePath(), and gnash::MovieClip::pathElement().

§ pointInBounds()

bool gnash::DisplayObject::pointInBounds ( std::int32_t  x,
std::int32_t  y 
) const
inline

Return true if the given point falls in this DisplayObject's bounds.

Parameters
xPoint x coordinate in world space
yPoint y coordinate in world space
Returns
Whether (x, y) is within the DisplayObject's bounds. This ignores _root's transform.

References gnash::getWorldMatrix(), gnash::SWFRect::point_test(), gnash::SWFMatrix::transform(), x, and y.

Referenced by gnash::Bitmap::pointInShape(), gnash::StaticText::pointInShape(), and gnash::registerMovieClipNative().

§ pointInShape()

virtual bool gnash::DisplayObject::pointInShape ( std::int32_t  x,
std::int32_t  y 
) const
pure virtual

Return true if the given point falls in this DisplayObject's shape.

Parameters
xPoint x coordinate in world space
yPoint y coordinate in world space
Returns
Whether (x, y) is within the DisplayObject's bounds.

Implemented in gnash::TextField, gnash::MovieClip, gnash::InteractiveObject, gnash::Button, gnash::StaticText, gnash::Bitmap, gnash::MorphShape, gnash::Video, and gnash::Shape.

Referenced by gnash::MovieClip::pointInHitableShape(), gnash::Button::pointInShape(), and gnash::MovieClip::pointInVisibleShape().

§ pointInVisibleShape()

virtual bool gnash::DisplayObject::pointInVisibleShape ( std::int32_t  x,
std::int32_t  y 
) const
inlinevirtual

true if the given point falls in this DisplayObject's visible shape

Point coordinates are in world TWIPS

The default implementation returns false if the DisplayObject is not visible, calling pointInShape() otherwise.

Note that this is good for simple DisplayObjects but needs to be overridden for DisplayObjects with childs. When a DisplayObject has childs it must take into account the case in which some childs are visible and some are not.

Reimplemented in gnash::MovieClip.

References gnash::visible().

§ rotation()

double gnash::DisplayObject::rotation ( ) const
inline

§ saveOriginalTarget()

void gnash::DisplayObject::saveOriginalTarget ( )
inlineprotected

Register currently computable target as the "original" one. This will be used by soft references (as_value) and should be called as soon as the stagePlacementCallback is invoked.

Referenced by gnash::Video::construct(), gnash::SWFMovie::construct(), gnash::Button::construct(), and gnash::MovieClip::construct().

§ scaleX()

double gnash::DisplayObject::scaleX ( ) const
inline

§ scaleY()

double gnash::DisplayObject::scaleY ( ) const
inline

§ set_child_invalidated()

void gnash::DisplayObject::set_child_invalidated ( )

Called by a child to signalize it has changed visibily. The difference to set_invalidated() is that this DisplayObject does not need to redraw itself completely. This function will recursively inform all its parents of the change.

References _parent, and set_child_invalidated().

Referenced by set_child_invalidated(), and set_invalidated().

§ set_clip_depth()

void gnash::DisplayObject::set_clip_depth ( int  d)
inline

§ set_depth()

void gnash::DisplayObject::set_depth ( int  d)
inline

§ set_event_handlers()

void gnash::DisplayObject::set_event_handlers ( const Events copyfrom)
protected

§ set_invalidated() [1/2]

void gnash::DisplayObject::set_invalidated ( )

This function marks the DisplayObject as being modified in aspect and keeps track of current invalidated bounds the first time it's called after each call to clear_invalidated().

Call this function before any change in this DisplayObject that modifies its rendering. This information will be used to detect visual changes that need to be redrawn.

It is important to call this function before the change rather then after as it will also take care of updating the previously invalidated bounds (m_old_invalidated_bounds)

Calling this function multiple time is a no-op, unless clear_invalidated() is called in between.

NOTE: Marking a DisplayObject as invalidated automatically marks its parent as being invalidated.

See also
Detection of updated regions

Referenced by gnash::MovieClip::addDisplayListObject(), gnash::Video::clear(), gnash::Bitmap::construct(), gnash::SWF::RemoveObjectTag::executeState(), extend_invalidated_bounds(), gnash::TextField::getTextAlignment(), gnash::DisplayList::insertDisplayObject(), gnash::TextField::keyInput(), gnash::DisplayList::mergeDisplayList(), gnash::DisplayList::placeDisplayObject(), gnash::MovieClip::remove_display_object(), gnash::DisplayList::replaceDisplayObject(), gnash::NetStream_as::seek(), gnash::Button::set_current_state(), set_visible(), gnash::TextField::setAlignment(), gnash::TextField::setAutoSize(), gnash::TextField::setBackgroundColor(), gnash::TextField::setBlockIndent(), gnash::TextField::setBorderColor(), gnash::TextField::setDisplay(), gnash::TextField::setDrawBackground(), gnash::TextField::setDrawBorder(), gnash::TextField::setEmbedFonts(), gnash::TextField::setFont(), gnash::TextField::setFontHeight(), gnash::TextField::setIndent(), gnash::TextField::setLeading(), gnash::TextField::setLeftMargin(), gnash::movie_root::setLevel(), setMask(), setMatrix(), gnash::TextField::setRightMargin(), gnash::TextField::setTabStops(), gnash::TextField::setTarget(), gnash::TextField::setTextColor(), gnash::TextField::setUnderlined(), gnash::TextField::setURL(), gnash::TextField::setWordWrap(), gnash::DisplayList::swapDepths(), gnash::movie_root::swapLevels(), gnash::Bitmap::update(), and gnash::TextField::updateText().

§ set_invalidated() [2/2]

void gnash::DisplayObject::set_invalidated ( const char *  debug_file,
int  debug_line 
)

§ set_name()

void gnash::DisplayObject::set_name ( const ObjectURI uri)
inline

§ set_parent()

void gnash::DisplayObject::set_parent ( DisplayObject parent)
inline

Set the parent of this DisplayObject.

In AS3, DisplayObjects may be created before being attached to a parent. In AS2, this is only used for external movies

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

§ set_ratio()

void gnash::DisplayObject::set_ratio ( std::uint16_t  r)
inline

§ set_rotation()

void gnash::DisplayObject::set_rotation ( double  rot)

Set the rotation value of current SWFMatrix.

Set the real and cached rotation.

This is used when setting _rotation See rotation_getset

Parameters
rotrotation in degrees. will be trimmed to the -180 .. 180 range, can be passed outside it.

Cached scale values are not updated.

References gnash::getMatrix(), gnash::key::m, rotation(), scaleX(), gnash::SWFMatrix::set_rotation(), gnash::SWFMatrix::set_x_scale(), setMatrix(), and transformedByScript().

Referenced by gnash::DisplayObject::MaskRenderer::~MaskRenderer().

§ set_visible()

void gnash::DisplayObject::set_visible ( bool  visible)

Set whether this DisplayObject should be rendered.

TODO: handle all visible getter/setters in DisplayObject, not in subclasses, and drop this / make it private.

References gnash::movie_root::getFocus(), set_invalidated(), gnash::movie_root::setFocus(), stage(), and visible().

Referenced by gnash::DisplayObject::MaskRenderer::~MaskRenderer().

§ set_x_scale()

void gnash::DisplayObject::set_x_scale ( double  scale_percent)

Set the xscale value of current SWFMatrix.

Set the real and cached x scale.

This is used when setting _xscale. See xscale_getset.

Parameters
factorscale factor, in percent

Cached rotation and y scale are not updated.

References gnash::getMatrix(), gnash::key::m, gnash::SWFMatrix::set_x_scale(), setMatrix(), and transformedByScript().

Referenced by gnash::DisplayObject::MaskRenderer::~MaskRenderer().

§ set_y_scale()

void gnash::DisplayObject::set_y_scale ( double  scale_percent)

Set the yscale value of current SWFMatrix.

Set the real and cached y scale.

This is used when setting _yscale See yscale_getset.

Parameters
factorscale factor, in percent

Cached rotation and x scale are not updated.

References gnash::getMatrix(), gnash::key::m, gnash::SWFMatrix::set_y_scale(), setMatrix(), and transformedByScript().

Referenced by gnash::DisplayObject::MaskRenderer::~MaskRenderer().

§ setBlendMode()

void gnash::DisplayObject::setBlendMode ( BlendMode  bm)
inline

§ setCxForm()

void gnash::DisplayObject::setCxForm ( const SWFCxForm cx)
inline

§ setDynamic()

void gnash::DisplayObject::setDynamic ( )
inline

§ setHeight()

void gnash::DisplayObject::setHeight ( double  height)
virtual

Set the height of this DisplayObject, modifying its SWFMatrix.

This is used when setting _height

Parameters
hnew height, in TWIPS.

Reimplemented in gnash::TextField.

References gnash::SWFMatrix::get_x_scale(), getBounds(), gnash::getMatrix(), gnash::SWFRect::height(), gnash::key::m, rotation(), gnash::SWFMatrix::set_scale_rotation(), and setMatrix().

Referenced by gnash::setHeight(), and gnash::DisplayObject::MaskRenderer::~MaskRenderer().

§ setMask()

void gnash::DisplayObject::setMask ( DisplayObject mask)

Register a DisplayObject as a mask for this instance.

Parameters
maskThe DisplayObject to use as a mask, possibly NULL. A reference to us will be registered with the mask, if not null, so it'll know it's a mask for us, and would stop being a mask for anything else.

Register as as masked by the mask

References noClipDepthValue, set_clip_depth(), set_invalidated(), and setMask().

Referenced by gnash::registerMovieClipNative(), setMask(), and unload().

§ setMatrix()

void gnash::DisplayObject::setMatrix ( const SWFMatrix m,
bool  updateCache = false 
)

§ setVolume()

void gnash::DisplayObject::setVolume ( int  vol)
inline

Set sound volume for this DisplayObject.

Referenced by gnash::registerSoundNative().

§ setWidth()

void gnash::DisplayObject::setWidth ( double  width)
virtual

Set the width of this DisplayObject, modifying its SWFMatrix.

This is used when setting _width

Parameters
wnew width, in TWIPS. TextField does this differently (caches not updated).

Reimplemented in gnash::TextField.

References gnash::SWFMatrix::get_y_scale(), getBounds(), gnash::getMatrix(), gnash::key::m, rotation(), gnash::SWFMatrix::set_scale_rotation(), setMatrix(), and gnash::SWFRect::width().

Referenced by gnash::DisplayObject::MaskRenderer::~MaskRenderer().

§ stage()

movie_root& gnash::DisplayObject::stage ( ) const
inlineprotected

§ to_movie()

virtual MovieClip* gnash::DisplayObject::to_movie ( )
inlinevirtual

§ topmostMouseEntity()

virtual InteractiveObject* gnash::DisplayObject::topmostMouseEntity ( std::int32_t  ,
std::int32_t   
)
inlinevirtual

DisplayObjects are not a mouse entity by default.

Override this function for InteractiveObjects.

Reimplemented in gnash::MovieClip, gnash::TextField, gnash::InteractiveObject, and gnash::Button.

Referenced by gnash::Button::topmostMouseEntity().

§ transform()

const Transform& gnash::DisplayObject::transform ( ) const
inline

§ transformedByScript()

void gnash::DisplayObject::transformedByScript ( )
inline

Call this function when the sprite has been transformed due to ActionScript code.

This information will be used while executing PlaceObject tags in that ActionScript-transformed DisplayObjects won't be allowed to be moved.

TODO: make protected

References gnash::visible().

Referenced by gnash::SWF::SWFHandlers::execute(), gnash::registerMovieClipNative(), set_rotation(), set_x_scale(), set_y_scale(), gnash::DisplayList::swapDepths(), and gnash::DisplayObject::MaskRenderer::~MaskRenderer().

§ unload()

bool gnash::DisplayObject::unload ( )

Unload this instance from the stage.

This function must be called when the DisplayObject is removed from the stage. It will take care of properly calling unload against any child DisplayObjects and queuing the 'UNLOAD' event handler.

Returns
true if any onUnload event handler was defined by either this or any child DisplayObjects, false otherwise.

References setMask(), and unloadChildren().

Referenced by gnash::movie_root::dropLevel(), gnash::DisplayList::mergeDisplayList(), gnash::DisplayList::placeDisplayObject(), gnash::DisplayList::removeDisplayObject(), gnash::DisplayList::replaceDisplayObject(), gnash::Button::set_current_state(), and gnash::DisplayList::unload().

§ unloadChildren()

virtual bool gnash::DisplayObject::unloadChildren ( )
inlineprotectedvirtual

Reimplemented in gnash::MovieClip, and gnash::Button.

Referenced by unload().

§ unloaded()

bool gnash::DisplayObject::unloaded ( ) const
inline

§ update()

virtual void gnash::DisplayObject::update ( )
inlinevirtual

Notify a change in the DisplayObject's appearance.

Reimplemented in gnash::Bitmap.

Referenced by gnash::BitmapData_as::updateObjects().

§ visible()

bool gnash::DisplayObject::visible ( ) const
inline

§ visitNonProperties()

virtual void gnash::DisplayObject::visitNonProperties ( KeyVisitor ) const
inlinevirtual

Enumerate any non-proper properties.

This function allows enumeration of properties that are derived from the DisplayObject type, e.g. DisplayList members.

The default implementation adds nothing

Reimplemented in gnash::MovieClip.

Referenced by gnash::as_object::visitKeys().

Member Data Documentation

§ _name

ObjectURI gnash::DisplayObject::_name
protected

Name of this DisplayObject (if any)

§ _parent

DisplayObject* gnash::DisplayObject::_parent
protected

§ lowerAccessibleBound

const int gnash::DisplayObject::lowerAccessibleBound = -16384
static

See also http://www.kirupa.com/developer/actionscript/depths2.htm.

The lowest placeable and accessible depth for a DisplayObject. Macromedia Flash help says: depth starts at -16383 (0x3FFF)

See: http://www.senocular.com/flash/tutorials/depths/?page=2The only way to exceed these bounds is with createEmptyMoveClip(), which can be placed at any depth within +/- 2**31.

Referenced by gnash::SWF::SWFHandlers::execute(), and gnash::registerMovieClipNative().

§ m_old_invalidated_ranges

InvalidatedRanges gnash::DisplayObject::m_old_invalidated_ranges
protected

Bounds of this DisplayObject instance before first invalidation since last call to clear_invalidated().

This stores the bounds of the DisplayObject before it has been changed, ie. the position when set_invalidated() is being called. While drawing, both the old and the new bounds are updated (rendered). When moving a DisplayObject A to B then both the position A needs to be re-rendered (to reveal the backgrond) and the position B needs to be re-rendered (to show the DisplayObject in its new position). The bounds may be identical or overlap, but SnappingRanges takes care of that.

Will be set by set_invalidated() and used by get_invalidated_bounds().

Referenced by gnash::Bitmap::add_invalidated_bounds(), gnash::Video::add_invalidated_bounds(), gnash::Button::add_invalidated_bounds(), gnash::TextField::add_invalidated_bounds(), gnash::MovieClip::add_invalidated_bounds(), add_invalidated_bounds(), extend_invalidated_bounds(), and set_invalidated().

§ noClipDepthValue

const int gnash::DisplayObject::noClipDepthValue = -1000000
static

This value is used for m_clip_depth when the DisplayObject is not a layer mask. Depths below -16384 are illegal, so this value should not collide with real depths.

Referenced by boundsInClippingArea(), and setMask().

§ removedDepthOffset

const int gnash::DisplayObject::removedDepthOffset = -32769
static

This is the offset at which DisplayObject's depth is shifted when a DisplayObject is removed from stage but an onUnload event handler is defined.

Example: a DisplayObject at depth 60 gets moved to depth -32829 (-32769-60) when unloaded and an onUnload event handler is defined for it or any of its childs.

So, to recap: 1: -32769 to -16385 are removed 2: -16384 to 0 are statics 3: Max depth for a PlaceObject call is 16384 (which becomes 0 in the statics) (all of the above correct?)

Referenced by gnash::DisplayList::mergeDisplayList(), gnash::DisplayList::removeUnloaded(), and gnash::Button::set_current_state().

§ staticDepthOffset

const int gnash::DisplayObject::staticDepthOffset = lowerAccessibleBound
static

§ upperAccessibleBound

const int gnash::DisplayObject::upperAccessibleBound = 2130690044
static

This is the maximum depth a MovieClip DisplayObject can be placed at (attachMovie). Kirupa (see above) says 2130690045, but this seems not to be included in the range.

Referenced by gnash::SWF::SWFHandlers::execute(), and gnash::registerMovieClipNative().


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