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, 10 Apr 2008 10:13:31 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/10 10:13:31

Modified files:
        .              : ChangeLog 
        server         : edit_text_character.cpp 
        server/asobj   : TextFormat.cpp TextFormat.h 
        testsuite/misc-ming.all: DefineEditTextTest.c 

Log message:
        * server/asobj/TextFormat.{cpp,h}: implement color getter-setter
        * server/edit_text_character.cpp: fix handling of TextField.color.
        * testsuite/misc-ming.all/DefineEditTextTest.c: test TextFormat.color.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6238&r2=1.6239
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.166&r2=1.167
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/TextFormat.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/TextFormat.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DefineEditTextTest.c?cvsroot=gnash&r1=1.34&r2=1.35

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6238
retrieving revision 1.6239
diff -u -b -r1.6238 -r1.6239
--- ChangeLog   10 Apr 2008 09:49:07 -0000      1.6238
+++ ChangeLog   10 Apr 2008 10:13:29 -0000      1.6239
@@ -1,5 +1,11 @@
 2008-04-10 Sandro Santilli <address@hidden>
 
+       * server/asobj/TextFormat.{cpp,h}: implement color getter-setter
+       * server/edit_text_character.cpp: fix handling of TextField.color.
+       * testsuite/misc-ming.all/DefineEditTextTest.c: test TextFormat.color.
+
+2008-04-10 Sandro Santilli <address@hidden>
+
        * server/asobj/TextFormat.cpp: implement leading getter-setter.
        * testsuite/misc-ming.all/DefineEditTextTest.c: test leading.
 

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -b -r1.166 -r1.167
--- server/edit_text_character.cpp      10 Apr 2008 08:44:13 -0000      1.166
+++ server/edit_text_character.cpp      10 Apr 2008 10:13:30 -0000      1.167
@@ -173,6 +173,7 @@
        tf->leadingSet(text->getLeading());
        tf->leftMarginSet(text->getLeftMargin());
        tf->rightMarginSet(text->getRightMargin());
+       tf->colorSet(text->getTextColor());
 
        const font* font = text->getFont();
        if (font)
@@ -184,7 +185,7 @@
 
        // TODO: add font color and some more
 
