[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11212: Add named instances as butto
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11212: Add named instances as button members. Fixes bug #24467. |
Date: |
Tue, 07 Jul 2009 17:50:32 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11212
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2009-07-07 17:50:32 +0200
message:
Add named instances as button members. Fixes bug #24467.
Add basic test for enumerable button members (needs improvement).
added:
testsuite/misc-ming.all/ButtonPropertiesTest.c
testsuite/misc-ming.all/ButtonPropertiesTestRunner.cpp
modified:
libcore/Button.cpp
testsuite/misc-ming.all/ButtonEventsTest.c
testsuite/misc-ming.all/Makefile.am
------------------------------------------------------------
revno: 11208.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2009-07-07 16:56:59 +0200
message:
Add and remove named instances as enumerable properties. Fixes bug #24467.
modified:
libcore/Button.cpp
------------------------------------------------------------
revno: 11208.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2009-07-07 17:26:13 +0200
message:
Add a simple, not really self-contained test for button instance
properties.
added:
testsuite/misc-ming.all/ButtonPropertiesTest.c
testsuite/misc-ming.all/ButtonPropertiesTestRunner.cpp
modified:
testsuite/misc-ming.all/ButtonEventsTest.c
testsuite/misc-ming.all/Makefile.am
=== modified file 'libcore/Button.cpp'
--- a/libcore/Button.cpp 2009-06-10 11:27:47 +0000
+++ b/libcore/Button.cpp 2009-07-07 14:56:59 +0000
@@ -217,6 +217,22 @@
// Forward declarations
static as_object* getButtonInterface();
+namespace {
+ void addInstanceProperty(Button& b, DisplayObject* d) {
+ if (!d) return;
+ const std::string& name = d->get_name();
+ if (name.empty()) return;
+ b.init_member(name, d, 0);
+ }
+
+ void removeInstanceProperty(Button& b, DisplayObject* d) {
+ if (!d) return;
+ const std::string& name = d->get_name();
+ if (name.empty()) return;
+ b.delProperty(b.getVM().getStringTable().find(name));
+ }
+}
+
/// Predicates for standard algorithms.
/// Depth comparator for DisplayObjects.
@@ -683,9 +699,10 @@
if ( ! shouldBeThere )
{
+
// is there, but is unloaded: destroy, clear slot and go on
- if ( oldch && oldch->unloaded() )
- {
+ if ( oldch && oldch->unloaded() ) {
+ removeInstanceProperty(*this, oldch);
if ( ! oldch->isDestroyed() ) oldch->destroy();
_stateCharacters[i] = NULL;
oldch = NULL;
@@ -698,7 +715,8 @@
if ( ! oldch->unload() )
{
// No onUnload handler: destroy and clear slot
- if ( ! oldch->isDestroyed() ) oldch->destroy();
+ removeInstanceProperty(*this, oldch);
+ if (!oldch->isDestroyed()) oldch->destroy();
_stateCharacters[i] = NULL;
}
else
@@ -718,6 +736,7 @@
// Is there already, but is unloaded: destroy and consider as gone
if ( oldch && oldch->unloaded() )
{
+ removeInstanceProperty(*this, oldch);
if ( ! oldch->isDestroyed() ) oldch->destroy();
_stateCharacters[i] = NULL;
oldch = NULL;
@@ -730,6 +749,7 @@
set_invalidated();
_stateCharacters[i] = ch;
+ addInstanceProperty(*this, ch);
ch->stagePlacementCallback();
}
}
@@ -885,6 +905,7 @@
DisplayObject* ch = rec.instantiate(this);
_stateCharacters[rno] = ch;
+ addInstanceProperty(*this, ch);
ch->stagePlacementCallback(); // give this DisplayObject a life
}
@@ -1125,7 +1146,12 @@
os << actChars.size() << " active DisplayObjects for state " <<
mouseStateName(_mouseState);
InfoTree::iterator localIter = tr.append_child(selfIt,
- StringPair(_("Button state"), os.str()));
+ StringPair(_("Button state"), os.str()));
+
+ os.str("");
+ os << std::boolalpha << isEnabled();
+ localIter = tr.append_child(selfIt, StringPair(_("Enabled"), os.str()));
+
std::for_each(actChars.begin(), actChars.end(),
boost::bind(&DisplayObject::getMovieInfo, _1, tr, localIter));
=== modified file 'testsuite/misc-ming.all/ButtonEventsTest.c'
--- a/testsuite/misc-ming.all/ButtonEventsTest.c 2009-04-03 09:29:19
+0000
+++ b/testsuite/misc-ming.all/ButtonEventsTest.c 2009-07-07 15:26:13
+0000
@@ -140,6 +140,7 @@
//" _root.note(''+this+' at depth '+myDepth+'
unloaded.');"
" _root.buttonChild[myDepth]['uld']++;"
"};"
+ "for (i in _level0.square1.button) { trace (i); };"
//"_root.note('buttonChilds:'+dumpObj(_root.buttonChild));"
));
SWFMovieClip_nextFrame(ermc);
=== added file 'testsuite/misc-ming.all/ButtonPropertiesTest.c'
--- a/testsuite/misc-ming.all/ButtonPropertiesTest.c 1970-01-01 00:00:00
+0000
+++ b/testsuite/misc-ming.all/ButtonPropertiesTest.c 2009-07-07 15:26:13
+0000
@@ -0,0 +1,187 @@
+/***********************************************************************
+ *
+ * Copyright (C) 2005, 2006, 2009 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
+ *
+ *
+ */
+
+#include "ming_utils.h"
+
+#include <ming.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define OUTPUT_VERSION 6
+#define OUTPUT_FILENAME "ButtonPropertiesTest.swf"
+
+SWFFont font;
+
+void add_event(SWFMovie mo, const char* name, const char* event, const char*
action);
+SWFDisplayItem add_button(SWFMovie mo);
+
+SWFDisplayItem
+add_button(SWFMovie mo)
+{
+ SWFDisplayItem it;
+ SWFMovieClip mc, mc1;
+ SWFButtonRecord br;
+ SWFShape sh1, sh2, sh3, sh4, sh1a, sh2a, sh3a, sh4a;
+ SWFButton bu = newSWFButton();
+ mc = newSWFMovieClip();
+
+ sh1 = make_fill_square(0, 0, 40, 40, 0, 0, 0, 0, 0, 0);
+ sh1a = make_fill_square(30, 30, 5, 5, 128, 128, 128, 128, 128, 128);
+ sh2 = make_fill_square(0, 0, 40, 40, 255, 0, 0, 255, 0, 0);
+ sh2a = make_fill_square(30, 30, 5, 5, 128, 0, 0, 128, 0, 0);
+ sh3 = make_fill_square(0, 0, 40, 40, 0, 255, 0, 0, 255, 0);
+ sh3a = make_fill_square(30, 30, 5, 5, 0, 128, 0, 0, 128, 0);
+ sh4 = make_fill_square(0, 0, 40, 40, 255, 255, 0, 255, 255, 0);
+ sh4a = make_fill_square(30, 30, 5, 5, 128, 128, 0, 128, 128, 0);
+
+ /* Higher depth DisplayObject is intentionally added before lower depth
one */
+ br = SWFButton_addCharacter(bu, (SWFCharacter)sh1a, SWFBUTTON_HIT);
+ SWFButtonRecord_setDepth(br, 2);
+ br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
+ SWFButtonRecord_setDepth(br, 1);
+
+ /* Higher depth DisplayObject is intentionally added before lower depth
one */
+ br = SWFButton_addCharacter(bu, (SWFCharacter)sh2a, SWFBUTTON_UP );
+ SWFButtonRecord_setDepth(br, 2);
+ br = SWFButton_addCharacter(bu, (SWFCharacter)sh2, SWFBUTTON_UP );
+ SWFButtonRecord_setDepth(br, 1);
+
+ mc1 = newSWFMovieClip();
+ br = SWFButton_addCharacter(bu, (SWFCharacter)mc1, SWFBUTTON_UP);
+ SWFButtonRecord_setDepth(br, 8);
+
+ br = SWFButton_addCharacter(bu, (SWFCharacter)mc1, SWFBUTTON_DOWN);
+ SWFButtonRecord_setDepth(br, 7);
+
+ br = SWFButton_addCharacter(bu, (SWFCharacter)mc1, SWFBUTTON_HIT);
+ SWFButtonRecord_setDepth(br, 9);
+
+ it = SWFMovieClip_add(mc, (SWFBlock)bu);
+ SWFDisplayItem_setName(it, "button");
+ SWFMovieClip_nextFrame(mc); /* showFrame */
+
+
+ it = SWFMovie_add(mo, (SWFBlock)mc);
+ return it;
+}
+
+int
+main(int argc, char **argv)
+{
+ SWFMovie mo;
+ SWFDisplayItem it;
+ const char *srcdir=".";
+ SWFMovieClip dejagnuclip;
+
+ /*********************************************
+ *
+ * Initialization
+ *
+ *********************************************/
+
+ puts("Setting things up");
+
+ Ming_init();
+ Ming_useSWFVersion (OUTPUT_VERSION);
+ Ming_setScale(20.0);
+
+ mo = newSWFMovie();
+ SWFMovie_setDimension(mo, 800, 600);
+ SWFMovie_setRate(mo, 12);
+
+ if ( argc>1 ) srcdir=argv[1];
+ else
+ {
+ fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+ return 1;
+ }
+
+ font = get_default_font(srcdir);
+
+ /* Dejagnu equipment */
+ dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 800, 600);
+ it = SWFMovie_add(mo, (SWFBlock)dejagnuclip);
+ SWFDisplayItem_setDepth(it, 200);
+ SWFDisplayItem_move(it, 200, 0);
+
+ SWFMovie_nextFrame(mo); /* showFrame */
+
+ /*****************************************************
+ *
+ * Add button
+ *
+ *****************************************************/
+
+ it = add_button(mo);
+ SWFDisplayItem_moveTo(it, 40, 30);
+ SWFDisplayItem_setName(it, "square1");
+ SWFDisplayItem_setDepth(it, 2);
+
+ add_actions(mo, "note('This is a very simple test. Do anything you like "
+ "with the buttons and you should get no failures');");
+
+ add_actions(mo, "var c = 2;");
+ add_actions(mo,
+ "props = function() {"
+ " s=''; "
+ " for (i in square1.button) { "
+ " if (i.substr(0, 8) == 'instance') { s += i; }; "
+ " };"
+ " return s;"
+ "};");
+ add_actions(mo, "check_equals(props(), 'instance' + c++);");
+ add_actions(mo,
+ "square1.button.onRollOver = function() {"
+ " check_equals(props(), '');"
+ "};"
+ "square1.button.onRollOut = function() {"
+ " check_equals(props(), 'instance' + c++);"
+ "};"
+ "square1.button.onMouseDown = function() {"
+ " check_equals(props(), 'instance' + c++);"
+ "};"
+ "square1.button.onPress = function() {"
+ " check_equals(props(), 'instance' + c++);"
+ "};"
+ "square1.button.onRelease = function() {"
+ " check_equals(props(), '');"
+ "};"
+ "square1.button.onReleaseOutside = function() {"
+ " check_equals(props(), 'instance' + c++);"
+ "};"
+ );
+
+ //add_actions(mo, "onEnterFrame = function() { props(); trace (s); };");
+ add_actions(mo, "stop();");
+ SWFMovie_nextFrame(mo); /* showFrame */
+
+ /*****************************************************
+ *
+ * Save it...
+ *
+ *****************************************************/
+
+ puts("Saving " OUTPUT_FILENAME );
+
+ SWFMovie_save(mo, OUTPUT_FILENAME);
+
+ return 0;
+}
=== added file 'testsuite/misc-ming.all/ButtonPropertiesTestRunner.cpp'
--- a/testsuite/misc-ming.all/ButtonPropertiesTestRunner.cpp 1970-01-01
00:00:00 +0000
+++ b/testsuite/misc-ming.all/ButtonPropertiesTestRunner.cpp 2009-07-07
15:26:13 +0000
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 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
+ *
+ *
+ */
+
+#define INPUT_FILENAME "ButtonPropertiesTest.swf"
+
+#include "MovieTester.h"
+#include "MovieClip.h"
+#include "DisplayObject.h"
+#include "DisplayList.h"
+#include "log.h"
+#include "VM.h"
+
+#include "check.h"
+#include <string>
+#include <cassert>
+
+using namespace gnash;
+using namespace std;
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+ string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
+ MovieTester tester(filename);
+
+ MovieClip* root = tester.getRootMovie();
+ assert(root);
+
+ tester.advance();
+ check_equals(root->get_current_frame(), 1);
+
+ tester.movePointerTo(45, 35);
+ tester.click();
+
+ tester.movePointerTo(100, 200);
+ tester.movePointerTo(45, 35);
+ tester.movePointerTo(100, 200);
+ tester.movePointerTo(45, 35);
+ tester.movePointerTo(100, 200);
+ tester.movePointerTo(45, 35);
+ tester.movePointerTo(100, 200);
+ tester.movePointerTo(45, 35);
+ tester.movePointerTo(100, 200);
+ tester.movePointerTo(45, 35);
+ tester.click();
+ tester.click();
+ tester.click();
+}
+
=== modified file 'testsuite/misc-ming.all/Makefile.am'
--- a/testsuite/misc-ming.all/Makefile.am 2009-06-17 15:33:51 +0000
+++ b/testsuite/misc-ming.all/Makefile.am 2009-07-07 15:26:13 +0000
@@ -230,8 +230,11 @@
if MING_SUPPORTS_SWFBUTTON_SET_DEPTH
check_PROGRAMS += \
+ ButtonPropertiesTest \
ButtonEventsTest \
- ButtonEventsTest-Runner
+ ButtonPropertiesTestRunner \
+ ButtonEventsTest-Runner \
+ $(NULL)
endif
if MING_VERSION_0_4_3
@@ -1682,6 +1685,27 @@
StageConfigTest.swf: $(srcdir)/StageConfigTest.as
$(MAKESWF) -o $@ -s 512x512 $(srcdir)/StageConfigTest.as
+ButtonPropertiesTest_SOURCES = \
+ ButtonPropertiesTest.c \
+ $(NULL)
+ButtonPropertiesTest_LDADD = libgnashmingutils.la
+ButtonPropertiesTest.swf: ButtonPropertiesTest
+ ./ButtonPropertiesTest $(top_srcdir)/testsuite/media
+ButtonPropertiesTestRunner_SOURCES = \
+ ButtonPropertiesTestRunner.cpp \
+ $(NULL)
+ButtonPropertiesTestRunner_LDADD = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ $(NULL)
+ButtonPropertiesTestRunner_DEPENDENCIES = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ ButtonPropertiesTest.swf \
+ $(NULL)
+ButtonPropertiesTestRunner_CXXFLAGS = \
+ -DTGTDIR='"$(abs_builddir)"' \
+ $(NULL)
+
+
init_action_test_SOURCES = \
init_action_test.c \
$(NULL)
@@ -2047,6 +2071,7 @@
if MING_SUPPORTS_SWFBUTTON_SET_DEPTH
TEST_CASES += \
+ ButtonPropertiesTestRunner \
ButtonEventsTest-Runner \
$(NULL)
endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11212: Add named instances as button members. Fixes bug #24467.,
Benjamin Wolsey <=