gnash-commit
[Top][All Lists]
Advanced

[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: Thu, 12 Apr 2007 11:35:30 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/04/12 11:35:30

Modified files:
        .              : ChangeLog 
        server         : button_character_instance.cpp 
                         button_character_instance.h character.cpp 
                         character.h edit_text_character.cpp 
                         edit_text_character.h generic_character.h 
                         sprite_instance.cpp sprite_instance.h 

Log message:
                * server/: button_character_instance.{cpp,h},
                  character.{cpp,h}, edit_text_character.{cpp,h},
                  generic_character.h, sprite_instance.{cpp,h}:
                  get_width() and get_height() made non-virtual
                  methods using getBounds() internally.
                  Fixed _width, _height, _xscale, _yscale and _rotation
                  getter/setter to call valueOf when available.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2863&r2=1.2864
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.h?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/server/generic_character.h?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.237&r2=1.238
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.95&r2=1.96

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2863
retrieving revision 1.2864
diff -u -b -r1.2863 -r1.2864
--- ChangeLog   12 Apr 2007 09:46:06 -0000      1.2863
+++ ChangeLog   12 Apr 2007 11:35:29 -0000      1.2864
@@ -1,5 +1,15 @@
 2007-04-12 Sandro Santilli <address@hidden>
 
+       * server/: button_character_instance.{cpp,h},
+         character.{cpp,h}, edit_text_character.{cpp,h},
+         generic_character.h, sprite_instance.{cpp,h}:
+         get_width() and get_height() made non-virtual
+         methods using getBounds() internally.
+         Fixed _width, _height, _xscale, _yscale and _rotation
+         getter/setter to call valueOf when available.
+
+2007-04-12 Sandro Santilli <address@hidden>
+
        * server/sprite_instance.cpp (duplicateMovieClip): 
          Duplicate also the drawable.
        * testsuite/misc-ming.all/displaylist_depths_test.c:

Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- server/button_character_instance.cpp        12 Apr 2007 09:14:36 -0000      
1.41
+++ server/button_character_instance.cpp        12 Apr 2007 11:35:30 -0000      
1.42
@@ -790,46 +790,6 @@
 
 }
 
-float
-button_character_instance::get_width() const
-{
-       for (unsigned int i = 0; i < m_def->m_button_records.size(); i++)
-       {
-               button_record&  rec = m_def->m_button_records[i];
-               if (m_record_character[i] == NULL)
-               {
-                       continue;
-               }
-               if ((m_mouse_state == UP && rec.m_up)
-                   || (m_mouse_state == DOWN && rec.m_down)
-                   || (m_mouse_state == OVER && rec.m_over))
-               {
-                       return m_record_character[i]->get_width();
-               }
-       }
-       return 0.0;
-}
-
-float
-button_character_instance::get_height() const
-{
-       for (unsigned int i = 0; i < m_def->m_button_records.size(); i++)
-       {
-               button_record&  rec = m_def->m_button_records[i];
-               if (m_record_character[i] == NULL)
-               {
-                       continue;
-               }
-               if ((m_mouse_state == UP && rec.m_up)
-                   || (m_mouse_state == DOWN && rec.m_down)
-                   || (m_mouse_state == OVER && rec.m_over))
-               {
-                       return m_record_character[i]->get_height();
-               }
-       }
-       return 0.0;
-}
-
 geometry::Range2d<float>
 button_character_instance::getBounds() const
 {

Index: server/button_character_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/button_character_instance.h  12 Apr 2007 09:14:36 -0000      1.18
+++ server/button_character_instance.h  12 Apr 2007 11:35:30 -0000      1.19
@@ -20,7 +20,7 @@
 
 // SWF buttons.  Mouse-sensitive update/display, actions, etc.
 
-/* $Id: button_character_instance.h,v 1.18 2007/04/12 09:14:36 strk Exp $ */
+/* $Id: button_character_instance.h,v 1.19 2007/04/12 11:35:30 strk Exp $ */
 
 #ifndef GNASH_BUTTON_CHARACTER_INSTANCE_H
 #define GNASH_BUTTON_CHARACTER_INSTANCE_H
@@ -134,14 +134,6 @@
 
        void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);
        
