[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, 28 Nov 2006 15:59:30 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/11/28 15:59:30
Modified files:
. : ChangeLog
server : button_character_instance.cpp
button_character_instance.h character.cpp
character.h movie_root.cpp movie_root.h
rect.cpp rect.h sprite_instance.cpp
sprite_instance.h
server/vm : ASHandlers.cpp
Log message:
* server/button_character_instance.{cpp,h}:
Don't override get_mouse_state with an equivalent
implementation.
* server/rect.{cpp,h}: Add clamp(point) method.
* server/: character.{cpp,h}, movie_root.{cpp,h},
sprite_instance.{h,cpp}:
Change signature of get_mouse_state() and get_drag_state()
to use references rather then pointers; Improve
definition of drag_state class to use our rect
class for bounds and to store character in a smart pointer.
* server/vm/ASHandlers.cpp (ActionStartDragMovie):
flip drag boundaries coordinates if given in the wrong
order (fixes bug #18394).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1803&r2=1.1804
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/rect.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/rect.h?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.92&r2=1.93
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.3&r2=1.4
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1803
retrieving revision 1.1804
diff -u -b -r1.1803 -r1.1804
--- ChangeLog 28 Nov 2006 13:02:48 -0000 1.1803
+++ ChangeLog 28 Nov 2006 15:59:30 -0000 1.1804
@@ -1,5 +1,21 @@
2006-11-28 Sandro Santilli <address@hidden>
+ * server/button_character_instance.{cpp,h}:
+ Don't override get_mouse_state with an equivalent
+ implementation.
+ * server/rect.{cpp,h}: Add clamp(point) method.
+ * server/: character.{cpp,h}, movie_root.{cpp,h},
+ sprite_instance.{h,cpp}:
+ Change signature of get_mouse_state() and get_drag_state()
+ to use references rather then pointers; Improve
+ definition of drag_state class to use our rect
+ class for bounds and to store character in a smart pointer.
+ * server/vm/ASHandlers.cpp (ActionStartDragMovie):
+ flip drag boundaries coordinates if given in the wrong
+ order (fixes bug #18394).
+
+2006-11-28 Sandro Santilli <address@hidden>
+
* gui/Player.cpp (load_movie) : don't start loader thread
also for stdin reads. Fixes bug #18393.
* server/: impl.{cpp,h}, parser/movie_def_impl.{cpp,h},
Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/button_character_instance.cpp 24 Nov 2006 10:38:03 -0000
1.18
+++ server/button_character_instance.cpp 28 Nov 2006 15:59:30 -0000
1.19
@@ -532,14 +532,6 @@
}
}
-
-void
-button_character_instance::get_mouse_state(int* x, int* y, int* buttons)
-{
- get_parent()->get_mouse_state(x, y, buttons);
-}
-
-
//
// ActionScript overrides
//
Index: server/button_character_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/button_character_instance.h 21 Nov 2006 00:25:46 -0000 1.6
+++ server/button_character_instance.h 28 Nov 2006 15:59:30 -0000 1.7
@@ -5,7 +5,7 @@
// SWF buttons. Mouse-sensitive update/display, actions, etc.
-/* $Id: button_character_instance.h,v 1.6 2006/11/21 00:25:46 strk Exp $ */
+/* $Id: button_character_instance.h,v 1.7 2006/11/28 15:59:30 strk Exp $ */
#ifndef GNASH_BUTTON_CHARACTER_INSTANCE_H
#define GNASH_BUTTON_CHARACTER_INSTANCE_H
@@ -99,8 +99,6 @@
void restart_characters(int condition);
- virtual void get_mouse_state(int* x, int* y, int* buttons);
-
//
// ActionScript overrides
//
Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/character.cpp 7 Nov 2006 17:16:18 -0000 1.10
+++ server/character.cpp 28 Nov 2006 15:59:30 -0000 1.11
@@ -18,7 +18,7 @@
//
//
-/* $Id: character.cpp,v 1.10 2006/11/07 17:16:18 strk Exp $ */
+/* $Id: character.cpp,v 1.11 2006/11/28 15:59:30 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -34,24 +34,22 @@
character::do_mouse_drag()
{
drag_state st;
- get_drag_state(&st);
- if (this == st.m_character)
+ get_drag_state(st);
+ if ( this == st.getCharacter() )
{
// We're being dragged!
int x, y, buttons;
- get_root_movie()->get_mouse_state(&x, &y, &buttons);
+ get_root_movie()->get_mouse_state(x, y, buttons);
point world_mouse(PIXELS_TO_TWIPS(x), PIXELS_TO_TWIPS(y));
- if (st.m_bound)
+ if ( st.hasBounds() )
{
+ const rect& bounds = st.getBounds();
// Clamp mouse coords within a defined rect.
- world_mouse.m_x =
- fclamp(world_mouse.m_x, st.m_bound_x0, st.m_bound_x1);
- world_mouse.m_y =
- fclamp(world_mouse.m_y, st.m_bound_y0, st.m_bound_y1);
+ bounds.clamp(world_mouse);
}
- if (st.m_lock_center)
+ if (st.isLockCentered())
{
matrix world_mat = get_world_matrix();
point local_mouse;
@@ -107,7 +105,7 @@
}
void
-character::get_drag_state(drag_state* st)
+character::get_drag_state(drag_state& st)
{
assert(m_parent != NULL);
assert(m_parent->get_ref_count() > 0);
@@ -123,7 +121,7 @@
}
void
-character::get_mouse_state(int* x, int* y, int* buttons)
+character::get_mouse_state(int& x, int& y, int& buttons)
{
assert(m_parent != NULL);
assert(m_parent->get_ref_count() > 0);
Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/character.h 23 Nov 2006 16:33:43 -0000 1.29
+++ server/character.h 28 Nov 2006 15:59:30 -0000 1.30
@@ -18,7 +18,7 @@
//
//
-/* $Id: character.h,v 1.29 2006/11/23 16:33:43 strk Exp $ */
+/* $Id: character.h,v 1.30 2006/11/28 15:59:30 strk Exp $ */
#ifndef GNASH_CHARACTER_H
#define GNASH_CHARACTER_H
@@ -63,20 +63,64 @@
class drag_state
{
+
+ bool _hasbounds;
+
+ rect _bounds;
+
+ boost::intrusive_ptr<character> _character;
+
+ bool _lock_centered;
+
public:
- character* m_character;
- bool m_lock_center;
- bool m_bound;
- float m_bound_x0;
- float m_bound_y0;
- float m_bound_x1;
- float m_bound_y1;
+
+ bool isLockCentered() const {
+ return _lock_centered;
+ }
+
+ void setLockCentered(bool lock) {
+ _lock_centered = lock;
+ }
+
+ bool hasBounds() const {
+ return _hasbounds;
+ }
+
+ const rect& getBounds() const {
+ return _bounds;
+ }
+
+ // Initialize the boundaries
+ void setBounds(const rect& bounds) {
+ _bounds = bounds;
+ _hasbounds = true;
+ }
+
+ /// May return NULL !!
+ character* getCharacter() {
+ return _character.get();
+ }
+
+ /// Stores character in an intrusive pointer
+ void setCharacter(character* ch) {
+ _character = ch;
+ }
+
+ /// Reset drag state to its initial condition
+ void reset()
+ {
+ _character = NULL;
+ _hasbounds = false;
+ _bounds.set_null();
+ _lock_centered = false;
+ }
drag_state()
:
- m_character(0), m_lock_center(0), m_bound(0),
- m_bound_x0(0), m_bound_y0(0), m_bound_x1(1),
- m_bound_y1(1)
+ _hasbounds(false),
+ _bounds(),
+ _character(0),
+ _lock_centered(false)
{
}
};
@@ -301,7 +345,11 @@
virtual bool get_accept_anim_moves() const { return true; }
- virtual void get_drag_state(drag_state* st);
+ /// The default implementation calls get_drag_state against
+ /// the character's parent. The final parent (a sprite_instance)
+ /// will delegate the call to it's associated movie_root, which
+ /// does all the work.
+ virtual void get_drag_state(drag_state& st);
virtual void set_visible(bool visible) {
if (m_visible!=visible) set_invalidated();
@@ -325,7 +373,17 @@
}
}
- virtual void get_mouse_state(int* x, int* y, int* buttons);
+ /// Return mouse state in given variables
+ //
+ /// Use this to retrieve the last state of the mouse, as set via
+ /// notify_mouse_state(). Coordinates are in PIXELS, NOT TWIPS.
+ ///
+ /// The default implementation calls get_mouse_state against
+ /// the character's parent. The final parent (a sprite_instance)
+ /// will delegate the call to it's associated movie_root, which
+ /// does all the work.
+ ///
+ virtual void get_mouse_state(int& x, int& y, int& buttons);
// TODO : make protected
const std::map<event_id, as_value>& get_event_handlers() const
Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/movie_root.cpp 21 Nov 2006 00:25:46 -0000 1.28
+++ server/movie_root.cpp 28 Nov 2006 15:59:30 -0000 1.29
@@ -39,6 +39,16 @@
namespace gnash
{
+inline bool
+movie_root::testInvariant() const
+{
+ // TODO: fill this function !
+ assert(m_def);
+
+ return true;
+}
+
+
movie_root::movie_root(movie_def_impl* def)
:
sprite_instance(def, this, NULL, -1),
@@ -59,8 +69,9 @@
m_on_event_xmlsocket_onxml_called(false),
m_on_event_load_progress_called(false),
m_active_input_text(NULL),
- m_time_remainder(0.0f)
- {
+ m_time_remainder(0.0f),
+ m_drag_state()
+{
assert(m_def != NULL);
m_invalidated=true;
@@ -68,10 +79,13 @@
set_display_viewport(0, 0,
(int) m_def->get_width_pixels(),
(int) m_def->get_height_pixels());
+
+ assert(testInvariant());
}
movie_root::~movie_root()
{
+ assert(testInvariant());
assert(m_def != NULL);
m_movie = NULL;
m_def = NULL;
@@ -82,12 +96,14 @@
movie_root::set_root_movie(sprite_instance* root_movie)
{
m_movie = root_movie;
- assert(m_movie != NULL);
+ assert(testInvariant());
}
void
movie_root::set_display_viewport(int x0, int y0, int w, int h)
{
+ assert(testInvariant());
+
m_viewport_x0 = x0;
m_viewport_y0 = y0;
m_viewport_width = w;
@@ -99,11 +115,15 @@
float scale_x = m_viewport_width /
TWIPS_TO_PIXELS(frame_size.width());
float scale_y = m_viewport_height /
TWIPS_TO_PIXELS(frame_size.height());
m_pixel_scale = fmax(scale_x, scale_y);
+
+ assert(testInvariant());
}
bool
movie_root::notify_mouse_moved(int x, int y)
{
+ assert(testInvariant());
+
m_mouse_x = x;
m_mouse_y = y;
return fire_mouse_event();
@@ -113,6 +133,8 @@
bool
movie_root::notify_mouse_clicked(bool mouse_pressed, int button_mask)
{
+ assert(testInvariant());
+
if (mouse_pressed) {
m_mouse_buttons |= button_mask;
} else {
@@ -124,10 +146,14 @@
void
movie_root::notify_mouse_state(int x, int y, int buttons)
{
+ assert(testInvariant());
+
m_mouse_x = x;
m_mouse_y = y;
m_mouse_buttons = buttons;
fire_mouse_event();
+
+ assert(testInvariant());
}
// Return wheter any action triggered by this event requires display redraw.
@@ -311,6 +337,8 @@
{
// GNASH_REPORT_FUNCTION;
+ assert(testInvariant());
+
// Generate a mouse event
m_mouse_button_state.m_topmost_entity =
m_movie->get_topmost_mouse_entity(PIXELS_TO_TWIPS(m_mouse_x),
PIXELS_TO_TWIPS(m_mouse_y));
@@ -321,20 +349,38 @@
}
void
-movie_root::get_mouse_state(int* x, int* y, int* buttons)
+movie_root::get_mouse_state(int& x, int& y, int& buttons)
{
// GNASH_REPORT_FUNCTION;
- assert(x);
- assert(y);
- assert(buttons);
-
// dbglogfile << "X is: " << m_mouse_x << " Y is: " << m_mouse_y
// << " Button is: "
// << m_mouse_buttons << endl;
- *x = m_mouse_x;
- *y = m_mouse_y;
- *buttons = m_mouse_buttons;
+
+ assert(testInvariant());
+
+ x = m_mouse_x;
+ y = m_mouse_y;
+ buttons = m_mouse_buttons;
+
+ assert(testInvariant());
+}
+
+void
+movie_root::get_drag_state(drag_state& st)
+{
+ assert(testInvariant());
+
+ st = m_drag_state;
+
+ assert(testInvariant());
+}
+
+void
+movie_root::set_drag_state(const drag_state& st)
+{
+ m_drag_state = st;
+ assert(testInvariant());
}
#if 0 // see comments in movie_root.h
@@ -357,6 +403,7 @@
int
movie_root::add_interval_timer(void *timer)
{
+ assert(testInvariant());
Timer *ptr = static_cast<Timer *>(timer);
m_interval_timers.push_back(ptr);
@@ -368,6 +415,7 @@
{
m_interval_timers.erase(m_interval_timers.begin() + x-1);
//m_interval_timers[x]->clearInterval();
+ assert(testInvariant());
}
void
@@ -440,12 +488,14 @@
}
m_time_remainder = fmod(m_time_remainder, frame_time);
+ assert(testInvariant());
}
void
movie_root::display()
{
+ assert(testInvariant());
clear_invalidated();
@@ -476,6 +526,8 @@
bool
movie_root::goto_labeled_frame(const char* label)
{
+ assert(testInvariant());
+
log_error("movie_root::goto_labeled_frame called, guess we should
delegate to m_movie instead! Please report url of the movie triggering this
message so that developer can confirm the change will work fine.");
size_t target_frame;
@@ -497,6 +549,7 @@
movie_root::call_method(const char* method_name,
const char* method_arg_fmt, ...)
{
+ assert(testInvariant());
assert(m_movie != NULL);
va_list args;
@@ -513,6 +566,7 @@
const char* method_arg_fmt, va_list args)
{
assert(m_movie != NULL);
+ assert(testInvariant());
return m_movie->call_method_args(method_name, method_arg_fmt, args);
}
@@ -532,6 +586,8 @@
character* ch = (character*) listener.get();
ch->on_event(event_id(event_id::KEY_PRESS, (key::code) k));
}
+
+ assert(testInvariant());
}
void movie_root::add_keypress_listener(as_object* listener)
@@ -547,6 +603,8 @@
}
}
m_keypress_listeners.push_back(listener);
+
+ assert(testInvariant());
}
void movie_root::remove_keypress_listener(as_object* listener)
@@ -561,11 +619,13 @@
}
iter++;
}
+ assert(testInvariant());
}
character*
movie_root::get_active_entity()
{
+ assert(testInvariant());
return m_active_input_text;
}
@@ -573,11 +633,14 @@
movie_root::set_active_entity(character* ch)
{
m_active_input_text = ch;
+ assert(testInvariant());
}
bool
movie_root::isMouseOverActiveEntity() const
{
+ assert(testInvariant());
+
boost::intrusive_ptr<character> entity (
m_mouse_button_state.m_active_entity );
if ( ! entity.get() ) return false;
Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/movie_root.h 21 Nov 2006 00:25:46 -0000 1.26
+++ server/movie_root.h 28 Nov 2006 15:59:30 -0000 1.27
@@ -14,7 +14,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.26 2006/11/21 00:25:46 strk Exp $ */
+/* $Id: movie_root.h,v 1.27 2006/11/28 15:59:30 strk Exp $ */
/// \page events_handling Handling of user events
///
@@ -112,13 +112,13 @@
character* m_active_input_text;
float m_time_remainder;
+ /// @@ fold this into m_mouse_button_state?
+ character::drag_state m_drag_state;
+
public:
// XXXbastiaan: make these two variables private
boost::intrusive_ptr<sprite_instance> m_movie;
- /// @@ fold this into m_mouse_button_state?
- sprite_instance::drag_state m_drag_state;
-
movie_root(movie_def_impl* def);
~movie_root();
@@ -174,11 +174,20 @@
/// Use this to retrieve the last state of the mouse, as set via
/// notify_mouse_state(). Coordinates are in PIXELS, NOT TWIPS.
- virtual void get_mouse_state(int* x, int* y, int* buttons);
+ ///
+ virtual void get_mouse_state(int& x, int& y, int& buttons);
+
+ virtual void get_drag_state(drag_state& st);
+
+ virtual void set_drag_state(const drag_state& st);
sprite_instance* get_root_movie() { return m_movie.get(); }
- void stop_drag() { m_drag_state.m_character = NULL; }
+ void stop_drag()
+ {
+ log_msg("stop_drag called");
+ m_drag_state.reset();
+ }
movie_definition* get_movie_definition() {
return m_movie->get_movie_definition();
@@ -327,6 +336,8 @@
// reimplemented from movie_interface, see dox there
bool isMouseOverActiveEntity() const;
+ bool testInvariant() const;
+
private:
/// This function should return TRUE iff any action triggered
Index: server/rect.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/rect.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/rect.cpp 29 Oct 2006 18:34:11 -0000 1.3
+++ server/rect.cpp 28 Nov 2006 15:59:30 -0000 1.4
@@ -186,6 +186,13 @@
m_y_max = flerp(a.m_y_max, b.m_y_max, t);
}
+void
+rect::clamp(point& p) const
+{
+ p.m_x = fclamp(p.m_x, m_x_min, m_x_max);
+ p.m_y = fclamp(p.m_y, m_y_min, m_y_max);
+}
+
} // end namespace gnash
Index: server/rect.h
===================================================================
RCS file: /sources/gnash/gnash/server/rect.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/rect.h 26 Nov 2006 00:28:54 -0000 1.10
+++ server/rect.h 28 Nov 2006 15:59:30 -0000 1.11
@@ -17,7 +17,7 @@
//
//
-/* $Id: rect.h,v 1.10 2006/11/26 00:28:54 nihilus Exp $ */
+/* $Id: rect.h,v 1.11 2006/11/28 15:59:30 strk Exp $ */
#ifndef GNASH_RECT_H
#define GNASH_RECT_H
@@ -195,6 +195,12 @@
/// TODO: deprecate this ?
point get_corner(int i) const;
+ /// \brief
+ /// Make sure that the given point falls
+ /// in this rectangle, modifying it's coordinates
+ /// if needed.
+ void clamp(point& p) const;
+
/// Set ourself to bound a rectangle that has been transformed
/// by m. This is an axial bound of an oriented (and/or
/// sheared, scaled, etc) box.
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -b -r1.92 -r1.93
--- server/sprite_instance.cpp 28 Nov 2006 10:51:41 -0000 1.92
+++ server/sprite_instance.cpp 28 Nov 2006 15:59:30 -0000 1.93
@@ -1143,7 +1143,7 @@
// Local coord of mouse IN PIXELS.
int x, y, buttons;
assert(m_root);
- m_root->get_mouse_state(&x, &y, &buttons);
+ m_root->get_mouse_state(x, y, buttons);
matrix m = get_world_matrix();
@@ -1161,7 +1161,7 @@
// Local coord of mouse IN PIXELS.
int x, y, buttons;
assert(m_root);
- m_root->get_mouse_state(&x, &y, &buttons);
+ m_root->get_mouse_state(x, y, buttons);
matrix m = get_world_matrix();
@@ -2528,15 +2528,16 @@
}
void
-sprite_instance::get_mouse_state(int* x, int* y, int* buttons)
+sprite_instance::get_mouse_state(int& x, int& y, int& buttons)
{
m_root->get_mouse_state(x, y, buttons);
}
void
-sprite_instance::get_drag_state(drag_state* st)
+sprite_instance::get_drag_state(drag_state& st)
{
- *st = m_root->m_drag_state;
+ assert(m_root);
+ m_root->get_drag_state(st);
}
void
@@ -2549,7 +2550,7 @@
void
sprite_instance::set_drag_state(const drag_state& st)
{
- m_root->m_drag_state = st;
+ m_root->set_drag_state(st);
}
float
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- server/sprite_instance.h 27 Nov 2006 11:22:43 -0000 1.44
+++ server/sprite_instance.h 28 Nov 2006 15:59:30 -0000 1.45
@@ -17,7 +17,7 @@
//
//
-/* $Id: sprite_instance.h,v 1.44 2006/11/27 11:22:43 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.45 2006/11/28 15:59:30 strk Exp $ */
// Stateful live Sprite instance
@@ -166,7 +166,7 @@
float get_pixel_scale() const;
// delegates to m_root
- virtual void get_mouse_state(int* x, int* y, int* buttons);
+ virtual void get_mouse_state(int& x, int& y, int& buttons);
// delegatest to m_root
void set_background_color(const rgba& color);
@@ -391,7 +391,7 @@
virtual void stop_drag();
// delegates to m_root
- virtual void get_drag_state(drag_state* st);
+ virtual void get_drag_state(drag_state& st);
/// Duplicate the object with the specified name
Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/vm/ASHandlers.cpp 27 Nov 2006 01:01:54 -0000 1.3
+++ server/vm/ASHandlers.cpp 28 Nov 2006 15:59:30 -0000 1.4
@@ -16,7 +16,7 @@
//
-/* $Id: ASHandlers.cpp,v 1.3 2006/11/27 01:01:54 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.4 2006/11/28 15:59:30 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1233,37 +1233,63 @@
// GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
+ assert(thread.code[thread.pc] == SWF::ACTION_STARTDRAGMOVIE);
+
ensure_stack(env, 3);
- sprite_instance::drag_state st;
+ character::drag_state st;
- st.m_character = env.find_target(env.top(0));
- if (st.m_character == NULL) {
+ character* tgt = env.find_target(env.top(0));
+ if ( tgt ) {
+ st.setCharacter( tgt );
+ } else {
log_error("start_drag of invalid target '%s'.",
env.top(0).to_string());
}
- st.m_lock_center = env.top(1).to_bool();
- st.m_bound = env.top(2).to_bool();
- if (st.m_bound) {
-
+ st.setLockCentered( env.top(1).to_bool() );
+ if ( env.top(2).to_bool() ) // has bounds !
+ {
// strk: this works if we didn't drop any before, in
// a contrary case (if we used pop(), which I suggest)
// we must remember to updated this as required
- ensure_stack(env, 7);
+ ensure_stack(env, 7); // original 3 + 4 for bound
+
+ float y1 = env.top(3).to_number();
+ float x1 = env.top(4).to_number();
+ float y0 = env.top(5).to_number();
+ float x0 = env.top(6).to_number();
+
+ // check for swapped values
+ if ( y1 < y0 )
+ {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_msg("Y values in ActionStartDrag swapped, fixing");
+ );
+ swap(y1, y0);
+ }
+
+ if ( x1 < x0 )
+ {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_msg("X values in ActionStartDrag swapped, fixing");
+ );
+ swap(x1, x0);
+ }
+
+ rect bounds(x0, y0, x1, y1);
+ st.setBounds(bounds);
- st.m_bound_x0 = (float) env.top(6).to_number();
- st.m_bound_y0 = (float) env.top(5).to_number();
- st.m_bound_x1 = (float) env.top(4).to_number();
- st.m_bound_y1 = (float) env.top(3).to_number();
env.drop(4);
}
+
env.drop(3);
sprite_instance *root_movie = env.get_target()->get_root_movie();
assert(root_movie);
- if (root_movie && st.m_character) {
+ if (tgt)
+ {
root_movie->set_drag_state(st);
}