[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/character.h server/edit_...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/character.h server/edit_... |
Date: |
Wed, 18 Apr 2007 13:24:45 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/04/18 13:24:44
Modified files:
. : ChangeLog
server : character.h edit_text_character.cpp
edit_text_character.h generic_character.cpp
generic_character.h sprite_instance.cpp
sprite_instance.h
server/parser : character_def.h
testsuite/misc-ming.all: duplicate_movie_clip_test.c
loadMovieTestRunner.cpp
Log message:
* server/matrix.{cpp,h}: add transform_by_inverse(point&).
* server/character.h: add pointInBounds, pointInShape() and
pointInVisibleShape() new methods; document
get_topmost_mouse_entity.
* server/edit_text_character.{h,cpp}: implement pointInShape.
* server/generic_character.{h,cpp}: implement pointInShape.
* server/sprite_instance.{h,cpp}: implement pointInShape
and pointInVisibleShape; fix get_topmost_mouse_entity
implementation.
* server/parser/character_def.h: document point_test_local.
* testsuite/misc-ming.all/duplicate_movie_clip_test.c: don't
expect a failure.
* testsuite/misc-ming.all/loadMovieTestRunner.cpp: add two
small tests checking that the new two small buttons
are clickable. Needs more tests actually clicking those
buttons.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2907&r2=1.2908
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.57&r2=1.58
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/generic_character.cpp?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/generic_character.h?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.246&r2=1.247
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.98&r2=1.99
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/character_def.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/duplicate_movie_clip_test.c?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/loadMovieTestRunner.cpp?cvsroot=gnash&r1=1.6&r2=1.7
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2907
retrieving revision 1.2908
diff -u -b -r1.2907 -r1.2908
--- ChangeLog 18 Apr 2007 12:39:18 -0000 1.2907
+++ ChangeLog 18 Apr 2007 13:24:44 -0000 1.2908
@@ -1,6 +1,21 @@
2007-04-18 Sandro Santilli <address@hidden>
* server/matrix.{cpp,h}: add transform_by_inverse(point&).
+ * server/character.h: add pointInBounds, pointInShape() and
+ pointInVisibleShape() new methods; document
+ get_topmost_mouse_entity.
+ * server/edit_text_character.{h,cpp}: implement pointInShape.
+ * server/generic_character.{h,cpp}: implement pointInShape.
+ * server/sprite_instance.{h,cpp}: implement pointInShape
+ and pointInVisibleShape; fix get_topmost_mouse_entity
+ implementation.
+ * server/parser/character_def.h: document point_test_local.
+ * testsuite/misc-ming.all/duplicate_movie_clip_test.c: don't
+ expect a failure.
+ * testsuite/misc-ming.all/loadMovieTestRunner.cpp: add two
+ small tests checking that the new two small buttons
+ are clickable. Needs more tests actually clicking those
+ buttons.
2007-04-18 John Gilmore <address@hidden>
Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- server/character.h 12 Apr 2007 16:29:14 -0000 1.67
+++ server/character.h 18 Apr 2007 13:24:44 -0000 1.68
@@ -18,7 +18,7 @@
//
//
-/* $Id: character.h,v 1.67 2007/04/12 16:29:14 strk Exp $ */
+/* $Id: character.h,v 1.68 2007/04/18 13:24:44 strk Exp $ */
#ifndef GNASH_CHARACTER_H
#define GNASH_CHARACTER_H
@@ -463,6 +463,50 @@
return geometry::Range2d<float>(geometry::nullRange);
}
+ /// Return true if the given point falls in this character's bounds
+ //
+ /// Point coordinates are in world TWIPS
+ ///
+ bool pointInBounds(float x, float y) const
+ {
+ geometry::Range2d<float> bounds = getBounds();
+ matrix wm = get_world_matrix();
+ wm.transform(bounds);
+ return bounds.contains(x, y);
+ }
+
+ /// Return true if the given point falls in this character's shape
+ //
+ /// Point coordinates are in world TWIPS
+ ///
+ /// The default implementation warns about a missing
+ /// override and invokes pointInBounds().
+ ///
+ ///
+ virtual bool pointInShape(float x, float y) const
+ {
+ log_error("Character %s did not override pointInShape() - using
pointInBounds() instead", typeid(*this).name());
+ return pointInBounds(x, y);
+ }
+
+ /// Return true if the given point falls in this character's visible
shape
+ //
+ /// Point coordinates are in world TWIPS
+ ///
+ /// The default implementation returns false if the character is
+ /// not visible, calling pointInBounds() otherwise.
+ ///
+ /// Note that this is good for simple characters but needs
+ /// to be overridden for characters with childs. When a
+ /// character has childs it must take into account the case
+ /// in which some childs are visible and some are not.
+ ///
+ virtual bool pointInVisibleShape(float x, float y) const
+ {
+ if ( get_visible() ) return pointInShape(x, y);
+ else return false;
+ }
+
/// Return the "relative" root of this character
//
/// The "relative" is the movie_instance created by
@@ -581,10 +625,13 @@
}
+ // TODO: why is this virtual ??
virtual void set_visible(bool visible) {
if (m_visible!=visible) set_invalidated();
m_visible = visible;
}
+
+ // TODO: why is this virtual ??
virtual bool get_visible() const { return m_visible; }
virtual void set_display_callback(void (*callback)(void*), void*
user_ptr)
@@ -647,6 +694,30 @@
on_event(id);
}
+ /// \brief
+ /// Return the topmost entity covering the given point
+ /// and enabled to receive mouse events.
+ //
+ /// Return NULL if no "active" entity is found under the pointer.
+ ///
+ /// Coordinates of the point are given in parent's coordinate space.
+ /// This means that in order to convert the point to the local
coordinate
+ /// space you need to apply an inverse transformation using this
+ /// character matrix. Example:
+ ///
+ /// point p(x,y);
+ /// get_matrix().transform_by_inverse(p);
+ /// -- p is now in local coordinates
+ ///
+ /// Don't blame me for this mess, I'm just trying to document the
existing
+ /// functions ... --strk
+ ///
+ /// @param x
+ /// X ordinate of the pointer, in parent's coordinate space.
+ ///
+ /// @param y
+ /// Y ordinate of the pointer, in parent's coordiante space.
+ ///
virtual character* get_topmost_mouse_entity(float /* x */, float /* y
*/)
{
return NULL;
Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- server/edit_text_character.cpp 18 Apr 2007 09:35:42 -0000 1.57
+++ server/edit_text_character.cpp 18 Apr 2007 13:24:44 -0000 1.58
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: edit_text_character.cpp,v 1.57 2007/04/18 09:35:42 jgilmore Exp $ */
+/* $Id: edit_text_character.cpp,v 1.58 2007/04/18 13:24:44 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -593,11 +593,14 @@
character*
edit_text_character::get_topmost_mouse_entity(float x, float y)
{
+ //log_msg("get_topmost_mouse_entity called on edit_text_character %p,
labeled '%s'", (void*)this, get_text_value());
+
if (get_visible() == false)
{
return NULL;
}
+ // shouldn't this be !can_handle_mouse_event() instead ?
if (m_def->get_no_select())
{
// not selectable, so don't catch mouse events!
@@ -609,7 +612,7 @@
point p;
m.transform_by_inverse(&p, point(x, y));
- const rect def_bounds = m_def->get_bounds();
+ const rect& def_bounds = m_def->get_bounds();
if (def_bounds.point_test(p.m_x, p.m_y))
{
return this;
@@ -1337,6 +1340,16 @@
global.init_member("TextField", cl.get());
}
+bool
+edit_text_character::pointInShape(float x, float y) const
+{
+ matrix wm = get_world_matrix();
+ point lp(x, y);
+ wm.transform_by_inverse(lp);
+ const rect& def_bounds = m_def->get_bounds();
+ return def_bounds.point_test(lp.m_x, lp.m_y);
+}
+
} // namespace gnash
Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/edit_text_character.h 12 Apr 2007 11:35:30 -0000 1.28
+++ server/edit_text_character.h 18 Apr 2007 13:24:44 -0000 1.29
@@ -52,15 +52,17 @@
~edit_text_character();
- virtual bool can_handle_mouse_event() const { return true; }
- virtual character* get_topmost_mouse_entity(float x, float y);
+ // TODO: should this return !m_def->get_no_select() ?
+ bool can_handle_mouse_event() const { return true; }
- virtual bool wantsInstanceName()
+ character* get_topmost_mouse_entity(float x, float y);
+
+ bool wantsInstanceName()
{
return true; // text fields can be referenced
}
- virtual bool on_event(const event_id& id);
+ bool on_event(const event_id& id);
const char* get_variable_name() const
{
@@ -76,10 +78,10 @@
void set_variable_name(const std::string& newname);
/// Set our text to the given string.
- virtual void set_text_value(const char* new_text);
+ void set_text_value(const char* new_text);
/// Return value of our text.
- virtual const char* get_text_value() const;
+ const char* get_text_value() const;
/// We have a "text" member.
void set_member(const std::string& name, const as_value& val);
@@ -96,6 +98,9 @@
return m_def->get_bounds().getRange();
}
+ // See dox in character.h
+ bool pointInShape(float x, float y) const;
+
private:
/// The actual text
Index: server/generic_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/generic_character.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/generic_character.cpp 18 Apr 2007 09:35:42 -0000 1.5
+++ server/generic_character.cpp 18 Apr 2007 13:24:44 -0000 1.6
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: generic_character.cpp,v 1.5 2007/04/18 09:35:42 jgilmore Exp $ */
+/* $Id: generic_character.cpp,v 1.6 2007/04/18 13:24:44 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -49,6 +49,15 @@
assert(0); // TO BE IMPLEMENTED!!!!!
}
+bool
+generic_character::pointInShape(float x, float y) const
+{
+ matrix wm = get_world_matrix();
+ point lp(x, y);
+ wm.transform_by_inverse(lp);
+ return m_def->point_test_local(lp.m_x, lp.m_y);
+}
+
character*
generic_character::get_topmost_mouse_entity(float x, float y)
{
Index: server/generic_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/generic_character.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- server/generic_character.h 12 Apr 2007 11:35:30 -0000 1.21
+++ server/generic_character.h 18 Apr 2007 13:24:44 -0000 1.22
@@ -77,6 +77,9 @@
virtual character* get_topmost_mouse_entity(float x, float y);
+ // See dox in character.h
+ virtual bool pointInShape(float x, float y) const;
+
/// \brief
/// Return the character definition from which this
/// instance derive.
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.246
retrieving revision 1.247
diff -u -b -r1.246 -r1.247
--- server/sprite_instance.cpp 18 Apr 2007 11:00:29 -0000 1.246
+++ server/sprite_instance.cpp 18 Apr 2007 13:24:44 -0000 1.247
@@ -2820,6 +2820,90 @@
};
+/// Find the first character whose shape contain the point
+//
+/// Point coordinates in world TWIPS
+///
+class ShapeContainerFinder {
+
+ bool _found;
+ float _x;
+ float _y;
+
+public:
+
+ ShapeContainerFinder(float x, float y)
+ :
+ _found(false),
+ _x(x),
+ _y(y)
+ {}
+
+ bool operator() (character* ch)
+ {
+ if ( ch->pointInShape(_x, _y) )
+ {
+ _found = true;
+ return false;
+ }
+ else return true;
+ }
+
+ bool hitFound() { return _found; }
+
+};
+
+/// Find the first visible character whose shape contain the point
+//
+/// Point coordinates in world TWIPS
+///
+class VisibleShapeContainerFinder {
+
+ bool _found;
+ float _x;
+ float _y;
+
+public:
+
+ VisibleShapeContainerFinder(float x, float y)
+ :
+ _found(false),
+ _x(x),
+ _y(y)
+ {}
+
+ bool operator() (character* ch)
+ {
+ if ( ch->get_visible() && ch->pointInShape(_x, _y) )
+ {
+ _found = true;
+ return false;
+ }
+ else return true;
+ }
+
+ bool hitFound() { return _found; }
+
+};
+
+bool
+sprite_instance::pointInShape(float x, float y) const
+{
+ ShapeContainerFinder finder(x, y);
+ const_cast<DisplayList&>(m_display_list).visitBackward(finder);
+ if ( finder.hitFound() ) return true;
+ return _drawable_inst->pointInShape(x, y);
+}
+
+bool
+sprite_instance::pointInVisibleShape(float x, float y) const
+{
+ VisibleShapeContainerFinder finder(x, y);
+ const_cast<DisplayList&>(m_display_list).visitBackward(finder);
+ if ( finder.hitFound() ) return true;
+ return _drawable_inst->pointInVisibleShape(x, y);
+}
+
character*
sprite_instance::get_topmost_mouse_entity(float x, float y)
{
@@ -2830,6 +2914,18 @@
return NULL;
}
+ if ( can_handle_mouse_event() )
+ {
+ // point is in parent's space,
+ // we need to convert it in world space
+ matrix parent_world_matrix = get_parent()->get_world_matrix();
+ point wp(x,y);
+ parent_world_matrix.transform(wp);
+ if ( pointInVisibleShape(wp.m_x, wp.m_y) ) return this;
+ else return NULL;
+ }
+
+
matrix m = get_matrix();
point p;
m.transform_by_inverse(&p, point(x, y));
@@ -2842,15 +2938,7 @@
ch = _drawable_inst->get_topmost_mouse_entity(p.m_x, p.m_y);
}
- if ( ch && can_handle_mouse_event() )
- {
- return this;
- }
- else
- {
return ch; // might be NULL
- }
-
}
bool
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -b -r1.98 -r1.99
--- server/sprite_instance.h 16 Apr 2007 18:23:06 -0000 1.98
+++ server/sprite_instance.h 18 Apr 2007 13:24:44 -0000 1.99
@@ -17,7 +17,7 @@
//
//
-/* $Id: sprite_instance.h,v 1.98 2007/04/16 18:23:06 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.99 2007/04/18 13:24:44 strk Exp $ */
// Stateful live Sprite instance
@@ -139,6 +139,12 @@
/// Get the composite bounds of all component drawing elements
geometry::Range2d<float> getBounds() const;
+ // See dox in character.h
+ bool pointInShape(float x, float y) const;
+
+ // See dox in character.h
+ bool pointInVisibleShape(float x, float y) const;
+
size_t get_current_frame() const
{
return m_current_frame;
Index: server/parser/character_def.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/character_def.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/parser/character_def.h 11 Nov 2006 22:44:54 -0000 1.9
+++ server/parser/character_def.h 18 Apr 2007 13:24:44 -0000 1.10
@@ -66,6 +66,10 @@
{
}
+ /// Return true if the specified point is on the interior of our shape.
+ //
+ /// Point coordinates are local coords (TWIPS)
+ ///
virtual bool point_test_local(float /*x*/, float /*y*/)
{
return false;
Index: testsuite/misc-ming.all/duplicate_movie_clip_test.c
===================================================================
RCS file:
/sources/gnash/gnash/testsuite/misc-ming.all/duplicate_movie_clip_test.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- testsuite/misc-ming.all/duplicate_movie_clip_test.c 18 Apr 2007 08:13:45
-0000 1.1
+++ testsuite/misc-ming.all/duplicate_movie_clip_test.c 18 Apr 2007 13:24:44
-0000 1.2
@@ -76,7 +76,7 @@
check_equals(mo, "typeof(mc.onLoad)", "'function'");
check_equals(mo, "mc.getDepth()", "-16374");
check_equals(mo, "dup.prop1", "undefined"); // user defined property will
not be duplicated
- xcheck_equals(mo, "typeof(dup.onLoad)", "'undefined'"); //user defined event
will not be duplicated
+ check_equals(mo, "typeof(dup.onLoad)", "'undefined'"); //user defined event
will not be duplicated
check_equals(mo, "dup.getDepth()", "1");
add_actions(mo, " _root.totals(); stop(); ");
SWFMovie_nextFrame(mo);
Index: testsuite/misc-ming.all/loadMovieTestRunner.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/loadMovieTestRunner.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- testsuite/misc-ming.all/loadMovieTestRunner.cpp 17 Apr 2007 20:53:29
-0000 1.6
+++ testsuite/misc-ming.all/loadMovieTestRunner.cpp 18 Apr 2007 13:24:44
-0000 1.7
@@ -101,5 +101,15 @@
coverart = coverartch->to_movie();
check_equals(coverart->get_movie_definition()->get_url(),
offspringURL.str());
+ //---------------------------------------------------
+ // Now check that the active movieclip "buttons" work
+ //---------------------------------------------------
+
+ tester.movePointerTo(73, 204); // the "Scribble" button
+ check(tester.isMouseOverMouseEntity());
+
+ tester.movePointerTo(63, 227); // the "clear" button
+ check(tester.isMouseOverMouseEntity());
+
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/character.h server/edit_...,
Sandro Santilli <=