-
-       // not sure if we need to override this one.
-       //virtual const char*   get_text_value() const { return NULL; } // 
edit_text_character overrides this
-       
-       virtual float get_width() const;
-
-       virtual float get_height() const;
-
        geometry::Range2d<float> getBounds() const;
        
        static as_value enabled_getset(const fn_call& fn);

Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- server/character.cpp        12 Apr 2007 09:14:36 -0000      1.31
+++ server/character.cpp        12 Apr 2007 11:35:30 -0000      1.32
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: character.cpp,v 1.31 2007/04/12 09:14:36 strk Exp $ */
+/* $Id: character.cpp,v 1.32 2007/04/12 11:35:30 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -250,7 +250,7 @@
        else // setter
        {
                matrix m = ptr->get_matrix();
-               m.m_[0][2] = 
infinite_to_fzero(PIXELS_TO_TWIPS(fn.arg(0).to_number()));
+               m.m_[0][2] = 
infinite_to_fzero(PIXELS_TO_TWIPS(fn.arg(0).to_number(&(fn.env()))));
                ptr->set_matrix(m);
                ptr->transformedByScript(); // m_accept_anim_moves = false; 
        }
@@ -272,7 +272,7 @@
        else // setter
        {
                matrix m = ptr->get_matrix();
-               m.m_[1][2] = 
infinite_to_fzero(PIXELS_TO_TWIPS(fn.arg(0).to_number()));
+               m.m_[1][2] = 
infinite_to_fzero(PIXELS_TO_TWIPS(fn.arg(0).to_number(&(fn.env()))));
                ptr->set_matrix(m);
                ptr->transformedByScript(); // m_accept_anim_moves = false; 
        }
@@ -296,7 +296,7 @@
        {
                matrix m = ptr->get_matrix();
 
-               double scale_percent = fn.arg(0).to_number();
+               double scale_percent = fn.arg(0).to_number(&(fn.env()));
 
                // Handle bogus values
                if (isnan(scale_percent))
@@ -348,7 +348,7 @@
        {
                matrix m = ptr->get_matrix();
 
-               double scale_percent = fn.arg(0).to_number();
+               double scale_percent = fn.arg(0).to_number(&(fn.env()));
 
                // Handle bogus values
                if (isnan(scale_percent))
@@ -468,11 +468,13 @@
 {
        boost::intrusive_ptr<character> ptr = 
ensureType<character>(fn.this_ptr);
 
+       // Bounds are used for both getter and setter
+       geometry::Range2d<float> bounds = ptr->getBounds();
+
        as_value rv;
        if ( fn.nargs == 0 ) // getter
        {
                float w = 0;
-               geometry::Range2d<float> bounds = ptr->getBounds();
                if ( bounds.isFinite() )
                {
                        matrix m = ptr->get_matrix();
@@ -484,14 +486,13 @@
        }
        else // setter
        {
-               // @@ tulrich: is parameter in world-coords or local-coords?
                matrix m = ptr->get_matrix();
-               m.m_[0][0] = 
infinite_to_fzero(PIXELS_TO_TWIPS(fn.arg(0).to_number()));
-               float w = ptr->get_width();
-               if (fabsf(w) > 1e-6f)
-               {
-                       m.m_[0][0] /= w;
-               }
+
+               double newwidth = fn.arg(0).to_number(&(fn.env()));
+               m.m_[0][0] = infinite_to_fzero(PIXELS_TO_TWIPS(newwidth));
+
+               if ( bounds.isFinite() ) m.m_[0][0] /= bounds.width();
+
                ptr->set_matrix(m);
                ptr->transformedByScript(); // m_accept_anim_moves = false; 
        }
@@ -503,11 +504,13 @@
 {
        boost::intrusive_ptr<character> ptr = 
ensureType<character>(fn.this_ptr);
 
+       // Bounds are used for both getter and setter
+       geometry::Range2d<float> bounds = ptr->getBounds();
+
        as_value rv;
        if ( fn.nargs == 0 ) // getter
        {
                float h = 0;
-               geometry::Range2d<float> bounds = ptr->getBounds();
                if ( bounds.isFinite() )
                {
                        matrix m = ptr->get_matrix();
@@ -519,14 +522,13 @@
        }
        else // setter
        {
-               // @@ tulrich: is parameter in world-coords or local-coords?
                matrix m = ptr->get_matrix();
-               m.m_[1][1] = 
infinite_to_fzero(PIXELS_TO_TWIPS(fn.arg(0).to_number()));
-               float h = ptr->get_height(); 
-               if (fabsf(h) > 1e-6f)
-               {
-                       m.m_[1][1] /= h;
-               }
+
+               double newheight = fn.arg(0).to_number(&(fn.env()));
+               m.m_[1][1] = infinite_to_fzero(PIXELS_TO_TWIPS(newheight));
+
+               if ( bounds.isFinite() ) m.m_[1][1] /= bounds.height();
+
                ptr->set_matrix(m);
                ptr->transformedByScript(); // m_accept_anim_moves = false; 
        }
@@ -558,7 +560,7 @@
                float x_scale = m.get_x_scale();
                float y_scale = m.get_y_scale();
                // input is in degrees
-               float rotation = (float) fn.arg(0).to_number() * float(M_PI) / 
180.f;
+               float rotation = (float) fn.arg(0).to_number(&(fn.env())) * 
float(M_PI) / 180.f;
                m.set_scale_rotation(x_scale, y_scale, rotation);
 
                ptr->set_matrix(m);

Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- server/character.h  12 Apr 2007 09:14:36 -0000      1.65
+++ server/character.h  12 Apr 2007 11:35:30 -0000      1.66
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: character.h,v 1.65 2007/04/12 09:14:36 strk Exp $ */
+/* $Id: character.h,v 1.66 2007/04/12 11:35:30 strk Exp $ */
 
 #ifndef GNASH_CHARACTER_H
 #define GNASH_CHARACTER_H
