gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...
Date: Thu, 16 Aug 2007 10:31:52 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/08/16 10:31:51

Modified files:
        .              : ChangeLog 
        server         : edit_text_character.cpp edit_text_character.h 
                         gnash.h 
        testsuite/actionscript.all: TextField.as 

Log message:
                * server/edit_text_character.{cpp,h}: have a Range2d member to 
express
                  current TextField boundary (_width,_height). Implement _width 
and
                  _height setters. Add compile-time macro for debugging (still 
doesn't
                  work as expected).
                * server/gnash.h: add more descriptions, a set() method and 
TODO items
                  for the 'point' class.
                * testsuite/actionscript.all/TextField.as: more passes.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4010&r2=1.4011
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.98&r2=1.99
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.101&r2=1.102
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/TextField.as?cvsroot=gnash&r1=1.16&r2=1.17

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4010
retrieving revision 1.4011
diff -u -b -r1.4010 -r1.4011
--- ChangeLog   16 Aug 2007 09:29:32 -0000      1.4010
+++ ChangeLog   16 Aug 2007 10:31:50 -0000      1.4011
@@ -1,3 +1,13 @@
+2007-08-16 Sandro Santilli <address@hidden>
+
+       * server/edit_text_character.{cpp,h}: have a Range2d member to express
+         current TextField boundary (_width,_height). Implement _width and
+         _height setters. Add compile-time macro for debugging (still doesn't
+         work as expected).
+       * server/gnash.h: add more descriptions, a set() method and TODO items
+         for the 'point' class.
+       * testsuite/actionscript.all/TextField.as: more passes.
+
 2007-08-16 Zou Lunkai <address@hidden>
 
        * testsuite/misc-ming.all/registerClassTest2.c, Makefile.am: new 
testcase

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -b -r1.98 -r1.99
--- server/edit_text_character.cpp      13 Aug 2007 03:26:33 -0000      1.98
+++ server/edit_text_character.cpp      16 Aug 2007 10:31:51 -0000      1.99
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: edit_text_character.cpp,v 1.98 2007/08/13 03:26:33 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.99 2007/08/16 10:31:51 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -393,7 +393,8 @@
        _borderColor(0,0,0,255),
        _textColor(m_def->get_text_color()),
        _embedFonts(m_def->getUseEmbeddedGlyphs()),
