Gnash 0.8.10dev
|
#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 | notifyEvent (const event_id &id) |
Notify clip events (and also user-defined ones). | |
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) |
virtual bool | handleFocus () |
Set the current focus to this DisplayObject. | |
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. | |
Static Public Member Functions | |
static const char * | mouseStateName (MouseState s) |
Protected Member Functions | |
virtual bool | unloadChildren () |
Properly unload contained DisplayObjects. | |
void | markOwnResources () const |
Mark reachable resources (for the GC) |
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.
References gnash::movie_root::add_key_listener(), assert, and gnash::DisplayObject::stage().
gnash::Button::~Button | ( | ) |
References gnash::movie_root::remove_key_listener(), and gnash::DisplayObject::stage().
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::key::_1, gnash::geometry::SnappingRanges2d< T >::add(), gnash::DisplayObject::add_invalidated_bounds(), gnash::for_each(), gnash::DisplayObject::invalidated(), gnash::DisplayObject::m_old_invalidated_ranges, and gnash::DisplayObject::visible().
void gnash::Button::construct | ( | as_object * | init = 0 | ) | [virtual] |
Do ActionScript construction of the Button.
(1) Register this button instance as a live DisplayObject (2) 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(), gnash::key::e, gnash::key::i, IF_VERBOSE_ASCODING_ERRORS, gnash::SWF::ButtonRecord::instantiate(), MOUSESTATE_HIT, MOUSESTATE_UP, and gnash::DisplayObject::saveOriginalTarget().
void gnash::Button::destroy | ( | ) | [virtual] |
Properly destroy contained DisplayObjects.
Reimplemented from gnash::DisplayObject.
References gnash::DisplayObject::destroy(), gnash::key::e, gnash::key::i, and gnash::DisplayObject::isDestroyed().
Render this Button.
Implements gnash::InteractiveObject.
References gnash::DisplayObject::clear_invalidated(), gnash::key::e, and gnash::DisplayObject::transform().
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::SWFRect::expand_to_transformed_rect(), gnash::DisplayObject::getBounds(), gnash::getMatrix(), gnash::key::i, and gnash::key::m.
bool gnash::Button::handleFocus | ( | ) | [virtual] |
Set the current focus to this DisplayObject.
Nothing to do, but can receive focus.
Reimplemented from gnash::DisplayObject.
bool gnash::Button::isEnabled | ( | ) |
References assert, gnash::as_object::get_member(), gnash::getObject(), gnash::getVM(), gnash::NSV::PROP_ENABLED, and gnash::toBool().
Referenced by topmostMouseEntity().
void gnash::Button::markOwnResources | ( | ) | const [protected, virtual] |
Mark reachable resources (for the GC)
These are:
Reimplemented from gnash::DisplayObject.
References gnash::key::e, gnash::for_each(), gnash::key::i, and gnash::GcResource::setReachable().
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] |
Reimplemented from gnash::InteractiveObject.
References _, gnash::event_id::DRAG_OUT, gnash::event_id::DRAG_OVER, gnash::SWF::SoundInfoRecord::envelopes, gnash::event_id::functionURI(), gnash::DisplayObject::get_environment(), gnash::DisplayObject::get_event_handler(), gnash::getObject(), gnash::getRunResources(), gnash::DisplayObject::getTarget(), gnash::event_id::id(), gnash::SWF::SoundInfoRecord::inPoint, 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, 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::sound::sound_handler::stop_sound(), and gnash::DisplayObject::unloaded().
const char * gnash::Button::mouseStateName | ( | MouseState | s | ) | [static] |
References MOUSESTATE_DOWN, MOUSESTATE_HIT, MOUSESTATE_OVER, and MOUSESTATE_UP.
void gnash::Button::notifyEvent | ( | const event_id & | ) | [virtual] |
Notify clip events (and also user-defined ones).
Reimplemented from gnash::DisplayObject.
References gnash::key::INVALID, gnash::event_id::KEY_PRESS, gnash::DisplayObject::stage(), and gnash::DisplayObject::unloaded().
Referenced by gnash::movie_root::keyEvent().
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::DisplayObject::construct(), gnash::DisplayObject::destroy(), gnash::key::e, gnash::DisplayObject::get_depth(), gnash::key::i, gnash::SWF::ButtonRecord::instantiate(), gnash::DisplayObject::isDestroyed(), gnash::DisplayObject::removedDepthOffset, gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::unload(), and gnash::DisplayObject::unloaded().
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::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.
bool gnash::Button::trackAsMenu | ( | ) | [virtual] |
ActionScript property of Buttons and MovieClips altering mouse handling.
Reimplemented from gnash::InteractiveObject.
References assert, gnash::as_object::get_member(), gnash::getObject(), gnash::getURI(), gnash::getVM(), 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::unload(), and gnash::DisplayObject::unloaded().