@@ -399,16 +399,24 @@
     virtual void       display() {}
 
        /// Returns local, untransformed height of this character in TWIPS
-       virtual float   get_height() const
+       //
+       /// Use getBounds() if you need more then simply the height.
+       ///
+       float get_height() const
        {
-               log_error("a character class didn't override get_height: %s", 
typeid(*this).name());
+               geometry::Range2d<float> bounds = getBounds();
+               if ( bounds.isFinite() ) return bounds.height();
                return 0;
        }
 
        /// Returns local, untransformed width of this character in TWIPS
-       virtual float   get_width() const
+       //
+       /// Use getBounds() if you need more then simply the width.
+       ///
+       float get_width() const
        {
-               log_error("a character class didn't override get_width: %s", 
typeid(*this).name());
+               geometry::Range2d<float> bounds = getBounds();
+               if ( bounds.isFinite() ) return bounds.width();
                return 0;
        }
 

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- server/edit_text_character.cpp      3 Apr 2007 17:21:38 -0000       1.51
+++ server/edit_text_character.cpp      12 Apr 2007 11:35:30 -0000      1.52
@@ -15,7 +15,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 
-/* $Id: edit_text_character.cpp,v 1.51 2007/04/03 17:21:38 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.52 2007/04/12 11:35:30 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1291,32 +1291,6 @@
        _text_variable_registered=true;
 }
 
-float
-edit_text_character::get_height() const
-{
-       // @@ TODO should implement this in
-       // character and inherit into both here and sprite_instance
-       rect    transformed_rect;
-       transformed_rect.enclose_transformed_rect(get_world_matrix(), 
m_def->get_bounds());
-       return transformed_rect.height();
-
-       log_error("%s: not implmented yet", __PRETTY_FUNCTION__);
-       return 0;
-}
-
-float
-edit_text_character::get_width() const
-{
-       // @@ TODO should implement this in
-       // character and inherit into both here and sprite_instance
-       rect    transformed_rect;
-       transformed_rect.enclose_transformed_rect(get_world_matrix(), 
m_def->get_bounds());
-       return transformed_rect.width();
-
-       log_error("%s: not implmented yet", __PRETTY_FUNCTION__);
-       return 0;
-}
-
 void
 edit_text_character::set_variable_name(const std::string& newname)
 {

Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- server/edit_text_character.h        12 Apr 2007 09:14:36 -0000      1.27
+++ server/edit_text_character.h        12 Apr 2007 11:35:30 -0000      1.28
@@ -91,9 +91,6 @@
 
        void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);
 
-       virtual float   get_height() const;
-       virtual float   get_width() const;
-
        geometry::Range2d<float> getBounds() const
        {
                return m_def->get_bounds().getRange();

Index: server/generic_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/generic_character.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/generic_character.h  12 Apr 2007 09:14:36 -0000      1.20
+++ server/generic_character.h  12 Apr 2007 11:35:30 -0000      1.21
@@ -70,22 +70,6 @@
            do_display_callback();
        }
 
-    // @@ tulrich: these are used for finding bounds; TODO
-    // need to do this using enclose_transformed_rect(),
-    // not by scaling the local height/width!
-
-       virtual float   get_height() const
-       {
-               // Verified using samples/test_rotation.swf
-               return m_def->get_height_local();
-       }
-
-       virtual float   get_width() const
-       {
-               // Verified using samples/test_rotation.swf
-               return m_def->get_width_local();
-       }
-
        geometry::Range2d<float> getBounds() const
        {
                return m_def->get_bound().getRange();

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.237
retrieving revision 1.238
diff -u -b -r1.237 -r1.238
--- server/sprite_instance.cpp  12 Apr 2007 09:46:06 -0000      1.237
+++ server/sprite_instance.cpp  12 Apr 2007 11:35:30 -0000      1.238
@@ -1463,48 +1463,6 @@
        }
 };
 
-/// A DisplayList visitor used to compute its overall height.
-//
-/// TODO: this seems bogus actually, as it will just return
-///       the height of the tallest character in the list !!
-///
-class HeightFinder {
-public:
-       float _h;
-       HeightFinder(): _h(0) {}
-       void operator() (character* ch)
-       {
-               float ch_h = ch->get_height();
-               if (ch_h > _h) {
-                       _h = ch_h;
-               }
-       }
-       float getHeight() {
-               return _h;
-       }
-};
-
-/// A DisplayList visitor used to compute its overall width.
-//
-/// TODO: this seems bogus actually, as it will just return
-///       the width of the widest character in the list !!
-///
-class WidthFinder {
-public:
-       float _w;
-       WidthFinder(): _w(0) {}
-       void operator() (character* ch) 
-       {
-               float ch_w = ch->get_width();
-               if (ch_w > _w) {
-                       _w = ch_w;
-               }
-       }
-       float getWidth() {
-               return _w;
-       }
-};
-
 /// A DisplayList visitor used to extract script characters
 //
 /// Script characters are characters created or transformed
@@ -2999,40 +2957,6 @@
 
 }
 
-float sprite_instance::get_height() const
-{
-       // TODO: FIXME: this whole thing is bogus,
-       //       we should extract the actual bounds
-       //       and return their height
-
-       HeightFinder f;
-       // the const_cast is just to avoid defining a const version
-       // of DisplayList::visitForward, HeightFinder will NOT
-       // modify the DisplayList elements in any way
-       const_cast<DisplayList&>(m_display_list).visitAll(f);
-       float h = f.getHeight();
-       float hd = _drawable->get_height_local();
-       if ( hd > h ) h = hd;
-       return h;
-}
-
-float sprite_instance::get_width() const
-{
-       // TODO: FIXME: this whole thing is bogus,
-       //       we should extract the actual bounds
-       //       and return their width
-
-       WidthFinder f;
-       // the const_cast is just to avoid defining a const version
-       // of DisplayList::visitForward, WidthFinder will NOT
-       // modify the DisplayList elements in any way
-       const_cast<DisplayList&>(m_display_list).visitAll(f);
-       float w = f.getWidth(); 
-       float wd = _drawable->get_width_local();
-       if ( wd > w ) w = wd;
-       return w;
-}
-
 character*
 sprite_instance::get_character(int /* character_id */)
 {

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -b -r1.95 -r1.96
--- server/sprite_instance.h    12 Apr 2007 09:14:36 -0000      1.95
+++ server/sprite_instance.h    12 Apr 2007 11:35:30 -0000      1.96
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.95 2007/04/12 09:14:36 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.96 2007/04/12 11:35:30 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -136,10 +136,6 @@
                 return m_def.get();
         }
 
-       float get_width() const;
-
-       float get_height() const;
-
        /// Get the composite bounds of all component drawing elements
        geometry::Range2d<float> getBounds() const;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]