-       _autoSize(autoSizeNone)
+       _autoSize(autoSizeNone),
+       _bounds(m_def->get_bounds().getRange())
 {
        assert(parent);
        assert(m_def);
@@ -450,21 +451,26 @@
 
        registerTextVariable();
 
-       rect def_bounds = m_def->get_bounds();
+       //rect def_bounds = m_def->get_bounds();
 
        bool drawBorder = getDrawBorder();
        bool drawBackground = getDrawBackground();
 
-       if ( drawBorder || drawBackground )
+       if ( (drawBorder || drawBackground) && _bounds.isFinite() )
        {
                matrix  mat = get_world_matrix();
                render::set_matrix(mat);
 
                point   coords[4];
-               coords[0] = def_bounds.get_corner(0);
-               coords[1] = def_bounds.get_corner(1);
-               coords[2] = def_bounds.get_corner(2);
-               coords[3] = def_bounds.get_corner(3);
+               float xmin = _bounds.getMinX();
+               float xmax = _bounds.getMaxX();
+               float ymin = _bounds.getMinY();
+               float ymax = _bounds.getMaxY();
+
+               coords[0].set(xmin, ymin); // = def_bounds.get_corner(0);
+               coords[1].set(xmax, ymin); // = def_bounds.get_corner(1);
+               coords[2].set(xmax, ymax); // = def_bounds.get_corner(2);
+               coords[3].set(xmin, ymax); // = def_bounds.get_corner(3);
 
                rgba borderColor = drawBorder ? getBorderColor() : 
rgba(0,0,0,0);
                rgba backgroundColor = drawBackground ? getBackgroundColor() : 
rgba(0,0,0,0);
@@ -477,6 +483,11 @@
                if (drawBackground)
                        backgroundColor = cx.transform(backgroundColor);
                
+#ifdef GNASH_DEBUG_TEXTFIELDS
+       std::stringstream ss; ss << _bounds;
+       log_debug("rendering a Pol composed by corners %s", ss.str().c_str());
+#endif
+
                render::draw_poly( &coords[0], 4, backgroundColor, borderColor 
);
                
        }
@@ -488,9 +499,9 @@
        // Anyway, see bug #17954 for a testcase.
        matrix m;
 
-       if ( ! def_bounds.is_null() && ! def_bounds.is_world() )
+       if ( _bounds.isFinite() ) // ! def_bounds.is_null() && ! 
def_bounds.is_world() 
        {
-               m.concatenate_translation(def_bounds.get_x_min(), 
def_bounds.get_y_min());
+               m.concatenate_translation(_bounds.getMinX(), 
_bounds.getMinY()); // def_bounds.get_x_min(), def_bounds.get_y_min()
        }
        
        
@@ -655,8 +666,9 @@
        point   p;
        m.transform_by_inverse(&p, point(x, y));
 
-       const rect& def_bounds = m_def->get_bounds();
-       if (def_bounds.point_test(p.m_x, p.m_y))
+       //const rect& def_bounds = m_def->get_bounds();
+       //if (def_bounds.point_test(p.m_x, p.m_y))
+       if ( _bounds.contains(p.m_x, p.m_y) )
        {
                return this;
        }
@@ -749,6 +761,76 @@
                
                return;
        }
