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: Wed, 18 Jul 2007 02:26:53 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/07/18 02:26:53

Modified files:
        .              : ChangeLog 
        server         : edit_text_character.cpp edit_text_character.h 

Log message:
                * server/edit_text_character.{cpp,h}: Initial support for 
background,
                  backgroundColor, border and borderColor. Lacks proper 
management
                  of invalidated bounds and class properties.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3750&r2=1.3751
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.35&r2=1.36

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3750
retrieving revision 1.3751
diff -u -b -r1.3750 -r1.3751
--- ChangeLog   18 Jul 2007 01:47:01 -0000      1.3750
+++ ChangeLog   18 Jul 2007 02:26:53 -0000      1.3751
@@ -1,5 +1,8 @@
 2007-07-17 Sandro Santilli <address@hidden>
 
+       * server/edit_text_character.{cpp,h}: Initial support for background,
+         backgroundColor, border and borderColor. Lacks proper management
+         of invalidated bounds and class properties. 
        * server/types.h: Add rgba::parseRGB() for converting an integer
          to an rgb value.
        * server/as_object.h: fix comments about case sensitiveness of

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- server/edit_text_character.cpp      17 Jul 2007 06:04:22 -0000      1.75
+++ server/edit_text_character.cpp      18 Jul 2007 02:26:53 -0000      1.76
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: edit_text_character.cpp,v 1.75 2007/07/17 06:04:22 zoulunkai Exp $ */
+/* $Id: edit_text_character.cpp,v 1.76 2007/07/18 02:26:53 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -36,7 +36,6 @@
 #include "VM.h"
 #include "builtin_function.h" // for getter/setter properties
 #include "font.h" // for using the _font member
-#include "VM.h"
 
 #include <algorithm>
 #include <string>
@@ -45,7 +44,6 @@
 // Text fields have a fixed 2 pixel padding for each side (regardless of 
border)
 #define PADDING_TWIPS 40.0f
 
-
 namespace gnash {
 
 // Forward declarations
@@ -65,6 +63,20 @@
 static as_value textfield_replaceText(const fn_call& fn);
 static as_object* getTextFieldInterface();
 
+       namespace
+       {
+
+               void
+               lowercase_if_needed(std::string& str)
+               {
+                       VM& vm = VM::get();
+                       if ( vm.getSWFVersion() >= 7 ) return;
+                       boost::to_lower(str, vm.getLocale());
+               }
+
+       }
+
+
 
 //
 // TextField interface functions
@@ -364,6 +376,7 @@
        registerTextVariable();
 
        reset_bounding_box(0, 0);
+
 }
 
 edit_text_character::~edit_text_character()
@@ -402,7 +415,9 @@
 
        rect def_bounds = m_def->get_bounds();
 
-       if (m_def->has_border())
+       bool drawBorder = hasBorder();
+       bool drawBackground = hasBackground();
+       if ( drawBorder || drawBackground )
        {
                matrix  mat = get_world_matrix();
                
@@ -420,38 +435,11 @@
                coords[2] = def_bounds.get_corner(2);
                coords[3] = def_bounds.get_corner(3);
                
-               render::draw_poly(&coords[0], 4, rgba(255,255,255,255), 
rgba(0,0,0,255));
+               rgba borderColor = drawBorder ? getBorderColor() : 
rgba(0,0,0,0);
+               rgba backgroundColor = drawBackground ? getBackgroundColor() : 
rgba(255,255,255,0);
                
+               render::draw_poly( &coords[0], 4, backgroundColor, borderColor 
);
                
-               // removed by Udo:
-               /*
-               coords[0] = def_bounds.get_corner(0);
-               coords[1] = def_bounds.get_corner(1);
-               coords[2] = def_bounds.get_corner(3);
-               coords[3] = def_bounds.get_corner(2);
-
-               int16_t icoords[18] = 
-               {
-                       // strip (fill in)
-                       (int16_t) coords[0].m_x, (int16_t) coords[0].m_y,
-                       (int16_t) coords[1].m_x, (int16_t) coords[1].m_y,
-                       (int16_t) coords[2].m_x, (int16_t) coords[2].m_y,
-                       (int16_t) coords[3].m_x, (int16_t) coords[3].m_y,
-
-                       // outline
-                       (int16_t) coords[0].m_x, (int16_t) coords[0].m_y,
-                       (int16_t) coords[1].m_x, (int16_t) coords[1].m_y,
-                       (int16_t) coords[3].m_x, (int16_t) coords[3].m_y,
-                       (int16_t) coords[2].m_x, (int16_t) coords[2].m_y,
-                       (int16_t) coords[0].m_x, (int16_t) coords[0].m_y,
-               };
-               
-               render::fill_style_color(0, rgba(255, 255, 255, 255));
-               render::draw_mesh_strip(&icoords[0], 4);
-
-               render::line_style_color(rgba(0,0,0,255));
-               render::draw_line_strip(&icoords[8], 5);
-               */
        }
 
        // Draw our actual text.
