|
Gnash
0.8.11dev
|
Button implements Flash buttons. More...
#include <Button.h>
Public Types | |
| enum | mouse_flags { FLAG_IDLE = 0, FLAG_OVER = 1, FLAG_DOWN = 2, OVER_DOWN = FLAG_OVER | FLAG_DOWN, OVER_UP = FLAG_OVER, OUT_DOWN = FLAG_DOWN } |
| enum | MouseState { MOUSESTATE_UP = 0, MOUSESTATE_DOWN, MOUSESTATE_OVER, MOUSESTATE_HIT } |
| typedef std::vector< DisplayObject * > | DisplayObjects |
| typedef std::vector< const DisplayObject * > | ConstDisplayObjects |
| typedef std::set< int > | ActiveRecords |
| A container for holding the id of active button records. More... | |
Public Types inherited from gnash::DisplayObject | |
| 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, BufferList > | Events |
Public Member Functions | |
| Button (as_object *object, const SWF::DefineButtonTag *def, DisplayObject *parent) | |
| Construct a Button. More... | |
| ~Button () | |
| bool | mouseEnabled () const |
| Whether the DisplayObject can handle a mouse event. More... | |
| virtual bool | trackAsMenu () |
| ActionScript property of Buttons and MovieClips altering mouse handling. More... | |
| void | keyPress (key::code c) |
| Handle a key press associated with a button event. More... | |
| virtual void | display (Renderer &renderer, const Transform &xform) |
| Render this Button. More... | |
| void | set_current_state (MouseState new_state) |
| virtual InteractiveObject * | topmostMouseEntity (std::int32_t x, std::int32_t y) |
| Return the topmost entity that the given point covers. NULL if none. More... | |
| virtual void | mouseEvent (const event_id &event) |
| Called whenever a mouse event affects this Button. More... | |
| virtual bool | handleFocus () |
| Called when the Button is in focus. More... | |
| void | add_invalidated_bounds (InvalidatedRanges &ranges, bool force) |
| Add the DisplayObject's invalidated bounds to the given ranges list. More... | |
| virtual SWFRect | getBounds () const |
| Returns local, untransformed bounds of this DisplayObject in TWIPS. More... | |
| bool | pointInShape (std::int32_t x, std::int32_t y) const |
| Return true if the given point falls in this DisplayObject's shape. More... | |
| bool | isEnabled () |
| void | destroy () |
| Properly destroy contained DisplayObjects. More... | |
| virtual void | construct (as_object *init=nullptr) |
| Do ActionScript construction of the Button. More... | |
Public Member Functions inherited from gnash::InteractiveObject | |
| InteractiveObject (as_object *object, DisplayObject *parent) | |
| virtual | ~InteractiveObject () |
| virtual StaticText * | getStaticText (std::vector< const SWF::TextRecord *> &, size_t &) |
| Allow extraction of static text. More... | |
Public Member Functions inherited from gnash::DisplayObject | |
| DisplayObject (movie_root &mr, as_object *object, DisplayObject *parent) | |
| Construct a DisplayObject. More... | |
| virtual | ~DisplayObject () |
| virtual as_environment & | get_environment () |
| Return a reference to the variable scope of this DisplayObject. More... | |
| virtual void | visitNonProperties (KeyVisitor &) const |
| Enumerate any non-proper properties. More... | |
| DisplayObject * | parent () 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 MovieClip * | to_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... | |
| const Transform & | transform () 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 |
| DisplayObject * | getMask () 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 ObjectURI & | get_name () const |
| std::unique_ptr< ExecutableCode > | get_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... | |
| 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 | pointInVisibleShape (std::int32_t x, std::int32_t y) const |
| true if the given point falls in this DisplayObject's visible shape More... | |
| virtual Movie * | get_root () const |
| Return the relative root of this DisplayObject. More... | |
| virtual MovieClip * | getAsRoot () |
| Return the _root ActionScript property of this DisplayObject. More... | |
| virtual as_object * | pathElement (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 const DisplayObject * | findDropTarget (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 | omit_display () |
| 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... | |
| 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 void | killFocus () |
| Some DisplayObjects require actions on losing focus. More... | |
| double | rotation () const |
| double | scaleX () const |
| double | scaleY () const |
| as_object * | object () const |
| virtual void | markReachableResources () const |
| Mark all reachable resources. 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... | |
Protected Member Functions | |
| virtual bool | unloadChildren () |
| Properly unload contained DisplayObjects. More... | |
| void | markOwnResources () const |
| Mark reachable resources (for the GC) More... | |
Protected Member Functions inherited from gnash::DisplayObject | |
| movie_root & | stage () const |
| Get the movie_root to which this DisplayObject belongs. More... | |
| void | saveOriginalTarget () |
| const Events & | get_event_handlers () const |
| void | set_event_handlers (const Events ©from) |
| as_object * | getPathElementSeparator (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... | |
Additional Inherited Members | |
Static Public Member Functions inherited from gnash::DisplayObject | |
| static as_value | blendMode (const fn_call &fn) |
| Getter-setter for blendMode. More... | |
Static Public Attributes inherited from gnash::DisplayObject | |
| 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 Attributes inherited from gnash::DisplayObject | |
| 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... | |
Button implements Flash buttons.
| typedef std::set<int> gnash::Button::ActiveRecords |
A container for holding the id of active button records.
| typedef std::vector<const DisplayObject*> gnash::Button::ConstDisplayObjects |
| typedef std::vector<DisplayObject*> gnash::Button::DisplayObjects |
| gnash::Button::Button | ( | as_object * | object, |
| const SWF::DefineButtonTag * | def, | ||
| DisplayObject * | parent | ||
| ) |
Construct a Button.
A button should always have an associated object.
| gnash::Button::~Button | ( | ) |
|
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.
Implements gnash::InteractiveObject.
References gnash::key::_1, gnash::geometry::SnappingRanges2d< T >::add(), gnash::DisplayObject::add_invalidated_bounds(), gnash::renderer::opengl::for_each(), gnash::DisplayObject::invalidated(), gnash::DisplayObject::m_old_invalidated_ranges, and gnash::DisplayObject::visible().
|
virtual |
Do ActionScript construction of the Button.
Construct all button state DisplayObjects.
| init | An init object, which can be passed when constructing Buttons with attachMovie, but is never used. |
Reimplemented from gnash::DisplayObject.
References _, gnash::DisplayObject::construct(), IF_VERBOSE_ASCODING_ERRORS, gnash::SWF::ButtonRecord::instantiate(), gnash::log_aserror(), MOUSESTATE_HIT, MOUSESTATE_UP, gnash::movie_root::registerButton(), gnash::DisplayObject::saveOriginalTarget(), and gnash::DisplayObject::stage().
|
virtual |
Properly destroy contained DisplayObjects.
Reimplemented from gnash::DisplayObject.
References gnash::DisplayObject::destroy(), gnash::movie_root::removeButton(), and gnash::DisplayObject::stage().
Render this Button.
Implements gnash::InteractiveObject.
References gnash::DisplayObject::clear_invalidated(), and gnash::DisplayObject::transform().
|
virtual |
Returns local, untransformed bounds of this DisplayObject in TWIPS.
Container DisplayObjects (sprite and buttons) return the composite bounds of all their children, appropriately transformed with their local SWFMatrix.
Implements gnash::InteractiveObject.
References gnash::key::e, gnash::SWFRect::expand_to_transformed_rect(), gnash::DisplayObject::getBounds(), gnash::getMatrix(), gnash::key::i, and gnash::key::m.
|
virtual |
Called when the Button is in focus.
Nothing to do, but can receive focus.
Reimplemented from gnash::DisplayObject.
| bool gnash::Button::isEnabled | ( | ) |
References gnash::as_object::get_member(), gnash::getObject(), gnash::getVM(), gnash::NSV::PROP_ENABLED, and gnash::toBool().
Referenced by gnash::registerButtonNative(), and topmostMouseEntity().
| void gnash::Button::keyPress | ( | key::code | c | ) |
Handle a key press associated with a button event.
References gnash::event_id::KEY_PRESS, gnash::DisplayObject::stage(), and gnash::DisplayObject::unloaded().
|
protectedvirtual |
Mark reachable resources (for the GC)
These are:
Reimplemented from gnash::DisplayObject.
References gnash::renderer::opengl::for_each(), and gnash::GcResource::setReachable().
|
inlinevirtual |
Whether the DisplayObject can handle a mouse event.
Implements gnash::InteractiveObject.
References gnash::key::c, x, and y.
|
virtual |
Called whenever a mouse event affects this Button.
Implements gnash::InteractiveObject.
References _, gnash::key::_1, gnash::event_id::DRAG_OUT, gnash::event_id::DRAG_OVER, gnash::key::e, gnash::SWF::SoundInfoRecord::envelopes, gnash::event_id::functionURI(), gnash::DisplayObject::get_depth(), gnash::DisplayObject::get_environment(), gnash::DisplayObject::get_event_handler(), gnash::getObject(), gnash::getRunResources(), gnash::DisplayObject::getTarget(), gnash::key::i, gnash::event_id::id(), gnash::SWF::SoundInfoRecord::inPoint, gnash::DisplayObject::isDestroyed(), gnash::log_error(), gnash::SWF::SoundInfoRecord::loopCount, gnash::sound_sample::m_sound_handler_id, gnash::event_id::MOUSE_DOWN, gnash::event_id::MOUSE_UP, MOUSESTATE_DOWN, MOUSESTATE_OVER, MOUSESTATE_UP, gnash::SWF::SoundInfoRecord::noMultiple, gnash::SWF::SoundInfoRecord::outPoint, gnash::event_id::PRESS, gnash::movie_root::PRIORITY_DOACTION, gnash::movie_root::pushAction(), gnash::event_id::RELEASE, gnash::event_id::RELEASE_OUTSIDE, gnash::event_id::ROLL_OUT, gnash::event_id::ROLL_OVER, gnash::key::s, gnash::SWF::DefineButtonSoundTag::ButtonSound::sample, gnash::sendEvent(), set_current_state(), gnash::RunResources::soundHandler(), gnash::SWF::DefineButtonSoundTag::ButtonSound::soundID, gnash::SWF::DefineButtonSoundTag::ButtonSound::soundInfo, gnash::DisplayObject::stage(), gnash::sound::sound_handler::startSound(), gnash::DisplayObject::staticDepthOffset, gnash::sound::sound_handler::stopEventSound(), gnash::SWF::SoundInfoRecord::stopPlayback, gnash::key::SWF, and gnash::DisplayObject::unloaded().
|
virtual |
Return true if the given point falls in this DisplayObject's shape.
Point coordinates are in world TWIPS
The default implementation warns about a missing override and invokes pointInBounds().
Reimplemented from gnash::InteractiveObject.
References gnash::key::e, gnash::key::i, and gnash::DisplayObject::pointInShape().
| void gnash::Button::set_current_state | ( | MouseState | new_state | ) |
References gnash::DisplayObject::construct(), gnash::DisplayObject::destroy(), gnash::key::e, gnash::DisplayObject::get_depth(), gnash::key::i, gnash::SWF::ButtonRecord::instantiate(), gnash::DisplayObject::isDestroyed(), gnash::log_debug(), gnash::DisplayObject::removedDepthOffset, gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::unload(), and gnash::DisplayObject::unloaded().
Referenced by mouseEvent().
|
virtual |
Return the topmost entity that the given point covers. NULL if none.
I.e. check against ourself.
Implements gnash::InteractiveObject.
References gnash::key::e, gnash::getMatrix(), gnash::getWorldMatrix(), gnash::key::i, isEnabled(), gnash::key::m, gnash::key::p, gnash::DisplayObject::parent(), gnash::DisplayObject::topmostMouseEntity(), gnash::SWFMatrix::transform(), gnash::DisplayObject::visible(), gnash::geometry::Point2d::x, and gnash::geometry::Point2d::y.
|
virtual |
ActionScript property of Buttons and MovieClips altering mouse handling.
Reimplemented from gnash::InteractiveObject.
References gnash::as_object::get_member(), gnash::getObject(), gnash::getURI(), gnash::getVM(), and gnash::toBool().
|
protectedvirtual |
Properly unload contained DisplayObjects.
Reimplemented from gnash::DisplayObject.
1.8.12