[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gui.cpp gui/gui...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gui.cpp gui/gui... |
Date: |
Mon, 02 Apr 2007 15:45:23 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/04/02 15:45:22
Modified files:
. : ChangeLog
gui : gtk.cpp gui.cpp gui.h
server : character.cpp character.h gnash.h
movie_root.cpp movie_root.h sprite_instance.cpp
sprite_instance.h
server/asobj : Key.cpp
server/vm : ExecutableCode.h
testsuite : MovieTester.cpp
Log message:
* server/vm/ExecutableCode.h: change FunctionCode to take
a generic character as target, not necessarely a sprite.
* server/movie_root.{cpp,h}: update pushAction() for events
to take a generic character, add a notify_key_event method
for consistency.
* server/asobj/Key.cpp: notify_key_event moved to movie_root.
* server/gnash.h: remove notify_key_event prototype, it's now
a movie_root method.
* gui/gtk.cpp: use gui::notify_key_event for key events.
* gui/gui.{cpp,h}: add notify_key_event method.
* server/character.{cpp,h}: move queueActionHandler from
sprite_instance here.
* server/sprite_instance.{cpp,h}: cleanups.
* testsuite/MovieTester.cpp: update call to notify_key_event.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2749&r2=1.2750
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.79&r2=1.80
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.h?cvsroot=gnash&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.60&r2=1.61
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.88&r2=1.89
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.216&r2=1.217
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.85&r2=1.86
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.cpp?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ExecutableCode.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.cpp?cvsroot=gnash&r1=1.23&r2=1.24
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2749
retrieving revision 1.2750
diff -u -b -r1.2749 -r1.2750
--- ChangeLog 2 Apr 2007 10:47:36 -0000 1.2749
+++ ChangeLog 2 Apr 2007 15:45:22 -0000 1.2750
@@ -1,5 +1,22 @@
2007-04-02 Sandro Santilli <address@hidden>
+ * server/vm/ExecutableCode.h: change FunctionCode to take
+ a generic character as target, not necessarely a sprite.
+ * server/movie_root.{cpp,h}: update pushAction() for events
+ to take a generic character, add a notify_key_event method
+ for consistency.
+ * server/asobj/Key.cpp: notify_key_event moved to movie_root.
+ * server/gnash.h: remove notify_key_event prototype, it's now
+ a movie_root method.
+ * gui/gtk.cpp: use gui::notify_key_event for key events.
+ * gui/gui.{cpp,h}: add notify_key_event method.
+ * server/character.{cpp,h}: move queueActionHandler from
+ sprite_instance here.
+ * server/sprite_instance.{cpp,h}: cleanups.
+ * testsuite/MovieTester.cpp: update call to notify_key_event.
+
+2007-04-02 Sandro Santilli <address@hidden>
+
* testsuite/samples/: Makefile.am, gotoFrameOnKeyEvent-TestRunner.cpp:
First stub at an automated test runner for gotoFrameOnKeyEvent.
TODO item in comments.
Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- gui/gtk.cpp 29 Mar 2007 23:55:49 -0000 1.79
+++ gui/gtk.cpp 2 Apr 2007 15:45:22 -0000 1.80
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: gtk.cpp,v 1.79 2007/03/29 23:55:49 rsavoye Exp $ */
+/* $Id: gtk.cpp,v 1.80 2007/04/02 15:45:22 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1171,7 +1171,7 @@
gnash::key::code c = gdk_to_gnash_key(event->keyval);
if (c != gnash::key::INVALID) {
- gnash::notify_key_event(c, true);
+ gui->notify_key_event(c, true);
}
/* Handle GUI shortcuts */
@@ -1224,15 +1224,17 @@
gboolean
GtkGui::key_release_event(GtkWidget *const /*widget*/,
GdkEventKey *const event,
- const gpointer /*data*/)
+ const gpointer data)
{
GNASH_REPORT_FUNCTION;
+ Gui* gui = static_cast<Gui*>(data);
+
/* Forward key event to gnash */
gnash::key::code c = gdk_to_gnash_key(event->keyval);
if (c != gnash::key::INVALID) {
- gnash::notify_key_event(c, false);
+ gui->notify_key_event(c, false);
}
return true;
Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- gui/gui.cpp 7 Mar 2007 23:52:13 -0000 1.67
+++ gui/gui.cpp 2 Apr 2007 15:45:22 -0000 1.68
@@ -276,6 +276,20 @@
}
}
+void
+Gui::notify_key_event(gnash::key::code k, bool pressed)
+{
+ movie_root* m = get_current_root();
+
+ //log_msg("mouse @ %d,%d", x, y);
+ if ( m->notify_key_event(k, pressed) )
+ {
+ // any action triggered by the
+ // event required screen refresh
+ display(m);
+ }
+}
+
bool
Gui::display(movie_root* m)
{
Index: gui/gui.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- gui/gui.h 7 Mar 2007 23:52:13 -0000 1.46
+++ gui/gui.h 2 Apr 2007 15:45:22 -0000 1.47
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
#include "tu_config.h"
#include "rect.h" // for composition
#include "snappingrange.h" // for InvalidatedRanges
+#include "gnash.h" // for gnash::key::code type
#include <string>
@@ -167,6 +168,7 @@
//
/// @param x The mouse coordinate X component in pixels.
/// @param y The mouse coordinate Y component in pixels.
+ ///
void notify_mouse_moved(int x, int y);
/// Mouse notification callback to be called when the mouse is clicked.
@@ -174,8 +176,18 @@
/// @param mouse_pressed Determines whether the mouse button is being
/// pressed (true) or being released (false)
/// @param mask A binary representation of the buttons currently pressed.
+ ///
void notify_mouse_clicked(bool mouse_pressed, int mask);
+ /// Key event notification to be called when a key is pressed or depressed
+ //
+ /// @param k The key code.
+ ///
+ /// @param pressed Determines whether the key is being
+ /// pressed (true) or being released (false)
+ ///
+ void notify_key_event(gnash::key::code k, bool pressed);
+
/// Resize the client area view and the window accordingly.
//
/// @param width The desired width in pixels.
Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- server/character.cpp 22 Mar 2007 16:56:36 -0000 1.27
+++ server/character.cpp 2 Apr 2007 15:45:22 -0000 1.28
@@ -18,7 +18,7 @@
//
//
-/* $Id: character.cpp,v 1.27 2007/03/22 16:56:36 bjacques Exp $ */
+/* $Id: character.cpp,v 1.28 2007/04/02 15:45:22 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -31,6 +31,8 @@
#include "fn_call.h" // for shared ActionScript getter-setters
#include "GnashException.h" // for shared ActionScript getter-setters
(ensure_character)
+#include <boost/algorithm/string/case_conv.hpp>
+
namespace gnash
{
@@ -746,6 +748,66 @@
// mouse or keypress events.
}
+void
+character::unload()
+{
+ _unloaded = true;
+ log_msg("Queuing unload event for character %p", this);
+ queueEventHandler(event_id::UNLOAD);
+ //on_event(event_id::UNLOAD);
+}
+
+void
+character::queueEventHandler(const event_id& id)
+{
+ //testInvariant();
+
+ bool called=false;
+
+ movie_root& root = VM::get().getRoot();
+
+ // First, check for built-in event handler.
+ boost::intrusive_ptr<as_function> method =
get_event_handler(id).to_as_function();
+
+ if (method)
+ {
+ root.pushAction(method, boost::intrusive_ptr<character>(this));
+ called=true;
+ }
+
+ // This is likely wrong, we use it as a workaround
+ // to the fact that we don't distinguish between
+ // ActionScript and SWF defined events
+ // (for example: onClipLoad vs. onLoad)
+ //
+ if (called) return;
+
+ // Check for member function.
+ // In ActionScript 2.0, event method names are CASE SENSITIVE.
+ // In ActionScript 1.0, event method names are CASE INSENSITIVE.
+ // TODO: move to get_function_name directly ?
+ std::string method_name = id.get_function_name();
+ if ( _vm.getSWFVersion() < 7 )
+ {
+ boost::to_lower(method_name, _vm.getLocale());
+ }
+
+ if (method_name.length() > 0)
+ {
+ as_value method_val;
+ if ( get_member(method_name, &method_val) )
+ {
+ method = method_val.to_as_function();
+ if ( method )
+ {
+ root.pushAction(method,
boost::intrusive_ptr<character>(this));
+ }
+ }
+ }
+
+ //testInvariant();
+
+}
} // namespace gnash
Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- server/character.h 2 Apr 2007 09:12:48 -0000 1.60
+++ server/character.h 2 Apr 2007 15:45:22 -0000 1.61
@@ -18,7 +18,7 @@
//
//
-/* $Id: character.h,v 1.60 2007/04/02 09:12:48 strk Exp $ */
+/* $Id: character.h,v 1.61 2007/04/02 15:45:22 strk Exp $ */
#ifndef GNASH_CHARACTER_H
#define GNASH_CHARACTER_H
@@ -555,6 +555,9 @@
return false;
}
+ /// Queue event handler(s), if any.
+ void queueEventHandler(const event_id& id);
+
virtual void on_button_event(const event_id& id)
{
on_event(id);
@@ -647,14 +650,10 @@
/// This function must be called when the character is removed
/// from the stage.
/// stage for the first time. It will take care of properly
- /// unloading any child characters and calling the 'UNLOAD'
+ /// unloading any child characters and queuing the 'UNLOAD'
/// event handler.
///
- virtual void unload()
- {
- _unloaded = true;
- on_event(event_id::UNLOAD);
- }
+ virtual void unload();
bool isUnloaded() { return _unloaded; }
};
Index: server/gnash.h
===================================================================
RCS file: /sources/gnash/gnash/server/gnash.h,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -b -r1.88 -r1.89
--- server/gnash.h 1 Mar 2007 11:06:32 -0000 1.88
+++ server/gnash.h 2 Apr 2007 15:45:22 -0000 1.89
@@ -17,7 +17,7 @@
//
//
-/* $Id: gnash.h,v 1.88 2007/03/01 11:06:32 udog Exp $ */
+/* $Id: gnash.h,v 1.89 2007/04/02 15:45:22 strk Exp $ */
/// \mainpage
///
@@ -588,12 +588,6 @@
};
} // end namespace key
-/// Key events are global throughout gnash.
-/// @@ Maybe someday make these local to the movie_root ?
-/// See \ref events_handling for more info
-DSOEXPORT void notify_key_event(key::code k, bool down);
-
-
/// Some optional helpers.
namespace tools
{
Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- server/movie_root.cpp 2 Apr 2007 09:38:16 -0000 1.50
+++ server/movie_root.cpp 2 Apr 2007 15:45:22 -0000 1.51
@@ -33,12 +33,14 @@
#include "tu_random.h"
#include "ExecutableCode.h"
#include "Stage.h"
+#include "Key.h"
#include <iostream>
#include <string>
#include <typeinfo>
#include <cassert>
#include <boost/ptr_container/ptr_list.hpp>
+#include <boost/algorithm/string/case_conv.hpp>
using namespace std;
@@ -158,6 +160,70 @@
}
+void
+movie_root::notify_global_key(key::code k, bool down)
+{
+ VM& vm = VM::get();
+ if ( vm.getSWFVersion() < 6 )
+ {
+ // _global.Key was added in SWF6
+ return;
+ }
+
+ static boost::intrusive_ptr<key_as_object> keyobject = NULL;
+ if ( ! keyobject )
+ {
+ // This isn't very performant... do we allow user override
+ // of _global.Key, btw ?
+
+ as_value kval;
+ as_object* global = VM::get().getGlobal();
+
+ std::string objName = "Key";
+ if ( vm.getSWFVersion() < 7 )
+ {
+ boost::to_lower(objName, vm.getLocale());
+ }
+ if ( global->get_member(objName, &kval) )
+ {
+ //log_msg("Found member 'Key' in _global: %s",
kval.to_string());
+ boost::intrusive_ptr<as_object> obj = kval.to_object();
+ //log_msg("_global.Key to_object() : %s @ %p",
typeid(*obj).name(), obj);
+ keyobject = boost::dynamic_pointer_cast<key_as_object>(
obj );
+ }
+ }
+
+ if ( keyobject )
+ {
+ if (down) keyobject->set_key_down(k);
+ else keyobject->set_key_up(k);
+ }
+ else
+ {
+ log_error("gnash::notify_key_event(): _global.Key doesn't
exist, or isn't the expected built-in\n");
+ }
+}
+
+bool
+movie_root::notify_key_event(key::code k, bool down)
+{
+// GNASH_REPORT_FUNCTION;
+
+ // Notify keypress listeners.
+ if (down) notify_keypress_listeners(k);
+
+ //
+ // Notify the _global.Key object about key event
+ //
+
+ notify_global_key(k, down);
+
+ processActionQueue();
+
+ return false; // should return true if needs update ...
+}
+
+
bool
movie_root::notify_mouse_clicked(bool mouse_pressed, int button_mask)
{
@@ -583,6 +649,11 @@
void movie_root::cleanup_keypress_listeners()
{
+#ifdef KEYPRESS_LISTENERS_DEBUG
+ size_t prevsize = m_keypress_listeners.size();
+ log_msg("Cleaning up %u keypress listeners",
m_keypress_listeners.size());
+#endif
+
for (ListenerSet::iterator iter = m_keypress_listeners.begin();
iter != m_keypress_listeners.end(); )
{
@@ -600,6 +671,11 @@
++iter;
}
}
+
+#ifdef KEYPRESS_LISTENERS_DEBUG
+ size_t currsize = m_keypress_listeners.size();
+ log_msg("Cleaned up %u listeners (from %u to %u)", prevsize-currsize,
prevsize, currsize);
+#endif
}
void movie_root::notify_keypress_listeners(key::code k)
@@ -747,7 +823,7 @@
}
void
-movie_root::pushAction(boost::intrusive_ptr<as_function> func,
boost::intrusive_ptr<sprite_instance> target)
+movie_root::pushAction(boost::intrusive_ptr<as_function> func,
boost::intrusive_ptr<character> target)
{
#ifdef GNASH_DEBUG
log_msg("Pushed function (event hanlder?) with target %s",
target->getTargetPath().c_str());
Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/movie_root.h 2 Apr 2007 09:12:48 -0000 1.43
+++ server/movie_root.h 2 Apr 2007 15:45:22 -0000 1.44
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: movie_root.h,v 1.43 2007/04/02 09:12:48 strk Exp $ */
+/* $Id: movie_root.h,v 1.44 2007/04/02 15:45:22 strk Exp $ */
/// \page events_handling Handling of user events
///
@@ -57,10 +57,8 @@
///
/// - bool movie_root::notify_mouse_moved(int x, int y);
/// - bool movie_root::notify_mouse_clicked(bool mouse_pressed, int mask);
+/// - bool movie_root::notify_key_event(key::code k, bool down);
///
-/// Note that the notify_key_event() method is a global function, which should
-/// likely be moved somewhere else, and that has not been fixed yet to support
-/// the new interface.
///
@@ -204,6 +202,16 @@
void notify_mouse_state(int x, int y, int buttons);
/// \brief
+ /// The host app can use this to tell the movie when
+ /// user pressed or released a key.
+ //
+ /// This function should return TRUE iff any action triggered
+ /// by the event requires redraw, see \ref events_handling for
+ /// more info.
+ ///
+ bool notify_key_event(key::code k, bool down);
+
+ /// \brief
/// Use this to retrieve the last state of the mouse, as set via
/// notify_mouse_state().
//
@@ -409,10 +417,13 @@
void pushAction(const action_buffer& buf,
boost::intrusive_ptr<sprite_instance> target);
/// Push a function code to the ActionQueue
- void pushAction(boost::intrusive_ptr<as_function> func,
boost::intrusive_ptr<sprite_instance> target);
+ void pushAction(boost::intrusive_ptr<as_function> func,
boost::intrusive_ptr<character> target);
private:
+ /// Notify the global Key ActionScript object about a key status change
+ void notify_global_key(key::code k, bool down);
+
/// Remove all listeners with a ref-count of 1
/// (only referenced as key listeners)
void cleanup_keypress_listeners();
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -b -r1.216 -r1.217
--- server/sprite_instance.cpp 2 Apr 2007 09:12:48 -0000 1.216
+++ server/sprite_instance.cpp 2 Apr 2007 15:45:22 -0000 1.217
@@ -69,16 +69,6 @@
namespace gnash {
-// Define OLD_GET_MEMBER to thread "default" members within the get_member
-// override rather then by using the new 'init_property' call.
-// This will likely be removed soon, just here to track possible bugs
introduced
-// by this change. In particular, the place_and_remove_instane_test is failing
-// for '_x' property, but attachMovieTest is succeeding with the *new* layout
-// and failign with the previous.
-//
-//#define OLD_GET_MEMBER
-//
-
//#define GNASH_DEBUG 1
// Forward declarations
@@ -1061,8 +1051,6 @@
return as_value(clip.get());
}
-#ifndef OLD_GET_MEMBER
-
static as_value
sprite_currentframe_get(const fn_call& fn)
@@ -1225,8 +1213,6 @@
return as_value();
}
-#endif // ndef OLD_GET_MEMBER
-
/// Properties (and/or methods) *inherited* by MovieClip instances
static void
attachMovieClipInterface(as_object& o)
@@ -1643,240 +1629,6 @@
return true;
}
-#ifdef OLD_GET_MEMBER
- // FIXME: use addProperty interface for these !!
- as_standard_member std_member = get_standard_member(name);
- switch (std_member)
- {
- default:
- case M_INVALID_MEMBER:
- break;
- case M_X:
- //if (name == "_x")
- {
- matrix m = get_matrix();
- val->set_double(TWIPS_TO_PIXELS(m.m_[0][2]));
- return true;
- }
- case M_Y:
- //else if (name == "_y")
- {
- matrix m = get_matrix();
- val->set_double(TWIPS_TO_PIXELS(m.m_[1][2]));
- return true;
- }
- case M_XSCALE:
- //else if (name == "_xscale")
- {
- matrix m = get_matrix(); // @@ or get_world_matrix()? Test this.
- float xscale = m.get_x_scale();
- val->set_double(xscale * 100); // result in percent
- return true;
- }
- case M_YSCALE:
- //else if (name == "_yscale")
- {
- matrix m = get_matrix(); // @@ or get_world_matrix()? Test this.
- float yscale = m.get_y_scale();
- val->set_double(yscale * 100); // result in percent
- return true;
- }
- case M_CURRENTFRAME:
- //else if (name == "_currentframe")
- {
- val->set_int(m_current_frame + 1);
- return true;
- }
- case M_TOTALFRAMES:
- //else if (name == "_totalframes")
- {
- // number of frames. Read only.
- val->set_int(m_def->get_frame_count());
- return true;
- }
- case M_ALPHA:
- //else if (name == "_alpha")
- {
- // Alpha units are in percent.
- val->set_double(get_cxform().m_[3][0] * 100.f);
- return true;
- }
- case M_VISIBLE:
- //else if (name == "_visible")
- {
- val->set_bool(get_visible());
- return true;
- }
- case M_WIDTH: // _width
- {
- // Verified using samples/test_rotation.swf
- val->set_double(TWIPS_TO_PIXELS(get_width()));
- return true;
- }
- case M_HEIGHT: // _height
- {
- // Verified using samples/test_rotation.swf
- val->set_double(TWIPS_TO_PIXELS(get_height()));
- return true;
- }
- case M_ROTATION:
- //else if (name == "_rotation")
- {
- // Verified against Macromedia player using
samples/test_rotation.swf
- float angle = get_matrix().get_rotation();
-
- // Result is CLOCKWISE DEGREES, [-180,180]
- angle *= 180.0f / float(M_PI);
-
- val->set_double(angle);
- return true;
- }
- case M_PARENT:
- {
- if (m_parent==NULL)
- // _parent is undefined for root movies
- {
- return false;
- }
- else
- {
- assert(dynamic_cast<as_object*>(get_parent()));
-
val->set_as_object(static_cast<as_object*>(get_parent()));
- return true;
- }
- }
- case M_FRAMESLOADED:
- //else if (name == "_framesloaded")
- {
- val->set_int(m_def->get_loading_frame());
- return true;
- }
-
- case M_XMOUSE:
- //else if (name == "_xmouse")
- {
- // Local coord of mouse IN PIXELS.
- int x, y, buttons;
- _vm.getRoot().get_mouse_state(x, y, buttons);
-
- matrix m = get_world_matrix();
-
- point a(PIXELS_TO_TWIPS(x), PIXELS_TO_TWIPS(y));
- point b;
-
- m.transform_by_inverse(&b, a);
-
- val->set_double(TWIPS_TO_PIXELS(b.m_x));
- return true;
- }
-
- case M_YMOUSE:
- //else if (name == "_ymouse")
- {
- // Local coord of mouse IN PIXELS.
- int x, y, buttons;
- _vm.getRoot().get_mouse_state(x, y, buttons);
-
- matrix m = get_world_matrix();
-
- point a(PIXELS_TO_TWIPS(x), PIXELS_TO_TWIPS(y));
- point b;
-
- m.transform_by_inverse(&b, a);
-
- val->set_double(TWIPS_TO_PIXELS(b.m_y));
- return true;
- }
- /// FIXME: use a contextual 'target' member
- case M_TARGET:
- //else if (name == "_target")
- {
- // Full path to this object; e.g.
"/_level0/sprite1/sprite2/ourSprite"
- val->set_string(getTargetPath().c_str());
- return true;
- }
- case M_NAME:
- //else if (name == "_name")
- {
- if ( _vm.getSWFVersion() < 6 && get_name().empty() )
- val->set_undefined();
- else
- val->set_string(get_name().c_str());
-
- return true;
- }
-
- case M_DROPTARGET:
- //else if (name == "_droptarget")
- {
- // Absolute path in slash syntax where we were last dropped (?)
- // @@ TODO
- static bool warned = false;
- if ( ! warned ) {
- log_error("FIXME: MovieClip._droptarget unimplemented");
- warned=true;
- }
-
- if ( _vm.getSWFVersion() > 5 )
- val->set_string("");
- else
- val->set_undefined();
- return true;
- }
- case M_URL:
- //else if (name == "_url")
- {
- // A sprite's url is the url this
- // sprite has been "downloaded" from.
- // If this is an ActionScript-created sprite
- // we might use the actions creating
- // it as defining where was it "downloaded" from.
- //
- val->set_string(m_def->get_url().c_str());
- return true;
- }
- case M_ONROLLOVER:
- {
- return get_event_handler(event_id::ROLL_OVER, val);
- }
- case M_ONROLLOUT:
- {
- return get_event_handler(event_id::ROLL_OUT, val);
- }
- case M_HIGHQUALITY:
- //else if (name == "_highquality")
- {
- // Whether we're in high quality mode or not.
- val->set_bool(true);
- return true;
- }
- case M_FOCUSRECT:
- //else if (name == "_focusrect")
- {
- // Is a yellow rectangle visible around a focused movie clip (?)
- val->set_bool(false);
- return true;
- }
- case M_SOUNDBUFTIME:
- //else if (name == "_soundbuftime")
- {
- // Number of seconds before sound starts to stream.
- val->set_double(0.0);
- return true;
- }
- case M_ONLOAD:
- {
- if (m_as_environment.get_member(std::string(name.c_str()), val))
- {
- return true;
- }
- // Optimization: if no hit, don't bother looking in the display
list, etc.
- return false;
- }
-
- } // end switch
-#endif // def OLD_GET_MEMBER
-
// Try variables.
if ( m_as_environment.get_member(name, val) )
{
@@ -2140,58 +1892,6 @@
}
}
-void
-sprite_instance::queueEventHandler(const event_id& id)
-{
- testInvariant();
-
- bool called=false;
-
- movie_root& root = VM::get().getRoot();
-
- // First, check for built-in event handler.
- boost::intrusive_ptr<as_function> method =
get_event_handler(id).to_as_function();
-
- if (method)
- {
- root.pushAction(method,
boost::intrusive_ptr<sprite_instance>(this));
- called=true;
- }
-
- // This is likely wrong, we use it as a workaround
- // to the fact that we don't distinguish between
- // ActionScript and SWF defined events
- // (for example: onClipLoad vs. onLoad)
- //
- if (called) return;
-
- // Check for member function.
- // In ActionScript 2.0, event method names are CASE SENSITIVE.
- // In ActionScript 1.0, event method names are CASE INSENSITIVE.
- // TODO: move to get_function_name directly ?
- std::string method_name = id.get_function_name();
- if ( _vm.getSWFVersion() < 7 )
- {
- boost::to_lower(method_name, _vm.getLocale());
- }
-
- if (method_name.length() > 0)
- {
- as_value method_val;
- if ( get_member(method_name, &method_val) )
- {
- method = method_val.to_as_function();
- if ( method )
- {
- root.pushAction(method,
boost::intrusive_ptr<sprite_instance>(this));
- }
- }
- }
-
- testInvariant();
-
-}
-
/* private */
void
sprite_instance::queueActions(ActionList& actions)
@@ -2281,244 +1981,9 @@
const as_value& val)
{
#ifdef DEBUG_DYNTEXT_VARIABLES
-log_msg("sprite[%p]::set_member(%s, %s)", (void*)this, name.c_str(),
val.to_string());
+ log_msg("sprite[%p]::set_member(%s, %s)", (void*)this, name.c_str(),
val.to_string());
#endif
-#ifdef OLD_GET_MEMBER
- as_standard_member std_member = get_standard_member(name);
- switch (std_member)
- {
- default:
- case M_INVALID_MEMBER:
- break;
- case M_X:
- //if (name == "_x")
- {
- matrix m = get_matrix();
- m.m_[0][2] =
infinite_to_fzero(PIXELS_TO_TWIPS(val.to_number()));
- set_matrix(m);
-
- transformedByScript(); // m_accept_anim_moves = false;
-
- return;
- }
- case M_Y:
- //else if (name == "_y")
- {
- matrix m = get_matrix();
- m.m_[1][2] =
infinite_to_fzero(PIXELS_TO_TWIPS(val.to_number()));
- set_matrix(m);
-
- transformedByScript(); // m_accept_anim_moves = false;
-
- return;
- }
- case M_XSCALE:
- //else if (name == "_xscale")
- {
- matrix m = get_matrix();
-
- double scale_percent = val.to_number();
-
- // Handle bogus values
- if (isnan(scale_percent))
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror("Attempt to set _xscale to %g, refused",
- scale_percent);
- );
- return;
- }
- else if (scale_percent < 0 )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror("Attempt to set _xscale to %g, use 0",
- scale_percent);
- );
- scale_percent = 0;
- }
-
- // input is in percent
- float scale = (float)scale_percent/100.f;
-
- // Decompose matrix and insert the desired value.
- float x_scale = scale;
- float y_scale = m.get_y_scale();
- float rotation = m.get_rotation();
- m.set_scale_rotation(x_scale, y_scale, rotation);
-
- set_matrix(m);
- transformedByScript(); // m_accept_anim_moves = false;
- return;
- }
- case M_YSCALE:
- //else if (name == "_yscale")
- {
- matrix m = get_matrix();
-
- double scale_percent = val.to_number();
-
- // Handle bogus values
- if (isnan(scale_percent))
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror("Attempt to set _yscale to %g, refused",
- scale_percent);
- );
- return;
- }
- else if (scale_percent < 0 )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror("Attempt to set _yscale to %g, use 0",
- scale_percent);
- );
- scale_percent = 0;
- }
-
- // input is in percent
- float scale = (float)scale_percent/100.f;
-
- // Decompose matrix and insert the desired value.
- float x_scale = m.get_x_scale();
- float y_scale = scale;
- float rotation = m.get_rotation();
- m.set_scale_rotation(x_scale, y_scale, rotation);
-
- set_matrix(m);
- transformedByScript(); // m_accept_anim_moves = false;
- return;
- }
- case M_ALPHA:
- //else if (name == "_alpha")
- {
- // Set alpha modulate, in percent.
- cxform cx = get_cxform();
- cx.m_[3][0] = infinite_to_fzero(val.to_number()) / 100.f;
- set_cxform(cx);
- transformedByScript(); // m_accept_anim_moves = false;
- return;
- }
- case M_VISIBLE:
- //else if (name == "_visible")
- {
- set_visible(val.to_bool());
- transformedByScript(); // m_accept_anim_moves = false;
- return;
- }
- case M_WIDTH:
- //else if (name == "_width")
- {
- // @@ tulrich: is parameter in world-coords or local-coords?
- matrix m = get_matrix();
- m.m_[0][0] =
infinite_to_fzero(PIXELS_TO_TWIPS(val.to_number()));
- float w = get_width();
- if (fabsf(w) > 1e-6f)
- {
- m.m_[0][0] /= w;
- }
- set_matrix(m);
- transformedByScript(); // m_accept_anim_moves = false;
- return;
- }
- case M_HEIGHT:
- //else if (name == "_height")
- {
- // @@ tulrich: is parameter in world-coords or local-coords?
- matrix m = get_matrix();
- m.m_[1][1] =
infinite_to_fzero(PIXELS_TO_TWIPS(val.to_number()));
- float h = get_width(); // FIXME: shoudln't this be
get_height ??
- if (fabsf(h) > 1e-6f)
- {
- m.m_[1][1] /= h;
- }
- set_matrix(m);
- transformedByScript(); // m_accept_anim_moves = false;
- return;
- }
- case M_ROTATION:
- //else if (name == "_rotation")
- {
- matrix m = get_matrix();
-
- // Decompose matrix and insert the desired value.
- float x_scale = m.get_x_scale();
- float y_scale = m.get_y_scale();
- float rotation = (float) val.to_number() *
float(M_PI) / 180.f; // input is in degrees
- m.set_scale_rotation(x_scale, y_scale, rotation);
-
- set_matrix(m);
- transformedByScript(); // m_accept_anim_moves = false;
- return;
- }
- case M_ONROLLOVER:
- {
- set_event_handler(event_id::ROLL_OVER, val);
- return;
- }
- case M_ONROLLOUT:
- {
- set_event_handler(event_id::ROLL_OUT, val);
- return;
- }
- case M_HIGHQUALITY:
- //else if (name == "_highquality")
- {
- // @@ global { 0, 1, 2 }
-// // Whether we're in high quality mode or not.
-// val->set(true);
- return;
- }
- case M_FOCUSRECT:
- //else if (name == "_focusrect")
- {
-// // Is a yellow rectangle visible around a
focused movie clip (?)
-// val->set(false);
- return;
- }
- case M_SOUNDBUFTIME:
- //else if (name == "_soundbuftime")
- {
- // @@ global
-// // Number of seconds before sound starts to
stream.
-// val->set(0.0);
- return;
- }
- } // end switch
-#endif // def OLD_GET_MEMBER
-
-#ifdef DEBUG_DYNTEXT_VARIABLES
-log_msg(" not a standard member");
-#endif
-
-
-#if 0 // we'd need a testcase for this, my "short" tests show
- // that a textfield variable cannot be assigned to like this
-
- // Not a built-in property. See if we have a
- // matching edit_text character in our display
- // list.
- bool text_val = val.is_string() || val.is_number();
- if (text_val)
- {
- // CASE INSENSITIVE compare.
- // In ActionScript 2.0, this must change
- // to CASE SENSITIVE!!!
- character* ch = m_display_list.get_character_by_name_i(
name.c_str());
- if ( ch ) // item found
- {
- const char* text = val.to_string();
- ch->set_text_value(text);
- return;
- }
- }
-
-#ifdef DEBUG_DYNTEXT_VARIABLES
- log_msg(" not a character");
-#endif
-#endif
-
-
// Try textfield variables
//
// FIXME: Turn textfield variables into Getter/Setters (Properties)
@@ -2532,24 +1997,20 @@
if ( etc )
{
#ifdef DEBUG_DYNTEXT_VARIABLES
-log_msg(" it's a Text Variable!");
+ log_msg(" it's a Text Variable!");
#endif
etc->set_text_value(val.to_string());
}
#ifdef DEBUG_DYNTEXT_VARIABLES
else
{
-log_msg(" it's NOT a Text Variable!");
+ log_msg(" it's NOT a Text Variable!");
}
#endif
// If that didn't work call the default set_member
set_member_default(name, val);
-
- // If that didn't work, set a variable within this environment.
- // TODO: check if we broke anything with this!
- //if ( ! t ) m_as_environment.set_member(name.c_str(), val);
}
const char* sprite_instance::get_variable(const char* path_to_var) const
@@ -2704,7 +2165,8 @@
// Call UNLOAD event of just removed chars !
DisplayList justRemoved = oldDisplayList;
- justRemoved.clear_except(m_display_list, true);
+ justRemoved.clear_except(m_display_list, false); // true;
+ // No, dont' call UNLOAD event, as it should be called by
remove_display_object!
// Finally, execute actions in newly added childs
//
@@ -2721,26 +2183,6 @@
//log_msg("Advancing %d newly-added (after clearing) childs of %s",
newlyAdded.size(), getTargetPath().c_str());
newlyAdded.advance(delta_time);
-#if 0 // we push gotoframe actions on the global queue now
- // goto_frame_action (for now) need be executed
- // *after* actions in child sprites have
- // been executed. When action execution order
- // is fixed, we can move this code inside
- // do_action, or completely drop m_goto_frame_action_list
- // or rather push actions in goto_frame target frame
- // directly in the m_action_list (simplest)
- if ( ! m_goto_frame_action_list.empty() )
- {
- IF_VERBOSE_ACTION(
- log_action(" Executing %u actions in "
- "goto_frame_action_list",
- m_goto_frame_action_list.size());
- );
- execute_actions(m_goto_frame_action_list);
- assert(m_goto_frame_action_list.empty());
- }
-#endif
-
// Remember current state of the DisplayList for next iteration
oldDisplayList = m_display_list;
}
@@ -2955,7 +2397,9 @@
void
sprite_instance::goto_frame(size_t target_frame_number)
{
-// IF_VERBOSE_DEBUG(log_msg("sprite::goto_frame(%d)\n",
target_frame_number));//xxxxx
+ log_msg("sprite %s ::goto_frame(%d) - current frame is %d",
+ getTargetPath().c_str(), target_frame_number,
m_current_frame);
+ assert(! isUnloaded() );
// target_frame_number = iclamp(target_frame_number, 0,
m_def->get_frame_count() - 1);
// Macromedia Flash ignores goto_frame(bad_frame)
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -b -r1.85 -r1.86
--- server/sprite_instance.h 2 Apr 2007 09:12:48 -0000 1.85
+++ server/sprite_instance.h 2 Apr 2007 15:45:22 -0000 1.86
@@ -17,7 +17,7 @@
//
//
-/* $Id: sprite_instance.h,v 1.85 2007/04/02 09:12:48 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.86 2007/04/02 15:45:22 strk Exp $ */
// Stateful live Sprite instance
@@ -700,9 +700,6 @@
private:
- /// Queue event handler(s), if any.
- void queueEventHandler(const event_id& id);
-
/// Queue actions in the action list
//
/// The list of action will be pushed on the current
Index: server/asobj/Key.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/asobj/Key.cpp 20 Mar 2007 15:01:20 -0000 1.19
+++ server/asobj/Key.cpp 2 Apr 2007 15:45:22 -0000 1.20
@@ -316,64 +316,6 @@
return as_value();
}
-void notify_key_event(key::code k, bool down)
- // External interface for the host to report key events.
-{
-// GNASH_REPORT_FUNCTION;
-
- // Notify keypress listeners.
- if (down)
- {
- movie_root& mroot = VM::get().getRoot();
- mroot.notify_keypress_listeners(k);
- }
-
- //
- // Notify the _global.Key object about key event
- //
-
-
- VM& vm = VM::get();
- if ( vm.getSWFVersion() < 6 )
- {
- // _global.Key was added in SWF6
- return;
- }
-
- static boost::intrusive_ptr<key_as_object> keyobject = NULL;
- if ( ! keyobject )
- {
- // This isn't very performant... do we allow user override
- // of _global.Key, btw ?
-
- as_value kval;
- as_object* global = VM::get().getGlobal();
-
- std::string objName = "Key";
- if ( vm.getSWFVersion() < 7 )
- {
- boost::to_lower(objName, vm.getLocale());
- }
- if ( global->get_member(objName, &kval) )
- {
- //log_msg("Found member 'Key' in _global: %s",
kval.to_string());
- boost::intrusive_ptr<as_object> obj = kval.to_object();
- //log_msg("_global.Key to_object() : %s @ %p",
typeid(*obj).name(), obj);
- keyobject = boost::dynamic_pointer_cast<key_as_object>(
obj );
- }
- }
-
- if ( keyobject )
- {
- if (down) keyobject->set_key_down(k);
- else keyobject->set_key_up(k);
- }
- else
- {
- log_error("gnash::notify_key_event(): _global.Key doesn't
exist, or isn't the expected built-in\n");
- }
-}
-
void key_class_init(as_object& global)
{
Index: server/vm/ExecutableCode.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ExecutableCode.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/vm/ExecutableCode.h 27 Mar 2007 14:52:05 -0000 1.1
+++ server/vm/ExecutableCode.h 2 Apr 2007 15:45:22 -0000 1.2
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: ExecutableCode.h,v 1.1 2007/03/27 14:52:05 strk Exp $ */
+/* $Id: ExecutableCode.h,v 1.2 2007/04/02 15:45:22 strk Exp $ */
#ifndef GNASH_EXECUTABLECODE_H
#define GNASH_EXECUTABLECODE_H
@@ -81,7 +81,7 @@
public:
- FunctionCode(boost::intrusive_ptr<as_function> nFunc,
boost::intrusive_ptr<sprite_instance> nTarget)
+ FunctionCode(boost::intrusive_ptr<as_function> nFunc,
boost::intrusive_ptr<character> nTarget)
:
func(nFunc),
target(nTarget)
@@ -90,14 +90,15 @@
virtual void execute()
{
//log_msg("Execution of FunctionCode unimplemented yet");
- func->call(fn_call(target.get(), &(target->get_environment()),
0, 0));
+ as_environment env; env.set_target(target.get());
+ func->call(fn_call(target.get(), &env, 0, 0));
}
private:
boost::intrusive_ptr<as_function> func;
- boost::intrusive_ptr<sprite_instance> target;
+ boost::intrusive_ptr<character> target;
};
Index: testsuite/MovieTester.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- testsuite/MovieTester.cpp 28 Feb 2007 17:25:26 -0000 1.23
+++ testsuite/MovieTester.cpp 2 Apr 2007 15:45:22 -0000 1.24
@@ -157,13 +157,13 @@
void
MovieTester::pressKey(key::code code)
{
- notify_key_event(code, true);
+ _movie_root->notify_key_event(code, true);
}
void
MovieTester::releaseKey(key::code code)
{
- notify_key_event(code, false);
+ _movie_root->notify_key_event(code, false);
}
bool
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gui.cpp gui/gui...,
Sandro Santilli <=