[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: |
Tue, 15 Apr 2008 09:51:03 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/04/15 09:51:03
Modified files:
. : ChangeLog
server : button_character_instance.cpp
testsuite/misc-ming.all: ButtonEventsTest-Runner.cpp
ButtonEventsTest.c
Log message:
Fix a bug in button_character_instance::getBounds and add tests for it.
(would need to improve it to take transformation matrix into account)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6277&r2=1.6278
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.86&r2=1.87
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/ButtonEventsTest.c?cvsroot=gnash&r1=1.10&r2=1.11
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6277
retrieving revision 1.6278
diff -u -b -r1.6277 -r1.6278
--- ChangeLog 15 Apr 2008 08:04:54 -0000 1.6277
+++ ChangeLog 15 Apr 2008 09:51:02 -0000 1.6278
@@ -1,5 +1,17 @@
2008-04-15 Sandro Santilli <address@hidden>
+ * testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp:
+ Check rendering of the additional state character.
+ * testsuite/misc-ming.all/ButtonEventsTest.c: add a second
+ smaller character for each state making sure it's listed
+ before the wider but is at higher depth. This is very focused
+ on testing the just-fixed bug in button's getBOunds.
+ * server/button_character_instance.cpp (getBounds): consider
+ bounds of all active child characters, not just the first
+ found, and appropriately transform them with their matrix.
+
+2008-04-15 Sandro Santilli <address@hidden>
+
* server/button_character_instance.cpp: revert use of
m_child_invalidated in add_invalidated_bounds as per
Udo's request.
Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- server/button_character_instance.cpp 15 Apr 2008 08:04:54 -0000
1.86
+++ server/button_character_instance.cpp 15 Apr 2008 09:51:03 -0000
1.87
@@ -667,7 +667,12 @@
button_character_instance::add_invalidated_bounds(InvalidatedRanges& ranges,
bool force)
{
- if (!m_visible) return; // not visible anyway
+ if (!m_visible)
+ {
+ //log_debug("button %s not visible on add_invalidated_bounds",
getTarget());
+ return; // not visible anyway
+ }
+ //log_debug("button %s add_invalidated_bounds called", getTarget());
ranges.add(m_old_invalidated_ranges);
@@ -698,24 +703,35 @@
geometry::Range2d<float>
button_character_instance::getBounds() const
{
+ typedef geometry::Range2d<float> Range;
+ Range allBounds(geometry::nullRange);
+
for (size_t i = 0; i < m_def->m_button_records.size(); i++)
{
button_record& rec = m_def->m_button_records[i];
assert(m_record_character.size() > i);
- if (m_record_character[i] == NULL)
- {
- continue;
- }
+ character* ch = m_record_character[i].get();
+
+ if (!ch) continue;
+
if ((m_mouse_state == UP && rec.m_up)
|| (m_mouse_state == DOWN && rec.m_down)
|| (m_mouse_state == OVER && rec.m_over))
{
+
// TODO: should we consider having multiple characters
// for a single state ?
- return m_record_character[i]->getBounds();
+ Range lclBounds = ch->getBounds();
+
+ // TODO: we transform the child bounds here, right ?
+ matrix m = ch->get_matrix();
+ m.transform(lclBounds);
+
+ allBounds.expandTo(lclBounds);
}
}
- return geometry::Range2d<float>(geometry::nullRange);
+
+ return allBounds;
}
bool
@@ -800,16 +816,18 @@
ch->set_cxform(cx);
ch->set_depth(ch_depth);
assert(ch->get_parent() == this);
+ assert(ch->get_name().empty()); // no way to specify a name for
button chars anyway...
- if (ch->get_name().empty() && ch->wantsInstanceName())
+ if ( ch->wantsInstanceName() )
{
- std::string instance_name =
getNextUnnamedInstanceName();
- ch->set_name(instance_name.c_str());
+ //std::string instance_name =
getNextUnnamedInstanceName();
+ ch->set_name(getNextUnnamedInstanceName());
}
m_record_character[r] = ch;
ch->stagePlacementCallback(); // give this character life
(TODO: they aren't on stage, are them ?)
+ //log_debug("Character %d of Button %s, with target %s got a
life", r, getTarget(), ch->getTarget());
}
// there's no INITIALIZE/CONSTRUCT/LOAD/ENTERFRAME/UNLOAD events for
buttons
Index: testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp
===================================================================
RCS file:
/sources/gnash/gnash/testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp 21 Jan 2008 23:26:50
-0000 1.23
+++ testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp 15 Apr 2008 09:51:03
-0000 1.24
@@ -37,9 +37,13 @@
test_mouse_activity(MovieTester& tester, const character* text, const
character* text2, bool covered, bool enabled)
{
rgba red(255,0,0,255);
+ rgba dark_red(128,0,0,255);
rgba covered_red(127,126,0,255); // red, covered by 50% black
+ rgba covered_dark_red(64,120,0,255); // dark red, covered by 50% black
rgba yellow(255,255,0,255);
+ rgba dark_yellow(128,128,0,255);
rgba covered_yellow(128,255,0,255); // yellow, covered by 50% black
+ rgba covered_dark_yellow(64,184,0,255); // dark yellow, covered by 50%
black
rgba green(0,255,0,255);
// roll over the middle of the square, this should change
@@ -49,16 +53,38 @@
check_equals(string(text->get_text_value()),
string("MouseOver"));
check_equals(string(text2->get_text_value()),
string("RollOver"));
check(tester.isMouseOverMouseEntity());
- // check that pixel @ 60,60 is yellow !
- if ( covered ) { check_pixel(60, 60, 2, covered_yellow, 2); }
- else { check_pixel(60, 60, 2, yellow, 2); }
+ if ( covered )
+ {
+ // check that pixel @ 60,60 is yellow (covered)
+ check_pixel(60, 60, 2, covered_yellow, 2);
+ // check that pixel @ 72,64 is dark_yellow (covered)
+ check_pixel(72, 64, 2, covered_dark_yellow, 2);
+ }
+ else
+ {
+ // check that pixel @ 60,60 is yellow
+ check_pixel(60, 60, 2, yellow, 2);
+ // check that pixel @ 72,64 is dark_yellow
+ check_pixel(72, 64, 2, dark_yellow, 2);
+ }
} else {
check_equals(string(text->get_text_value()),
string("MouseOut"));
check_equals(string(text2->get_text_value()),
string("RollOut"));
check(!tester.isMouseOverMouseEntity());
- // check that pixel @ 60,60 is red !
- if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
- else { check_pixel(60, 60, 2, red, 2); }
+ if ( covered )
+ {
+ // check that pixel @ 60,60 is red (covered)
+ check_pixel(60, 60, 2, covered_red, 2);
+ // check that pixel @ 72,64 is dark_red (covered)
+ check_pixel(72, 64, 2, covered_dark_red, 2);
+ }
+ else
+ {
+ // check that pixel @ 60,60 is red
+ check_pixel(60, 60, 2, red, 2);
+ // check that pixel @ 72,64 is dark_red
+ check_pixel(72, 64, 2, dark_red, 2);
+ }
}
// press the mouse button, this should change
Index: testsuite/misc-ming.all/ButtonEventsTest.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/ButtonEventsTest.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- testsuite/misc-ming.all/ButtonEventsTest.c 3 Apr 2008 21:49:45 -0000
1.10
+++ testsuite/misc-ming.all/ButtonEventsTest.c 15 Apr 2008 09:51:03 -0000
1.11
@@ -24,8 +24,8 @@
* In a movie of 120x120 pixels, it places a movieclip containing a squared
* button in the middle of the stage, and a text area on top.
*
- * The movie has 3 frames, with the second adding a shape at a lower depth
- * and the third one at an higher depth respect to the button.
+ * The movie has 4 frames, with the second adding a shape at a lower depth,
+ * the third one at an higher depth, and fourth disabling the button.
*
* The following events print the event name in the text area
* (called _root.textfield) and change the color of the button:
@@ -35,6 +35,23 @@
* MouseDown : green button
* MouseUp : yellow button (same as MouseOver, but the label on top changes)
*
+ * Tests are triggered by events, in particular:
+ * - Test for _target and _name referring to button's parent.
+ * - Test for bounds of buttons being the union of all active state
+ * characters' bounds.
+ *
+ * Note that you need to play with your mouse on the button for the tests
+ * to be run, and that there's currently no END OF TEST condition.
+ * For gnash test automation, we use the ButtonEventsTest-Runner script
+ * that supposedly triggers all tests (still worth making the test
+ * more explicitly guided, also to provide an end-of-test flags for
+ * consistency checking).
+ *
+ * TODO:
+ * - Turn the test into a guided interaction, like the DragDropTest.swf one..
+ * - Add tests for invalidated bounds
+ * - Add matrix transformation to some child to also test that.
+ *
***********************************************************************/
#include "ming_utils.h"
@@ -86,23 +103,48 @@
{
SWFDisplayItem it;
SWFMovieClip mc;
- SWFShape sh1, sh2, sh3, sh4;
+ 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);
- SWFButton_addShape(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
- SWFButton_addShape(bu, (SWFCharacter)sh2, SWFBUTTON_UP );
- SWFButton_addShape(bu, (SWFCharacter)sh3, SWFBUTTON_DOWN );
- SWFButton_addShape(bu, (SWFCharacter)sh4, SWFBUTTON_OVER );
+ /* Higher depth character 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 character 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);
+
+ /* Higher depth character is intentionally added before lower depth one
*/
+ br = SWFButton_addCharacter(bu, (SWFCharacter)sh3a, SWFBUTTON_DOWN );
+ SWFButtonRecord_setDepth(br, 2);
+ br = SWFButton_addCharacter(bu, (SWFCharacter)sh3, SWFBUTTON_DOWN );
+ SWFButtonRecord_setDepth(br, 1);
+
+ /* Higher depth character is intentionally added before lower depth one
*/
+ br = SWFButton_addCharacter(bu, (SWFCharacter)sh4a, SWFBUTTON_OVER );
+ SWFButtonRecord_setDepth(br, 2);
+ br = SWFButton_addCharacter(bu, (SWFCharacter)sh4, SWFBUTTON_OVER );
+ SWFButtonRecord_setDepth(br, 1);
SWFButton_addAction(bu, compileSWFActionCode(
"_root.msg='MouseOut';"
"_root.note('SWFBUTTON_MOUSEOUT');"
+ "_root.check_equals(_root.printBounds(getBounds()),
'-0.05,-0.05 40.05,40.05');"
// Target of button action is the button's parent sprite
"_root.check_equals(_target, '/square1');"
"setTarget('/');"
@@ -112,6 +154,7 @@
SWFButton_addAction(bu, compileSWFActionCode(
"_root.msg='MouseOver';"
"_root.note('SWFBUTTON_MOUSEOVER');"
+ "_root.check_equals(_root.printBounds(getBounds()),
'-0.05,-0.05 40.05,40.05');"
// Target of button action is the button's parent sprite
"_root.check_equals(_target, '/square1');"
"setTarget('/');"
@@ -121,7 +164,8 @@
SWFButton_addAction(bu, compileSWFActionCode(
"_root.msg='MouseDown';"
"_root.note('SWFBUTTON_MOUSEDOWN');"
- // Target (and name) of button action is the button's parent
sprite
+ "_root.check_equals(_root.printBounds(getBounds()),
'-0.05,-0.05 40.05,40.05');"
+ /* Target (and name) of button action is the button's parent
sprite */
"_root.check_equals(_target, '/square1');"
"_root.check_equals(_name, 'square1');"
"setTarget('/');"
@@ -133,17 +177,19 @@
SWFButton_addAction(bu, compileSWFActionCode(
"_root.msg='MouseUp';"
"_root.note('SWFBUTTON_MOUSEUP');"
- // Target of button action is the button's parent sprite
+ "_root.check_equals(_root.printBounds(getBounds()),
'-0.05,-0.05 40.05,40.05');"
+ /* Target of button action is the button's parent sprite */
"_root.check_equals(_target, '/square1');"
"setTarget('/');"
"_root.check_equals(_target, '/');"
), SWFBUTTON_MOUSEUP);
+ /* SWFBUTTON_MOUSEUPOUTSIDE *should* be invoked !! */
SWFButton_addAction(bu, compileSWFActionCode(
"_root.msg='MouseUpOutside';"
"_root.note('SWFBUTTON_MOUSEUPOUTSIDE');"
- "_root.check(!'SWFBUTTON_MOUSEUPOUTSIDE should never be
invoked?');"
- // Target of button action is the button's parent sprite
+ "_root.check_equals(_root.printBounds(getBounds()),
'-0.05,-0.05 40.05,40.05');"
+ /* Target of button action is the button's parent sprite */
"_root.check_equals(_target, '/square1');"
"_root.check_equals(_name, 'square1');"
"setTarget('/');"
@@ -248,6 +294,12 @@
SWFDisplayItem_setName(it, "square1");
SWFDisplayItem_setDepth(it, 2);
+ add_actions(mo,
+ "function printBounds(b) {"
+ " return
''+Math.round(b.xMin*100)/100+','+Math.round(b.yMin*100)/100+'
'+Math.round(b.xMax*100)/100+','+Math.round(b.yMax*100)/100;"
+ "}"
+ );
+
//
// Mouse pointer events
//
@@ -333,7 +385,9 @@
/*****************************************************
*
- * On second frame, add a shape at lower depth
+ * On second frame, add a shape at lower depth,
+ * and check bounds of square1
+ *
*
*****************************************************/
@@ -342,6 +396,8 @@
SWFDisplayItem itsh = SWFMovie_add(mo, (SWFBlock)sh);
SWFDisplayItem_setDepth(itsh, 1);
+ check_equals(mo, "printBounds(square1.getBounds())",
"'-0.05,-0.05 40.05,40.05'");
+
SWFMovie_nextFrame(mo); /* showFrame */
}
@@ -362,7 +418,7 @@
/*****************************************************
*
- * On third frame, add a shape at higher depth
+ * On fourth frame, disable the button
*
*****************************************************/
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/12
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/15
- [Gnash-commit] gnash ChangeLog server/button_character_instanc...,
Sandro Santilli <=
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/15
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/16
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/18
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/18
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/18
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/18
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/19
- [Gnash-commit] gnash ChangeLog server/button_character_instanc..., Sandro Santilli, 2008/04/19