[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/button_character_instanc...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/button_character_instanc... |
Date: |
Wed, 16 Jan 2008 11:31:08 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/01/16 11:31:08
Modified files:
. : ChangeLog
server : button_character_instance.cpp
button_character_instance.h
server/parser : button_character_def.cpp button_character_def.h
server/swf : tag_loaders.cpp
testsuite/misc-swfc.all: Makefile.am
Added files:
testsuite/misc-swfc.all: button_test1.sc
Log message:
Allow accessing button childs (state characters) by name, add initial
test
for this and further button testing.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5411&r2=1.5412
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.70&r2=1.71
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.h?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/button_character_def.cpp?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/button_character_def.h?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.177&r2=1.178
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-swfc.all/Makefile.am?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-swfc.all/button_test1.sc?cvsroot=gnash&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5411
retrieving revision 1.5412
diff -u -b -r1.5411 -r1.5412
--- ChangeLog 16 Jan 2008 10:20:28 -0000 1.5411
+++ ChangeLog 16 Jan 2008 11:31:07 -0000 1.5412
@@ -1,5 +1,17 @@
2008-01-16 Sandro Santilli <address@hidden>
+ * testsuite/misc-swfc.all/: Makefile.am, button_test1.sc:
+ initial test for button interaction
+ * server/button_character_instance.{cpp,h}: allow
+ accessing button childs (state characters) by name.
+ * server/swf/tag_loaders.cpp (button_character_loader):
+ properly construct button characters
+ * server/parser/button_character_def.{cpp,h}:
+ Keep a pointer to the movie_definition containing
+ Button definitions, expose a getSWFVersion.
+
+2008-01-16 Sandro Santilli <address@hidden>
+
* server/: character.h, button_character_instance.h,
edit_text_character.h, sprite_instance.h, video_stream_instance.h:
const-correct wantsInstanceName() and isActionScriptReferenceable()
Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- server/button_character_instance.cpp 19 Dec 2007 20:40:31 -0000
1.70
+++ server/button_character_instance.cpp 16 Jan 2008 11:31:07 -0000
1.71
@@ -35,6 +35,7 @@
#include "fn_call.h" // for shared ActionScript getter-setters
#include "GnashException.h" // for shared ActionScript getter-setters
#include "ExecutableCode.h"
+#include "namedStrings.h"
/** \page buttons Buttons and mouse behaviour
@@ -773,24 +774,33 @@
button_character_instance::get_path_element(string_table::key key)
{
as_object* ch = get_path_element_character(key);
+ if ( ch ) return ch;
- if ( ! ch )
- {
string name = _vm.getStringTable().value(key);
- size_t size = m_record_character.size();
+ return getChildByName(name); // possibly NULL
+}
+character *
+button_character_instance::getChildByName(const std::string& name) const
+{
// See if we have a match on the button records list
- // TODO: Should we scan only currently visible characters
- // (get_active_characters) ??
- for (size_t i=0; i<size; i++)
+ for (size_t i=0, n=m_record_character.size(); i<n; ++i)
{
character* child = m_record_character[i].get();
- if (child->get_name() == name)
- return child;
+ const char* pat_c = child->get_name().c_str();
+ const char* nam_c = name.c_str();
+
+ if ( _vm.getSWFVersion() >= 7 )
+ {
+ if (! strcmp(pat_c, nam_c) ) return child;
+ }
+ else
+ {
+ if ( ! strcasecmp(pat_c, nam_c) ) return child;
}
}
- return ch; // possibly NULL
+ return NULL;
}
void
@@ -873,6 +883,112 @@
return hasUnloadEvent || childsHaveUnload;
}
+bool
+button_character_instance::get_member(string_table::key name_key, as_value*
val,
+ string_table::key nsname)
+{
+ // FIXME: use addProperty interface for these !!
+ // TODO: or at least have a character:: protected method take
+ // care of these ?
+ // Duplicates code in character::get_path_element_character too..
+ //
+ if (name_key == NSV::PROP_uROOT)
+ {
+
+ // Let ::get_root() take care of _lockroot
+ movie_instance* relRoot = get_root();
+ val->set_as_object( relRoot );
+ return true;
+ }
+
+ // NOTE: availability of _global doesn't depend on VM version
+ // but on actual movie version. Example: if an SWF4 loads
+ // an SWF6 (to, say, _level2), _global will be unavailable
+ // to the SWF4 code but available to the SWF6 one.
+ //
+ if ( getSWFVersion() > 5 && name_key == NSV::PROP_uGLOBAL ) // see
MovieClip.as
+ {
+ // The "_global" ref was added in SWF6
+ val->set_as_object( _vm.getGlobal() );
+ return true;
+ }
+
+ const std::string& name = _vm.getStringTable().value(name_key);
+
+ if (name.compare(0, 6, "_level") == 0 &&
name.find_first_not_of("0123456789", 7) == string::npos )
+ {
+ unsigned int levelno = atoi(name.c_str()+6); // getting 0 here for
"_level" is intentional
+ movie_instance* mo = _vm.getRoot().getLevel(levelno).get();
+ if ( mo )
+ {
+ val->set_as_object(mo);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ // TOCHECK : Try object members, BEFORE display list items
+ //
+ if (get_member_default(name_key, val, nsname))
+ {
+
+// ... trying to be useful to Flash coders ...
+// The check should actually be performed before any return
+// prior to the one due to a match in the DisplayList.
+// It's off by default anyway, so not a big deal.
+// See bug #18457
+#define CHECK_FOR_NAME_CLASHES 1
+#ifdef CHECK_FOR_NAME_CLASHES
+ IF_VERBOSE_ASCODING_ERRORS(
+ if ( getChildByName(name) )
+ {
+ log_aserror(_("A button member (%s) clashes with "
+ "the name of an existing character "
+ "in its display list. "
+ "The member will hide the "
+ "character"), name.c_str());
+ }
+ );
+#endif
+
+ return true;
+ }
+
+
+ // Try items on our display list.
+ character* ch = getChildByName(name);
+
+ if (ch)
+ {
+ // Found object.
+
+ // If the object is an ActionScript referenciable one we
+ // return it, otherwise we return ourselves
+ if ( ch->isActionScriptReferenceable() )
+ {
+ val->set_as_object(ch);
+ }
+ else
+ {
+ val->set_as_object(this);
+ }
+
+ return true;
+ }
+
+ return false;
+
+}
+
+int
+button_character_instance::getSWFVersion() const
+{
+ return m_def->getSWFVersion();
+}
+
} // end of namespace gnash
Index: server/button_character_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/button_character_instance.h 16 Jan 2008 10:20:29 -0000 1.29
+++ server/button_character_instance.h 16 Jan 2008 11:31:07 -0000 1.30
@@ -21,7 +21,7 @@
// SWF buttons. Mouse-sensitive update/display, actions, etc.
-/* $Id: button_character_instance.h,v 1.29 2008/01/16 10:20:29 strk Exp $ */
+/* $Id: button_character_instance.h,v 1.30 2008/01/16 11:31:07 strk Exp $ */
#ifndef GNASH_BUTTON_CHARACTER_INSTANCE_H
#define GNASH_BUTTON_CHARACTER_INSTANCE_H
@@ -85,6 +85,10 @@
~button_character_instance();
+ // See dox in as_object.h
+ bool get_member(string_table::key name, as_value* val,
+ string_table::key nsname = 0);
+
bool can_handle_mouse_event() const { return true; }
// called from keypress listener only
@@ -171,6 +175,23 @@
#endif // GNASH_USE_GC
private:
+
+
+ /// Return any state character whose name matches the given string
+ //
+ /// NOTE: both active and inactive childs are scanned for
+ ///
+ /// @param name
+ /// Name to match, search is case sensitive for SWF7 and higher,
+ /// case insensitive up to SWF6.
+ ///
+ character * getChildByName(const std::string& name) const;
+
+ /// \brief
+ /// Return version of the SWF containing
+ /// the button definition this is an instance of.
+ int getSWFVersion() const;
+
bool m_enabled;
};
Index: server/parser/button_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/button_character_def.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/parser/button_character_def.cpp 29 Dec 2007 20:15:25 -0000
1.24
+++ server/parser/button_character_def.cpp 16 Jan 2008 11:31:07 -0000
1.25
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: button_character_def.cpp,v 1.24 2007/12/29 20:15:25 strk Exp $ */
+/* $Id: button_character_def.cpp,v 1.25 2008/01/16 11:31:07 strk Exp $ */
// Based on the public domain work of Thatcher Ulrich <address@hidden> 2003
@@ -157,11 +157,12 @@
// button_character_definition
//
-button_character_definition::button_character_definition()
+button_character_definition::button_character_definition(movie_definition* m)
:
m_min_layer(0),
m_max_layer(0),
- m_sound(NULL)
+ m_sound(NULL),
+ _movieDef(m)
// Constructor.
{
@@ -447,6 +448,12 @@
}
#endif // GNASH_USE_GC
+int
+button_character_definition::getSWFVersion() const
+{
+ return _movieDef->get_version();
+}
+
} // namespace gnash
// Local Variables:
Index: server/parser/button_character_def.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/button_character_def.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/parser/button_character_def.h 29 Dec 2007 20:15:25 -0000
1.24
+++ server/parser/button_character_def.h 16 Jan 2008 11:31:08 -0000
1.25
@@ -26,6 +26,7 @@
// Forward declarations
namespace gnash {
class sprite_instance;
+ class movie_definition;
}
namespace gnash {
@@ -201,7 +202,11 @@
boost::scoped_ptr<button_sound_def> m_sound;
- button_character_definition();
+ /// \brief
+ /// Construct a character definition as read from
+ /// the given movie_definition (SWF)
+ button_character_definition(movie_definition* m);
+
virtual ~button_character_definition();
/// Create a mutable instance of our definition.
@@ -237,6 +242,11 @@
abort(); // not implemented
}
+ /// \brief
+ /// Return version of the SWF containing
+ /// this button definition.
+ int getSWFVersion() const;
+
protected:
#ifdef GNASH_USE_GC
@@ -257,6 +267,10 @@
if ( m_sound ) m_sound->markReachableResources();
}
#endif // GNASH_USE_GC
+private:
+
+ /// The movie definition containing definition of this button
+ movie_definition* _movieDef;
};
} // end namespace gnash
Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -b -r1.177 -r1.178
--- server/swf/tag_loaders.cpp 10 Jan 2008 11:44:04 -0000 1.177
+++ server/swf/tag_loaders.cpp 16 Jan 2008 11:31:08 -0000 1.178
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: tag_loaders.cpp,v 1.177 2008/01/10 11:44:04 strk Exp $ */
+/* $Id: tag_loaders.cpp,v 1.178 2008/01/16 11:31:08 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -944,7 +944,7 @@
log_parse(_(" button character loader: char_id = %d"), character_id);
);
- button_character_definition* ch = new button_character_definition;
+ button_character_definition* ch = new button_character_definition(m);
ch->read(in, tag, m);
m->add_character(character_id, ch);
Index: testsuite/misc-swfc.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-swfc.all/Makefile.am,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- testsuite/misc-swfc.all/Makefile.am 29 Dec 2007 22:16:22 -0000 1.26
+++ testsuite/misc-swfc.all/Makefile.am 16 Jan 2008 11:31:08 -0000 1.27
@@ -37,6 +37,7 @@
gotoFrameFromInterval.sc \
gotoFrameFromInterval2.sc \
gotoFrameLabelAsFunction.sc \
+ button_test1.sc \
$(NULL)
# These ones are the ones for which consistency check fail
Index: testsuite/misc-swfc.all/button_test1.sc
===================================================================
RCS file: testsuite/misc-swfc.all/button_test1.sc
diff -N testsuite/misc-swfc.all/button_test1.sc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-swfc.all/button_test1.sc 16 Jan 2008 11:31:08 -0000
1.1
@@ -0,0 +1,131 @@
+/*
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+.flash bbox=800x600 filename="button_test1.swf" background=white version=6
fps=12
+
+.frame 1
+
+ .action:
+#include "Dejagnu.sc"
+ .end
+
+.box rbox width=200 height=300 fill=#FF0000 color=#000000
+.box gbox width=200 height=200 fill=#00FF00 color=#000000
+
+.button button1
+ .show rbox as=idle
+ .show rbox as=area
+ .show rbox as=hover
+ .show rbox as=pressed
+ .on_press:
+ trace("red box");
+ button2._xscale = button2._yscale = 100;
+ button1._xscale = button1._yscale = 200;
+ runNextTest();
+ .end
+.end
+
+.button button2
+ .show gbox as=idle
+ .show gbox as=area
+ .show gbox as=hover
+ .show gbox as=pressed
+ .on_press:
+ trace("green box");
+ button2._xscale = button2._yscale = 200;
+ button1._xscale = button1._yscale = 100;
+ runNextTest();
+ .end
+.end
+
+.sprite buttonContainer
+ .put button2 pin=center x=0 y=0 scalex=100% scaley=100%
+ .put button1 pin=center x=20 y=20 scalex=100% scaley=100% alpha=50
+.end
+
+.button button3
+ .show buttonContainer as=idle
+ .show buttonContainer as=area
+ .show buttonContainer as=hover
+ .show buttonContainer as=pressed
+ .on_press:
+ trace("button3");
+ button3._xscale = button3._yscale = 200;
+ .end
+.end
+
+//.put buttonContainer pin=center x=200 y=200 scalex=100% scaley=100%
+.put button3 pin=center x=200 y=300 scalex=100% scaley=50% alpha=50%
+
+.frame 1
+.action:
+
+ test1 = function()
+ {
+ note(" - Testing button stuff - ");
+ check_equals(typeof(button3), 'object');
+ check_equals(button3['_root'], _level0);
+ check_equals(button3['_global'], _global);
+ check_equals(button3['_level0'], _root);
+ check_equals(typeof(button3.instance1), 'movieclip');
+ check_equals(typeof(button3.instANce1), 'movieclip'); //
case-insensitive
+ check_equals(typeof(button3.instance1.button1), 'object');
+ check_equals(typeof(button3.instance1.button2), 'object');
+ check_equals(button3.instance1.button1._height, 300);
+ check_equals(button3.instance1.button2._height, 200);
+
+ endOfTest(); // comment out this line and uncomment the
following ones
+ // when MovieTester-based runners are available,
or you
+ // intend to run the test manually
+ //note("1. Press on the green box.");
+ //nexttest = test2;
+ };
+
+ test2 = function()
+ {
+ check_equals(button3.instance1.button1._height, 300);
+ check_equals(button3.instance1.button2._height, 400);
+ note("2. Press on the red box, where it overlaps with the green
one.");
+ nexttest = test3;
+ };
+
+ test3 = function()
+ {
+ check_equals(button3.instance1.button1._height, 600);
+ check_equals(button3.instance1.button2._height, 200);
+ endOfTest();
+ nexttest = endOfTest;
+
+ };
+
+ endOfTest = function()
+ {
+ totals(10);
+ };
+
+ _global.runNextTest = function()
+ {
+ //note("runNextTest invoked");
+ nexttest();
+ };
+
+ test1();
+.end
+
+.end // file end
+
- [Gnash-commit] gnash ChangeLog server/button_character_instanc...,
Sandro Santilli <=