[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/character.cpp server/cha...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/character.cpp server/cha... |
Date: |
Sun, 23 Dec 2007 22:29:57 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/12/23 22:29:57
Modified files:
. : ChangeLog
server : character.cpp character.h dlist.h
movie_root.cpp movie_root.h sprite_instance.cpp
sprite_instance.h
testsuite/misc-ming.all: DragDropTest.as
testsuite/misc-mtasc.all: level5.as level99.as
Log message:
* server/dlist.h: const version of visitBackward.
* server/character.h: add virtual findDropTarget method.
* server/character.cpp (computeTargetPath): include _levelX
prefix
when topmost movie is not _level0.
* server/movie_root.{cpp,h}: if a character is being dragged
find it's current _droptarget on mouse move.
* server/sprite_instance.{cpp,h}: implement findDropTarget.
* testsuite/misc-ming.all/DragDropTest.as: no more failures.
* testsuite/misc-mtasc.all/: level5.as, level99.as:
add test for _target member of clips inside _level#.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5246&r2=1.5247
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.70&r2=1.71
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.117&r2=1.118
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.h?cvsroot=gnash&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.138&r2=1.139
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.97&r2=1.98
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.418&r2=1.419
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.160&r2=1.161
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DragDropTest.as?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-mtasc.all/level5.as?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-mtasc.all/level99.as?cvsroot=gnash&r1=1.8&r2=1.9
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5246
retrieving revision 1.5247
diff -u -b -r1.5246 -r1.5247
--- ChangeLog 23 Dec 2007 22:24:50 -0000 1.5246
+++ ChangeLog 23 Dec 2007 22:29:56 -0000 1.5247
@@ -1,5 +1,18 @@
2007-12-23 Sandro Santilli <address@hidden>
+ * server/dlist.h: const version of visitBackward.
+ * server/character.h: add virtual findDropTarget method.
+ * server/character.cpp (computeTargetPath): include _levelX prefix
+ when topmost movie is not _level0.
+ * server/movie_root.{cpp,h}: if a character is being dragged
+ find it's current _droptarget on mouse move.
+ * server/sprite_instance.{cpp,h}: implement findDropTarget.
+ * testsuite/misc-ming.all/DragDropTest.as: no more failures.
+ * testsuite/misc-mtasc.all/: level5.as, level99.as:
+ add test for _target member of clips inside _level#.
+
+2007-12-23 Sandro Santilli <address@hidden>
+
* testsuite/actionscript.all/MovieClipLoader.as: stop() before
invoking the tests chaing. This is to workaround bogus blocking
MovieClipLoader.loadClip of Gnash.
Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- server/character.cpp 18 Dec 2007 21:28:58 -0000 1.70
+++ server/character.cpp 23 Dec 2007 22:29:56 -0000 1.71
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: character.cpp,v 1.70 2007/12/18 21:28:58 strk Exp $ */
+/* $Id: character.cpp,v 1.71 2007/12/23 22:29:56 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -722,6 +722,7 @@
Path path;
// Build parents stack
+ const character* topLevel = 0;
const character* ch = this;
for (;;)
{
@@ -732,6 +733,7 @@
{
// it is completely legal to set root's _name
//assert(ch->get_name().empty());
+ topLevel = ch;
break;
}
@@ -739,6 +741,8 @@
ch = parent;
}
+ assert(topLevel);
+
if ( path.empty() )
{
if ( _vm.getRoot().getRootMovie() == this ) return "/";
@@ -749,6 +753,12 @@
// Build the target string from the parents stack
std::string target;
+ if ( topLevel != _vm.getRoot().getRootMovie() )
+ {
+ std::stringstream ss;
+ ss << "_level" <<
topLevel->get_depth()-character::staticDepthOffset;
+ target = ss.str();
+ }
for ( Path::reverse_iterator
it=path.rbegin(), itEnd=path.rend();
it != itEnd;
Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -b -r1.117 -r1.118
--- server/character.h 22 Dec 2007 00:24:41 -0000 1.117
+++ server/character.h 23 Dec 2007 22:29:56 -0000 1.118
@@ -19,7 +19,7 @@
//
//
-/* $Id: character.h,v 1.117 2007/12/22 00:24:41 strk Exp $ */
+/* $Id: character.h,v 1.118 2007/12/23 22:29:56 strk Exp $ */
#ifndef GNASH_CHARACTER_H
#define GNASH_CHARACTER_H
@@ -955,6 +955,21 @@
return NULL;
}
+ /// Find highest depth character whose shape contains the given
+ /// point and is not the character being dragged or any of its childs.
+ //
+ /// Point coordinates in global twips.
+ ///
+ virtual const character* findDropTarget(float x, float y, character*
dragging) const
+ {
+ if ( this != dragging && get_visible()
+ && pointInVisibleShape(x, y) )
+ {
+ return this;
+ }
+ else return 0;
+ }
+
/// Returns true when the object (type) should get a instance name even
/// if none is provided manually.
virtual bool wantsInstanceName()
Index: server/dlist.h
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- server/dlist.h 7 Dec 2007 01:33:26 -0000 1.61
+++ server/dlist.h 23 Dec 2007 22:29:56 -0000 1.62
@@ -307,6 +307,8 @@
///
template <class V>
inline void visitBackward(V& visitor);
+ template <class V>
+ inline void visitBackward(V& visitor) const;
/// \brief
/// Visit each and all character in the list.
@@ -443,6 +445,19 @@
template <class V>
void
+DisplayList::visitBackward(V& visitor) const
+{
+ for (const_reverse_iterator it = _charsByDepth.rbegin(),
+ itEnd = _charsByDepth.rend();
+ it != itEnd; ++it)
+ {
+ const DisplayItem& di = *it;
+ if ( ! visitor(di.get()) ) break;
+ }
+}
+
+template <class V>
+void
DisplayList::visitAll(V& visitor)
{
for (iterator it = _charsByDepth.begin(),
Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -b -r1.138 -r1.139
--- server/movie_root.cpp 18 Dec 2007 00:07:11 -0000 1.138
+++ server/movie_root.cpp 23 Dec 2007 22:29:56 -0000 1.139
@@ -750,10 +750,31 @@
assert(testInvariant());
+ float x = PIXELS_TO_TWIPS(m_mouse_x);
+ float y = PIXELS_TO_TWIPS(m_mouse_y);
+
// Generate a mouse event
- m_mouse_button_state.m_topmost_entity =
getTopmostMouseEntity(PIXELS_TO_TWIPS(m_mouse_x), PIXELS_TO_TWIPS(m_mouse_y));
+ m_mouse_button_state.m_topmost_entity = getTopmostMouseEntity(x, y);
m_mouse_button_state.m_mouse_button_state_current = (m_mouse_buttons & 1);
+ // Set _droptarget if dragging a sprite
+ sprite_instance* dragging = 0;
+ character* draggingChar = m_drag_state.getCharacter();
+ if ( draggingChar ) dragging = draggingChar->to_movie();
+ if ( dragging )
+ {
+ // TODO: optimize making findDropTarget and getTopmostMouseEntity
+ // use a single scan.
+ const character* dropChar = findDropTarget(x, y, dragging);
+ if ( dropChar )
+ {
+ // TODO: use target of closest script character containing this
+ dragging->setDropTarget(dropChar->getTargetPath());
+ }
+ else dragging->setDropTarget("");
+
+ }
+
bool need_redraw = generate_mouse_button_events(&m_mouse_button_state);
// FIXME: need_redraw might also depend on actual
@@ -1445,6 +1466,17 @@
return NULL;
}
+const character *
+movie_root::findDropTarget(float x, float y, character* dragging) const
+{
+ for (Levels::const_reverse_iterator i=_movies.rbegin(),
e=_movies.rend(); i!=e; ++i)
+ {
+ const character* ret = i->second->findDropTarget(x, y,
dragging);
+ if ( ret ) return ret;
+ }
+ return NULL;
+}
+
void
movie_root::cleanupDisplayList()
{
Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -b -r1.97 -r1.98
--- server/movie_root.h 18 Dec 2007 00:07:11 -0000 1.97
+++ server/movie_root.h 23 Dec 2007 22:29:56 -0000 1.98
@@ -15,7 +15,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.97 2007/12/18 00:07:11 strk Exp $ */
+/* $Id: movie_root.h,v 1.98 2007/12/23 22:29:56 strk Exp $ */
/// \page events_handling Handling of user events
///
@@ -846,6 +846,8 @@
return (_processingActionLevel < apSIZE);
}
+ const character* findDropTarget(float x, float y, character* dragging)
const;
+
};
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.418
retrieving revision 1.419
diff -u -b -r1.418 -r1.419
--- server/sprite_instance.cpp 21 Dec 2007 12:26:26 -0000 1.418
+++ server/sprite_instance.cpp 23 Dec 2007 22:29:57 -0000 1.419
@@ -1410,6 +1410,8 @@
sprite_droptarget_getset(const fn_call& fn)
{
boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
+
+ return ptr->getDropTarget();
UNUSED(ptr);
static bool warned = false;
@@ -3084,6 +3086,72 @@
return ch; // might be NULL
}
+/// Find the first visible character whose shape contain the point
+/// and is not the character being dragged or any of its childs
+//
+/// Point coordinates in world TWIPS
+///
+class DropTargetFinder {
+
+ float _x;
+ float _y;
+ character* _dragging;
+ const character* _dropch;
+
+public:
+
+ DropTargetFinder(float x, float y, character* dragging)
+ :
+ _x(x),
+ _y(y),
+ _dragging(dragging),
+ _dropch(0)
+ {}
+
+ bool operator() (const character* ch)
+ {
+ const character* dropChar = ch->findDropTarget(_x, _y,
_dragging);
+ if ( dropChar )
+ {
+ _dropch = dropChar;
+ return false;
+ }
+ else return true;
+ }
+
+ const character* getDropChar() const { return _dropch; }
+};
+
+const character*
+sprite_instance::findDropTarget(float x, float y, character* dragging) const
+{
+ //GNASH_REPORT_FUNCTION;
+
+ if ( this == dragging ) return 0; // not here...
+
+ if ( ! get_visible() ) return 0; // isn't me !
+
+ DropTargetFinder finder(x, y, dragging);
+ m_display_list.visitBackward(finder);
+
+ // does it hit any child ?
+ const character* ch = finder.getDropChar();
+ if ( ch )
+ {
+ // TODO: find closest actionscript referenceable container
+ // (possibly itself)
+ return ch;
+ }
+
+ // does it hit us ?
+ if ( _drawable_inst->pointInVisibleShape(x, y) )
+ {
+ return this;
+ }
+
+ return NULL;
+}
+
bool
sprite_instance::can_handle_mouse_event() const
{
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -b -r1.160 -r1.161
--- server/sprite_instance.h 19 Dec 2007 20:40:31 -0000 1.160
+++ server/sprite_instance.h 23 Dec 2007 22:29:57 -0000 1.161
@@ -239,6 +239,19 @@
/// none. Coords are in parent's frame.
virtual character* get_topmost_mouse_entity(float x, float y);
+ // see dox in character.h
+ const character* findDropTarget(float x, float y, character* dragging)
const;
+
+ void setDropTarget(const std::string& tgt)
+ {
+ _droptarget = tgt;
+ }
+
+ const std::string& getDropTarget() const
+ {
+ return _droptarget;
+ }
+
virtual bool wantsInstanceName()
{
return true; // sprites can be referenced
@@ -1007,6 +1020,8 @@
cxform _userCxform;
+ std::string _droptarget;
+
protected:
void place_character(character* ch, int depth,
Index: testsuite/misc-ming.all/DragDropTest.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/DragDropTest.as,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- testsuite/misc-ming.all/DragDropTest.as 21 Dec 2007 23:43:39 -0000
1.4
+++ testsuite/misc-ming.all/DragDropTest.as 23 Dec 2007 22:29:57 -0000
1.5
@@ -8,7 +8,7 @@
//
//
-rcsid="$Id: DragDropTest.as,v 1.4 2007/12/21 23:43:39 strk Exp $";
+rcsid="$Id: DragDropTest.as,v 1.5 2007/12/23 22:29:57 strk Exp $";
#define info _root.note
#define note _root.note
@@ -208,7 +208,7 @@
note("2. Click on the FIRST RED circle.");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget, "/target10");
+ check_equals(_root.draggable50._droptarget, "/target10");
test3();
};
};
@@ -218,7 +218,7 @@
note("3. Click on the FIRST GREEN circle.");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget, "/target20");
+ check_equals(_root.draggable50._droptarget, "/target20");
test4();
};
};
@@ -228,7 +228,7 @@
note("4. Click on the FIRST BLUE circle.");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget, "/target100");
+ check_equals(_root.draggable50._droptarget, "/target100");
test5();
};
};
@@ -238,7 +238,7 @@
note("5. Click on the SECOND RED circle.");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget,
"_level50/target10");
+ check_equals(_root.draggable50._droptarget,
"_level50/target10");
test6();
};
};
@@ -248,7 +248,7 @@
note("6. Click on the SECOND GREEN circle.");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget,
"_level50/target20");
+ check_equals(_root.draggable50._droptarget,
"_level50/target20");
test7();
};
};
@@ -258,7 +258,7 @@
note("7. Click on the SECOND BLUE circle.");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget,
"_level50/target100");
+ check_equals(_root.draggable50._droptarget,
"_level50/target100");
test8();
};
};
@@ -268,7 +268,7 @@
note("8. Click on the THIRD RED circle.");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget,
"/loadedTarget/target10");
+ check_equals(_root.draggable50._droptarget,
"/loadedTarget/target10");
test9();
};
};
@@ -278,7 +278,7 @@
note("9. Click on the THIRD GREEN circle.");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget,
"/loadedTarget/target20");
+ check_equals(_root.draggable50._droptarget,
"/loadedTarget/target20");
test10();
};
};
@@ -288,7 +288,7 @@
note("10. Click on the THIRD BLUE circle.");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget,
"/loadedTarget/target100");
+ check_equals(_root.draggable50._droptarget,
"/loadedTarget/target100");
// move the draggable over the first green square
_root.draggable50._x = _root.draggable50._y = 50;
@@ -305,8 +305,8 @@
note("11. Click ANYWHERE OUT of the THIRD BLUE circle (on another
circle makes a better test)");
_root.onMouseDown = function()
{
- xcheck_equals(_root.draggable50._droptarget,
"/loadedTarget/target100");
- endOfTest();
+ check_equals(_root.draggable50._droptarget,
"/loadedTarget/target100");
+ endOfTest(); // TODO: test that moving the draggable out of any
drawing changes _droptarget to the empty string
};
};
Index: testsuite/misc-mtasc.all/level5.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-mtasc.all/level5.as,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- testsuite/misc-mtasc.all/level5.as 30 Nov 2007 11:26:05 -0000 1.8
+++ testsuite/misc-mtasc.all/level5.as 23 Dec 2007 22:29:57 -0000 1.9
@@ -73,6 +73,8 @@
endFill();
};
+ check_equals(mc.ch._target, "_level5/ch");
+
// load yet another swf
getURL("level99.swf","_level"+99);
}
Index: testsuite/misc-mtasc.all/level99.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-mtasc.all/level99.as,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- testsuite/misc-mtasc.all/level99.as 30 Nov 2007 11:26:05 -0000 1.8
+++ testsuite/misc-mtasc.all/level99.as 23 Dec 2007 22:29:57 -0000 1.9
@@ -118,7 +118,7 @@
// - sane swapping between to levels,
// - swapping & removing _level0
//
- check_totals(43);
+ check_totals(44);
Dejagnu.done();
delete this.onEnterFrame;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/character.cpp server/cha...,
Sandro Santilli <=