-       ONCE( log_unimpl("TextField.getTextFormat() discards color, url, 
target, underline, blockIndent, tabStops, bullet and display") );
+       ONCE( log_unimpl("TextField.getTextFormat() discards url, target, 
underline, blockIndent, tabStops, bullet and display") );
 
        return as_value(tf.get());
 }
@@ -236,6 +237,7 @@
        text->setLeading(tf->leading());
        text->setLeftMargin(tf->leftMargin());
        text->setRightMargin(tf->rightMargin());
+       text->setTextColor(tf->color());
 
        const std::string& fontName = tf->font();
        if ( ! fontName.empty() )
@@ -252,7 +254,7 @@
 
        // TODO: add font color and some more
 
-       ONCE( log_unimpl("TextField.setTextFormat() discards color, url, 
target, underline, blockIndent, tabStops, bullet and display") );
+       ONCE( log_unimpl("TextField.setTextFormat() discards url, target, 
underline, blockIndent, tabStops, bullet and display") );
 
        return as_value();
 

Index: server/asobj/TextFormat.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/TextFormat.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/asobj/TextFormat.cpp 10 Apr 2008 09:49:08 -0000      1.8
+++ server/asobj/TextFormat.cpp 10 Apr 2008 10:13:30 -0000      1.9
@@ -45,7 +45,7 @@
        _italic(false),
        _bullet(false),
        _block_indent(-1),
-       _color(0),
+       _color(),
        _indent(-1),
        _leading(-1),
        _left_margin(-1),
@@ -67,7 +67,7 @@
        boost::intrusive_ptr<TextFormat> tf = new TextFormat;
        if ( fn.nargs > 0  ) {  tf->fontSet(fn.arg(0).to_string());
        if ( fn.nargs > 1  ) {  tf->sizeSet(fn.arg(1).to_int());
-       if ( fn.nargs > 2  ) {  tf->colorSet(fn.arg(2).to_int()); // TODO: 
check this...
+       if ( fn.nargs > 2  ) {  rgba col; col.parseRGB(fn.arg(2).to_int()); 
tf->colorSet(col); 
        if ( fn.nargs > 3  ) {  tf->boldSet(fn.arg(3).to_bool()); 
        if ( fn.nargs > 4  ) {  tf->italicedSet(fn.arg(4).to_bool()); 
        if ( fn.nargs > 5  ) {  tf->underlinedSet(fn.arg(5).to_bool()); 
@@ -252,9 +252,21 @@
 }
 
 as_value
-TextFormat::color_getset(const fn_call& /*fn*/)
+TextFormat::color_getset(const fn_call& fn)
 {
-       ONCE( log_unimpl("TextField.color") );
+       boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
+
+       if ( fn.nargs == 0 ) // getter
+       {
+               return as_value(ptr->color().toRGB());
+       }
+       else // setter
+       {
+               rgba newcolor;
+               newcolor.parseRGB(fn.arg(0).to_int());
+               ptr->colorSet(newcolor);
+       }
+
        return as_value();
 }
 
@@ -270,8 +282,6 @@
        else // setter
        {
                ptr->sizeSet(PIXELS_TO_TWIPS(fn.arg(0).to_int()));
-               ONCE( log_debug("TextField.size setter TESTING") );
-
        }
 
        return as_value();

Index: server/asobj/TextFormat.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/TextFormat.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/asobj/TextFormat.h   10 Apr 2008 09:35:34 -0000      1.6
+++ server/asobj/TextFormat.h   10 Apr 2008 10:13:30 -0000      1.7
@@ -23,6 +23,7 @@
 
 #include "as_object.h" // for inheritance of TextFormat
 #include "edit_text_character_def.h" // for edit_text_character_def::alignment 
enum
+#include "types.h" // for rgba
 #include <boost/cstdint.hpp> // for boost::uint32_t
 #include <string>
 
@@ -52,10 +53,7 @@
        bool bullet()      { return _bullet; }
 
        /// Return the color of text using this text format.
-       //
-       /// A number containing three 8-bit RGB components; for example,
-        /// 0xFF0000 is red, 0x00FF00 is green.
-       boost::uint32_t color() const { return _color; }
+       const rgba& color() const { return _color; }
 
        /// \brief
        /// Return ann integer that indicates the indentation from the left
@@ -107,7 +105,7 @@
        void italicedSet(bool x)     { _italic = x; }
        void boldSet(bool x)         { _bold = x; }
        void bulletSet(bool x)       { _bullet = x; }
-       void colorSet(boost::uint32_t x)      { _color = x; }
+       void colorSet(const rgba& x)      { _color = x; }
        void indentSet(boost::uint16_t x)      { _indent = x; }
        void fontSet(const std::string& font) { _font=font; }
 
@@ -177,7 +175,7 @@
        //
        /// A number containing three 8-bit RGB components; for example,
         /// 0xFF0000 is red, 0x00FF00 is green.
-       boost::uint32_t _color; 
+       rgba _color;    
 
        // The name of a font for text as a string.
        std::string _font;      

Index: testsuite/misc-ming.all/DefineEditTextTest.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/DefineEditTextTest.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- testsuite/misc-ming.all/DefineEditTextTest.c        10 Apr 2008 09:49:09 
-0000      1.34
+++ testsuite/misc-ming.all/DefineEditTextTest.c        10 Apr 2008 10:13:31 
-0000      1.35
@@ -40,12 +40,15 @@
 
 SWFDisplayItem add_text_field(SWFMovie mo, SWFBlock font, const char* text,
        float indent, float leftMargin, float rightMargin, 
SWFTextFieldAlignment align,
-       float lineSpacing);
+       float lineSpacing,
+       unsigned int textR, unsigned int textG, unsigned int textB, unsigned 
int textA);
 
 SWFDisplayItem
 add_text_field(SWFMovie mo, SWFBlock font, const char* text, float indent,
                float leftMargin, float rightMargin,
-               SWFTextFieldAlignment align, float lineSpacing)
+               SWFTextFieldAlignment align, float lineSpacing,
+               unsigned int textR, unsigned int textG,
+               unsigned int textB, unsigned int textA)
 {
   SWFTextField tf;
 
@@ -57,6 +60,7 @@
   SWFTextField_setRightMargin(tf, rightMargin);
   SWFTextField_setAlignment(tf, align);
   SWFTextField_setLineSpacing(tf, lineSpacing);
+  SWFTextField_setColor(tf, textR, textG, textB, textA);
 
   /* setting flags seem unneeded */
   /*SWFTextField_setFlags(tf, SWFTEXTFIELD_USEFONT|SWFTEXTFIELD_NOEDIT);*/
@@ -152,15 +156,15 @@
     SWFBrowserFont bfont = newSWFBrowserFont("_sans");
     SWFFont efont = loadSWFFontFromFile(font_file);
 
-    it = add_text_field(mo, (SWFBlock)bfont, "Hello", 1, 2, 3, 
SWFTEXTFIELD_ALIGN_LEFT, 10);
+    it = add_text_field(mo, (SWFBlock)bfont, "Hello", 1, 2, 3, 
SWFTEXTFIELD_ALIGN_LEFT, 10, 100, 101, 102, 50);
     SWFDisplayItem_setName(it, "dtext1");
     SWFDisplayItem_moveTo(it, 0, 200);
-    it = add_text_field(mo, (SWFBlock)efont, "Hello", 4, 5, 6, 
SWFTEXTFIELD_ALIGN_CENTER, 11);
+    it = add_text_field(mo, (SWFBlock)efont, "Hello", 4, 5, 6, 
SWFTEXTFIELD_ALIGN_CENTER, 11, 110, 111, 112, 51);
     SWFDisplayItem_setName(it, "etext1");
     SWFDisplayItem_moveTo(it, 0, 300);
 
     SWFBrowserFont bfont2 = newSWFBrowserFont("times");
-    it = add_text_field(mo, (SWFBlock)bfont2, "Hello", 7, 8, 9, 
SWFTEXTFIELD_ALIGN_RIGHT, 12);
+    it = add_text_field(mo, (SWFBlock)bfont2, "Hello", 7, 8, 9, 
SWFTEXTFIELD_ALIGN_RIGHT, 12, 120, 121, 122, 52);
     SWFDisplayItem_setName(it, "dtext2");
     SWFDisplayItem_moveTo(it, 0, 400);
   }
@@ -230,9 +234,9 @@
   check_equals(mo, "dtext1.backgroundColor", "0xffffff");
   check_equals(mo, "etext1.backgroundColor", "0xffffff");
   check_equals(mo, "dtext2.backgroundColor", "0xffffff");
-  check_equals(mo, "dtext1.textColor", "0x000000");
-  check_equals(mo, "etext1.textColor", "0x000000");
-  check_equals(mo, "dtext2.textColor", "0x000000");
+  check_equals(mo, "dtext1.textColor", "6579558");
+  check_equals(mo, "etext1.textColor", "7237488");
+  check_equals(mo, "dtext2.textColor", "7895418");
   check_equals(mo, "dtext1._alpha", "100");
   check_equals(mo, "etext1._alpha", "100");
   check_equals(mo, "dtext2._alpha", "100");
@@ -247,19 +251,6 @@
   check_equals(mo, "typeof(etext1._ymouse)", "'number'"); 
   check_equals(mo, "typeof(dtext2._ymouse)", "'number'"); 
   
-  add_actions(mo, "dtext1.background = true;"
-                  "etext1.background = true;"
-                  "dtext2.background = true;"
-                  "dtext1.backgroundColor = 0xff0000;"
-                  "etext1.backgroundColor = 0x00ff00;"
-                  "dtext2.backgroundColor = 0x0000ff;"
-                  "dtext1.textColor = 0x00ffff;"
-                  "etext1.textColor = 0xff00ff;"
-                  "dtext2.textColor = 0xffff00;"
-                  "dtext1.text += ' world';"
-                  "etext1.text += ' world';"
-                  "dtext2.text += ' world';" );
-
   // TextFormat objects are created on the fly
   add_actions(mo,
        "etext1.tf = etext1.getTextFormat();"
@@ -299,6 +290,26 @@
   check_equals(mo, "typeof(dtext2.tf.leading)", "'number'");
   check_equals(mo, "etext1.tf.leading", "11");
   check_equals(mo, "dtext2.tf.leading", "12"); 
+  check_equals(mo, "typeof(etext1.tf.color)", "'number'");
+  check_equals(mo, "typeof(dtext2.tf.color)", "'number'");
+  check_equals(mo, "etext1.tf.color", "7237488");
+  check_equals(mo, "dtext2.tf.color", "7895418");
+
+  add_actions(mo, "dtext1.background = true;"
+                  "etext1.background = true;"
+                  "dtext2.background = true;"
+                  "dtext1.backgroundColor = 0xff0000;"
+                  "etext1.backgroundColor = 0x00ff00;"
+                  "dtext2.backgroundColor = 0x0000ff;"
+                  "dtext1.textColor = 0x00ffff;"
+                  "etext1.textColor = 0xff00ff;"
+                  "dtext2.textColor = 0xffff00;"
+                  "dtext1.text += ' world';"
+                  "etext1.text += ' world';"
+                  "dtext2.text += ' world';" );
+
+  check_equals(mo, "etext1.getTextFormat().color", "0xff00ff");
+  check_equals(mo, "dtext2.getTextFormat().color", "0xffff00"); 
 
   check_equals(mo, "dtext1.text", "'Hello world'");
   check_equals(mo, "etext1.text", "'Hello world'");




reply via email to

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