@@ -755,6 +743,12 @@
        // @@ TODO see TextField members in Flash MX docs
        }       // end switch
 
+
+       // TODO: iff background, backgroundColor, border, borderColor or 
textColor 
+       //       members are changed we should call set_invalidated !
+       //       Note that *deleting* these members might need to have
+       //       the same effect too (to be tested)
+
        set_member_default(name, val);
 }
 
@@ -1349,6 +1343,68 @@
        return def_bounds.point_test(lp.m_x, lp.m_y);
 }
 
+bool
+edit_text_character::hasBorder() const
+{
+       // TODO: check the 'border' member too !
+       return m_def->has_border();
+}
+
+rgba
+edit_text_character::getBorderColor() const
+{
+       // Background color is white by default
+       rgba col(0,0,0,255);
+
+       // TODO: define a caching strategy
+       as_value tmp;
+       std::string pname = "borderColor";
+       lowercase_if_needed(pname); // convert to lowercase if SWF < 7
+       if ( ! const_cast<edit_text_character*>(this)->get_member(pname, &tmp) 
) return col;
+
+       // Parse color
+       uint32_t rgbCol = tmp.to_number<uint32_t>(); // TODO: pass to_number an 
as_environment !
+       col.parseRGB(rgbCol);
+       //uint8_t r = (uint8_t)(rgbCol>>16);
+       //uint8_t g = (uint8_t)(rgbCol>>8);
+       //uint8_t b = (uint8_t)(rgbCol);
+       //col.set(r,g,b,255);
+       return col;
+}
+
+bool
+edit_text_character::hasBackground() const
+{
+       // TODO: define a caching strategy
+       as_value tmp;
+       static const char* pname = "background";
+       if ( ! const_cast<edit_text_character*>(this)->get_member(pname, &tmp) 
) return false;
+       return tmp.to_bool();
+}
+
+rgba
+edit_text_character::getBackgroundColor() const
+{
+       // Background color is white by default
+       rgba col(255,255,255,255);
+
+       // TODO: define a caching strategy
+       as_value tmp;
+       std::string pname = "backgroundColor";
+       lowercase_if_needed(pname); // convert to lowercase if SWF < 7
+       if ( ! const_cast<edit_text_character*>(this)->get_member(pname, &tmp) 
) return col;
+
+       // Parse color
+       uint32_t rgbCol = tmp.to_number<uint32_t>(); // TODO: pass to_number an 
as_environment !
+       col.parseRGB(rgbCol);
+       //uint8_t r = (uint8_t)(rgbCol>>16);
+       //uint8_t g = (uint8_t)(rgbCol>>8);
+       //uint8_t b = (uint8_t)(rgbCol);
+       //col.set(r,g,b,255);
+
+       return col;
+}
+
 } // namespace gnash
 
 

Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/edit_text_character.h        3 Jul 2007 01:12:45 -0000       1.35
+++ server/edit_text_character.h        18 Jul 2007 02:26:53 -0000      1.36
@@ -110,6 +110,18 @@
        /// Return true if HTML was allowed by definition
        bool htmlAllowed() const { return m_def->htmlAllowed(); }
 
+       /// Return true if the 'background' member is set to true
+       bool hasBackground() const;
+
+       /// Return the value of 'backgroundColor', or solid white if undefined.
+       rgba getBackgroundColor() const;
+
+       /// Return true if this TextField should have it's border visible
+       bool hasBorder() const;
+
+       /// Return the value of 'borderColor', or solid black if undefined.
+       rgba getBorderColor() const;
+
        /// The actual text
        std::string _text;
 




reply via email to

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