Gnash
0.8.10
|
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. | |
Public Member Functions | |
Button (as_object *object, const SWF::DefineButtonTag *def, DisplayObject *parent) | |
Construct a Button. | |
~Button () | |
bool | mouseEnabled () const |
Whether the DisplayObject can handle a mouse event. | |
virtual bool | trackAsMenu () |
ActionScript property of Buttons and MovieClips altering mouse handling. | |
void | keyPress (key::code c) |
Handle a key press associated with a button event. | |
virtual void | display (Renderer &renderer, const Transform &xform) |
Render this Button. | |
void | set_current_state (MouseState new_state) |
virtual InteractiveObject * | topmostMouseEntity (boost::int32_t x, boost::int32_t y) |
Return the topmost entity that the given point covers. NULL if none. | |
virtual void | mouseEvent (const event_id &event) |
Called whenever a mouse event affects this Button. | |
virtual bool | handleFocus () |
Called when the Button is in focus. | |
void | add_invalidated_bounds (InvalidatedRanges &ranges, bool force) |
Add the DisplayObject's invalidated bounds *to* the given ranges list. | |
virtual SWFRect | getBounds () const |
Returns local, untransformed bounds of this DisplayObject in TWIPS. | |
bool | pointInShape (boost::int32_t x, boost::int32_t y) const |
Return true if the given point falls in this DisplayObject's shape. | |
bool | isEnabled () |
void | destroy () |
Properly destroy contained DisplayObjects. | |
virtual void | construct (as_object *init=0) |
Do ActionScript construction of the Button. | |
Protected Member Functions | |
virtual bool | unloadChildren () |
Properly unload contained DisplayObjects. | |
void | markOwnResources () const |
Mark reachable resources (for the GC) |
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 | ||
) |
gnash::Button::~Button | ( | ) |
void gnash::Button::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.
Implements gnash::InteractiveObject.
References gnash::DisplayObject::visible(), gnash::geometry::SnappingRanges2d::add(), gnash::DisplayObject::m_old_invalidated_ranges, gnash::renderer::opengl::for_each(), gnash::DisplayObject::add_invalidated_bounds(), gnash::key::_1, and gnash::DisplayObject::invalidated().
void gnash::Button::construct | ( | as_object * | init = 0 | ) | [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 IF_VERBOSE_ASCODING_ERRORS, _, gnash::DisplayObject::saveOriginalTarget(), MOUSESTATE_HIT, gnash::key::e, gnash::key::i, gnash::key::SWF, gnash::SWF::ButtonRecord::instantiate(), MOUSESTATE_UP, gnash::DisplayObject::construct(), gnash::DisplayObject::stage(), and gnash::movie_root::registerButton().
void gnash::Button::destroy | ( | ) | [virtual] |
Properly destroy contained DisplayObjects.
Reimplemented from gnash::DisplayObject.
References gnash::DisplayObject::stage(), gnash::movie_root::removeButton(), gnash::key::e, gnash::key::i, gnash::DisplayObject::isDestroyed(), and gnash::DisplayObject::destroy().
Render this Button.
Implements gnash::InteractiveObject.
References gnash::DisplayObject::transform(), gnash::key::e, and gnash::DisplayObject::clear_invalidated().
SWFRect gnash::Button::getBounds | ( | ) | const [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::key::i, gnash::DisplayObject::getBounds(), gnash::key::m, gnash::getMatrix(), and gnash::SWFRect::expand_to_transformed_rect().
bool gnash::Button::handleFocus | ( | ) | [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::getObject(), assert, gnash::as_object::get_member(), gnash::NSV::PROP_ENABLED, gnash::toBool(), and gnash::getVM().
Referenced by topmostMouseEntity().
void gnash::Button::keyPress | ( | key::code | c | ) |
Handle a key press associated with a button event.
References gnash::DisplayObject::unloaded(), gnash::DisplayObject::stage(), and gnash::event_id::KEY_PRESS.
void gnash::Button::markOwnResources | ( | ) | const [protected, virtual] |
Mark reachable resources (for the GC)
These are:
Reimplemented from gnash::DisplayObject.
References gnash::key::e, gnash::key::i, gnash::GcResource::setReachable(), and gnash::renderer::opengl::for_each().
bool gnash::Button::mouseEnabled | ( | ) | const [inline, virtual] |
Whether the DisplayObject can handle a mouse event.
Implements gnash::InteractiveObject.
void gnash::Button::mouseEvent | ( | const event_id & | event | ) | [virtual] |
Called whenever a mouse event affects this Button.
Implements gnash::InteractiveObject.
References gnash::DisplayObject::unloaded(), gnash::event_id::id(), MOUSESTATE_UP, MOUSESTATE_OVER, MOUSESTATE_DOWN, _, set_current_state(), gnash::key::s, gnash::getRunResources(), gnash::getObject(), gnash::RunResources::soundHandler(), gnash::key::SWF, gnash::SWF::DefineButtonSoundTag::ButtonSound::soundID, gnash::SWF::DefineButtonSoundTag::ButtonSound::sample, gnash::SWF::DefineButtonSoundTag::ButtonSound::soundInfo, gnash::sound::sound_handler::stopEventSound(), gnash::sound_sample::m_sound_handler_id, gnash::SWF::SoundInfoRecord::envelopes, gnash::sound::sound_handler::startSound(), gnash::SWF::SoundInfoRecord::noMultiple, gnash::SWF::SoundInfoRecord::inPoint, gnash::SWF::SoundInfoRecord::outPoint, gnash::DisplayObject::stage(), gnash::DisplayObject::get_event_handler(), gnash::movie_root::pushAction(), gnash::movie_root::PRIORITY_DOACTION, gnash::sendEvent(), gnash::DisplayObject::get_environment(), and gnash::event_id::functionURI().
bool gnash::Button::pointInShape | ( | boost::int32_t | x, |
boost::int32_t | y | ||
) | const [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::key::e, gnash::key::i, gnash::DisplayObject::unloaded(), gnash::DisplayObject::isDestroyed(), gnash::DisplayObject::destroy(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::unload(), gnash::DisplayObject::get_depth(), gnash::DisplayObject::removedDepthOffset, gnash::DisplayObject::set_depth(), gnash::key::SWF, gnash::SWF::ButtonRecord::instantiate(), and gnash::DisplayObject::construct().
Referenced by mouseEvent().
InteractiveObject * gnash::Button::topmostMouseEntity | ( | boost::int32_t | x, |
boost::int32_t | y | ||
) | [virtual] |
Return the topmost entity that the given point covers. NULL if none.
I.e. check against ourself.
Implements gnash::InteractiveObject.
References gnash::DisplayObject::visible(), isEnabled(), gnash::key::m, gnash::getMatrix(), gnash::key::p, gnash::DisplayObject::topmostMouseEntity(), gnash::geometry::Point2d::x, gnash::geometry::Point2d::y, gnash::DisplayObject::parent(), gnash::getWorldMatrix(), gnash::SWFMatrix::transform(), gnash::key::i, and gnash::key::e.
bool gnash::Button::trackAsMenu | ( | ) | [virtual] |
ActionScript property of Buttons and MovieClips altering mouse handling.
Reimplemented from gnash::InteractiveObject.
References gnash::getObject(), assert, gnash::getVM(), gnash::getURI(), gnash::as_object::get_member(), and gnash::toBool().
bool gnash::Button::unloadChildren | ( | ) | [protected, virtual] |
Properly unload contained DisplayObjects.
Reimplemented from gnash::DisplayObject.
References gnash::key::e, gnash::key::i, gnash::DisplayObject::unloaded(), and gnash::DisplayObject::unload().