+       case M_WIDTH: // _width
+       {
+               float nw = PIXELS_TO_TWIPS(val.to_number()); // TODO: pass an 
as_environment !
+               if ( _bounds.width() == nw )
+               {
+#ifdef GNASH_DEBUG_TEXTFIELDS
+                       log_debug("TextField width already == %g, nothing to do 
to change it", nw);
+#endif
+                       return; // nothing to do
+               }
+               if ( ! _bounds.isFinite() )
+               {
+#ifdef GNASH_DEBUG_TEXTFIELDS
+                       stringstream ss; ss<<_bounds;
+                       log_debug("Non-finite TextField bounds : %s", 
ss.str().c_str());
+#endif
+                       return;
+               }
+
+#ifdef GNASH_DEBUG_TEXTFIELDS
+               log_debug("Chaging TextField width to %g", nw);
+#endif
+
+               set_invalidated();
+
+               // Modify TextField drawing rectangle
+               // TODO: check which anchor point we should use !
+               float xmin = _bounds.getMinX();
+               float ymin = _bounds.getMinY();
+               float ymax = _bounds.getMaxY();
+               _bounds.setTo(xmin, ymin, xmin+nw, ymax);
+               assert(_bounds.width() == nw);
+
+               return;
+       }
+       case M_HEIGHT: // _height
+       {
+               float nh = PIXELS_TO_TWIPS(val.to_number()); // TODO: pass an 
as_environment !
+               if ( _bounds.height() == nh )
+               {
+#ifdef GNASH_DEBUG_TEXTFIELDS
+                       log_debug("TextField height already == %g, nothing to 
do to change it", nh);
+#endif // GNASH_DEBUG_TEXTFIELDS
+                       return; // nothing to do
+               }
+               if ( ! _bounds.isFinite() )
+               {
+#ifdef GNASH_DEBUG_TEXTFIELDS
+                       stringstream ss; ss<<_bounds;
+                       log_debug("Non-finite TextField bounds : %s", 
ss.str().c_str());
+#endif // GNASH_DEBUG_TEXTFIELDS
+                       return;
+               }
+
+#ifdef GNASH_DEBUG_TEXTFIELDS
+               log_debug("Chaging TextField height to %g", nh);
+#endif // GNASH_DEBUG_TEXTFIELDS
+               set_invalidated();
+
+               // Modify TextField drawing rectangle
+               // TODO: check which anchor point we should use !
+               float xmin = _bounds.getMinX();
+               float xmax = _bounds.getMaxX();
+               float ymin = _bounds.getMinY();
+               _bounds.setTo(xmin, ymin, xmax, ymin+nh);
+
+               assert(_bounds.height() == nh);
+
+               return;
+       }
        case M_VISIBLE:
                //else if (name == "_visible")
        {
@@ -823,11 +905,17 @@
        case M_WIDTH: // _width
        {
                val->set_double(TWIPS_TO_PIXELS(get_width()));
+#ifdef GNASH_DEBUG_TEXTFIELDS
+               log_debug("Got TextField width == %s", 
val->to_debug_string().c_str());
+#endif // GNASH_DEBUG_TEXTFIELDS
                return true;
        }
        case M_HEIGHT: // _height
        {
                val->set_double(TWIPS_TO_PIXELS(get_height()));
+#ifdef GNASH_DEBUG_TEXTFIELDS
+               log_debug("Got TextField height == %s", 
val->to_debug_string().c_str());
+#endif // GNASH_DEBUG_TEXTFIELDS
                return true;
        }
        case M_TEXTWIDTH:
@@ -856,15 +944,17 @@
        //GNASH_REPORT_FUNCTION;
        assert(m_def);
 
-       float   extra_space = (m_def->width() -
-                       m_def->get_right_margin()) - x - PADDING_TWIPS;
+       float width = _bounds.width(); // m_def->width()
+       float right_margin = m_def->get_right_margin();
+
+       float   extra_space = (width - right_margin) - x - PADDING_TWIPS;
 
        //assert(extra_space >= 0.0f);
        if (extra_space <= 0.0f)
        {
                log_debug(_("TextField text doesn't fit in its boundaries: "
                            "width %g, margin %d - nothing to align"),
-                           m_def->width(), m_def->get_right_margin());
+                           width, right_margin);
                return 0.0f;
        }
 
@@ -1147,7 +1237,10 @@
                
 after_x_advance:
 
-               if (x >= m_def->width() - m_def->get_right_margin() - 
PADDING_TWIPS)
+               float width = _bounds.width(); // m_def->width()
+               float right_margin = m_def->get_right_margin();
+
+               if (x >= width - right_margin - PADDING_TWIPS)
                {
                        // Whoops, we just exceeded the box width. 
                        // Do word-wrap if requested to do so.
@@ -1371,8 +1464,9 @@
        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);
+       return _bounds.contains(lp.m_x, lp.m_y);
+       //const rect& def_bounds = m_def->get_bounds();
+       //return def_bounds.point_test(lp.m_x, lp.m_y);
 }
 
 bool

Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- server/edit_text_character.h        13 Aug 2007 03:26:09 -0000      1.44
+++ server/edit_text_character.h        16 Aug 2007 10:31:51 -0000      1.45
@@ -112,11 +112,7 @@
 
        geometry::Range2d<float> getBounds() const
        {
-               // TODO: keep an instance member for encoding
-               //       the bounding box, as it might be 
-               //       dynamically updated if the textfield
-               //       is editable and auto-resizes.
-               return m_def->get_bounds().getRange();
+               return _bounds;
        }
 
        // See dox in character.h
@@ -319,6 +315,14 @@
 
        AutoSizeValue _autoSize;
 
+       /// Area in which the text is drawn. 
+       //
+       /// This area encloses all the text, can be automatically
+       /// extended to fit text or hide text overflowing it.
+       /// See the setAutoSize() method to change that.
+       ///
+       geometry::Range2d<float> _bounds;
+
 protected:
 
 #ifdef GNASH_USE_GC

Index: server/gnash.h
===================================================================
RCS file: /sources/gnash/gnash/server/gnash.h,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -b -r1.101 -r1.102
--- server/gnash.h      24 Jul 2007 14:19:31 -0000      1.101
+++ server/gnash.h      16 Aug 2007 10:31:51 -0000      1.102
@@ -352,21 +352,38 @@
 //
 
 
+/// Point class
+//
+/// TODO: move in libgeometry/point2d.{cpp,h}, provide a gnash::point2d typedef
+/// TODO: make m_x and m_y members private ? (or rename to x,y)
+/// TODO: provide a toString() and an output operator
+///
 class DSOLOCAL point
 {
 public:
        float   m_x, m_y;
 
+       /// Construct a point with X and Y values set to 0
        point() : m_x(0), m_y(0) {}
+
+       /// Construct a point with X and Y values set to the given values
        point(float x, float y) : m_x(x), m_y(y) {}
 
+       /// Set X and Y values of the point
+       void set(float x, float y)
+       {
+               m_x = x;
+               m_y = y;
+       }
+
+       /// Set to a + (b - a) * t
        void    set_lerp(const point& a, const point& b, float t)
-               // Set to a + (b - a) * t
                {
                        m_x = a.m_x + (b.m_x - a.m_x) * t;
                        m_y = a.m_y + (b.m_y - a.m_y) * t;
                }
 
+       /// Compare two points for 2d equality
        bool operator==(const point& p) const { return m_x == p.m_x && m_y == 
p.m_y; }
 
        /// Return the square of the distance between this and other point.
@@ -375,6 +392,10 @@
        /// Return the distance between this and other point.
        float distance(const point& other) const;
 
+       /// Compare two points for bitwise equality
+       //
+       /// TODO: (should this really be different by normal equality?)
+       ///
        bool    bitwise_equal(const point& p) const;
 };
 

Index: testsuite/actionscript.all/TextField.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/TextField.as,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- testsuite/actionscript.all/TextField.as     15 Aug 2007 23:00:15 -0000      
1.16
+++ testsuite/actionscript.all/TextField.as     16 Aug 2007 10:31:51 -0000      
1.17
@@ -19,7 +19,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: TextField.as,v 1.16 2007/08/15 23:00:15 strk Exp $";
+rcsid="$Id: TextField.as,v 1.17 2007/08/16 10:31:51 strk Exp $";
 
 #include "check.as"
 
@@ -252,7 +252,7 @@
 check(!tf.__proto__.hasOwnProperty('_height'));
 check_equals(tf._height, 500); // as we created it, see createTextField call
 tf._height = 99999;
-xcheck_equals(tf._height, 99999); 
+check_equals(tf._height, 99999); 
 tf._height = 500;
 
 // Check TextField.hscroll
@@ -538,7 +538,7 @@
 check( ! tf.__proto__.hasOwnProperty('_width') ); 
 check_equals(tf._width, 500); // as it was set by createTextField, see above
 tf._width = 99999;
-xcheck_equals(tf._width, 99999); 
+check_equals(tf._width, 99999); 
 tf._width = 500;
 
 // Check TextField.wordWrap (should text wrap when bbox limit is hit?)
@@ -620,16 +620,16 @@
 tf.text = "Hello world";
 tf.autoSize = 'none';
 tf.wordWrap = false;
-xcheck_equals(tf._width, 10);
+check_equals(tf._width, 10);
 origTextWidth = tf.textWidth;
 tf.autoSize = 'center';
-check(tf._width > 10);
+xcheck(tf._width > 10);
 check_equals(origTextWidth, tf.textWidth); // textWidth isn't influenced by 
autoSize 
 tf.autoSize = 'none';
 tf.wordWrap = true;
 tf._width = 10;
 // Gnash ignores assigments to _width (should change TextField rendering area 
bounds instead)
-xcheck_equals(tf._width, 10);
+check_equals(tf._width, 10);
 check_equals(origTextWidth, tf.textWidth); // textWidth isn't influenced by 
wordWrap
 
 #endif // OUTPUT_VERSION > 5




reply via email to

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