[Top][All Lists]
[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 03:35:38 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/07/18 03:35:38
Modified files:
. : ChangeLog
server : edit_text_character.cpp edit_text_character.h
types.h
Log message:
* server/types.h: Add rgba::toRGB for serializing back to a
number.
* server/edit_text_character.{cpp,h}: use instance members and
getter-setters to keep info about background and border.
This should fix invalidated bounds computation.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3752&r2=1.3753
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.76&r2=1.77
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/server/types.h?cvsroot=gnash&r1=1.13&r2=1.14
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3752
retrieving revision 1.3753
diff -u -b -r1.3752 -r1.3753
--- ChangeLog 18 Jul 2007 02:44:18 -0000 1.3752
+++ ChangeLog 18 Jul 2007 03:35:37 -0000 1.3753
@@ -1,3 +1,10 @@
+2007-07-18 Sandro Santilli <address@hidden>
+
+ * server/types.h: Add rgba::toRGB for serializing back to a number.
+ * server/edit_text_character.{cpp,h}: use instance members and
+ getter-setters to keep info about background and border.
+ This should fix invalidated bounds computation.
+
2007-07-18 Zou Lunkai <address@hidden>
* testsuite/misc-ming.all/DefineEditTextTest.c: xchecks to checks, more
Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- server/edit_text_character.cpp 18 Jul 2007 02:26:53 -0000 1.76
+++ server/edit_text_character.cpp 18 Jul 2007 03:35:38 -0000 1.77
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: edit_text_character.cpp,v 1.76 2007/07/18 02:26:53 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.77 2007/07/18 03:35:38 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -63,6 +63,11 @@
static as_value textfield_replaceText(const fn_call& fn);
static as_object* getTextFieldInterface();
+static as_value textfield_background_getset(const fn_call& fn);
+static as_value textfield_border_getset(const fn_call& fn);
+static as_value textfield_backgroundColor_getset(const fn_call& fn);
+static as_value textfield_borderColor_getset(const fn_call& fn);
+
namespace
{
@@ -290,6 +295,7 @@
if ( target_version < 6 ) return;
// SWF6 or higher
+
boost::intrusive_ptr<builtin_function> variable_getter(new
builtin_function(&textfield_get_variable, NULL));
boost::intrusive_ptr<builtin_function> variable_setter(new
builtin_function(&textfield_set_variable, NULL));
o.init_property("variable", *variable_getter, *variable_setter);
@@ -303,6 +309,20 @@
o.init_member("getDepth", new builtin_function(textfield_getDepth));
o.init_member("removeTextField", new
builtin_function(textfield_removeTextField));
o.init_member("replaceSel", new builtin_function(textfield_replaceSel));
+
+ // The following properties should only be attached to the prototype
+ // on first textfield creation. We won't get to that detail of
compatibility,
+ // seeming not important
+ boost::intrusive_ptr<builtin_function> getset;
+ getset = new builtin_function(textfield_background_getset);
+ o.init_property("background", *getset, *getset);
+ getset = new builtin_function(textfield_backgroundColor_getset);
+ o.init_property("backgroundColor", *getset, *getset);
+ getset = new builtin_function(textfield_borderColor_getset);
+ o.init_property("border", *getset, *getset);
+ getset = new builtin_function(textfield_border_getset);
+ o.init_property("borderColor", *getset, *getset);
+
if ( target_version < 7 ) return;
// SWF7 or higher
@@ -356,7 +376,11 @@
m_xcursor(0.0f),
m_ycursor(0.0f),
_text_variable_registered(false),
- _variable_name(m_def->get_variable_name())
+ _variable_name(m_def->get_variable_name()),
+ _drawBackground(false),
+ _backgroundColor(255,255,255,255),
+ _drawBorder(m_def->has_border()),
+ _borderColor(0,0,0,255)
{
assert(parent);
assert(m_def);
@@ -415,8 +439,8 @@
rect def_bounds = m_def->get_bounds();
- bool drawBorder = hasBorder();
- bool drawBackground = hasBackground();
+ bool drawBorder = getDrawBorder();
+ bool drawBackground = getDrawBackground();
if ( drawBorder || drawBackground )
{
matrix mat = get_world_matrix();
@@ -438,6 +462,8 @@
rgba borderColor = drawBorder ? getBorderColor() :
rgba(0,0,0,0);
rgba backgroundColor = drawBackground ? getBackgroundColor() :
rgba(255,255,255,0);
+ //log_debug("Border color : %s, Background color : %s",
borderColor.toString().c_str(), backgroundColor.toString().c_str());
+
render::draw_poly( &coords[0], 4, backgroundColor, borderColor
);
}
@@ -748,6 +774,8 @@
// members are changed we should call set_invalidated !
// Note that *deleting* these members might need to have
// the same effect too (to be tested)
+ //
+ log_debug("Calling set_member_default(%s, xxx)", name.c_str());
set_member_default(name, val);
}
@@ -1344,65 +1372,144 @@
}
bool
-edit_text_character::hasBorder() const
+edit_text_character::getDrawBorder() const
{
- // TODO: check the 'border' member too !
- return m_def->has_border();
+ return _drawBorder;
+}
+
+void
+edit_text_character::setDrawBorder(bool val)
+{
+ if ( _drawBorder != val )
+ {
+ set_invalidated();
+ _drawBorder = val;
+ }
}
rgba
edit_text_character::getBorderColor() const
{
- // Background color is white by default
- rgba col(0,0,0,255);
+ return _borderColor;
+}
- // 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;
+void
+edit_text_character::setBorderColor(const rgba& col)
+{
+ if ( _borderColor != col )
+ {
+ set_invalidated();
+ _borderColor = col;
+ }
}
bool
-edit_text_character::hasBackground() const
+edit_text_character::getDrawBackground() 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();
+ return _drawBackground;
+}
+
+void
+edit_text_character::setDrawBackground(bool val)
+{
+ if ( _drawBackground != val )
+ {
+ log_debug("Setting draw background to %d", val);
+ set_invalidated();
+ _drawBackground = val;
+ }
}
rgba
edit_text_character::getBackgroundColor() const
{
- // Background color is white by default
- rgba col(255,255,255,255);
+ return _backgroundColor;
+}
+
+void
+edit_text_character::setBackgroundColor(const rgba& col)
+{
+ if ( _backgroundColor != col )
+ {
+ log_debug("Setting background color to %s",
col.toString().c_str());
+ set_invalidated();
+ _backgroundColor = col;
+ }
+}
+
+static as_value
+textfield_background_getset(const fn_call& fn)
+{
+ GNASH_REPORT_FUNCTION;
+ boost::intrusive_ptr<edit_text_character> ptr =
ensureType<edit_text_character>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->getDrawBackground());
+ }
+ else // setter
+ {
+ ptr->setDrawBackground(fn.arg(0).to_bool());
+ }
+
+ return as_value();
+}
+
+static as_value
+textfield_border_getset(const fn_call& fn)
+{
+ boost::intrusive_ptr<edit_text_character> ptr =
ensureType<edit_text_character>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->getDrawBorder());
+ }
+ else // setter
+ {
+ ptr->setDrawBorder(fn.arg(0).to_bool());
+ }
+
+ return as_value();
+}
+
+static as_value
+textfield_backgroundColor_getset(const fn_call& fn)
+{
+ GNASH_REPORT_FUNCTION;
+
+ boost::intrusive_ptr<edit_text_character> ptr =
ensureType<edit_text_character>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->getBackgroundColor().toRGB());
+ }
+ else // setter
+ {
+ rgba newColor;
+ newColor.parseRGB( fn.arg(0).to_number<uint32_t>(&fn.env()) );
+ ptr->setBackgroundColor(newColor);
+ }
- // 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 as_value();
+}
- return col;
+static as_value
+textfield_borderColor_getset(const fn_call& fn)
+{
+ boost::intrusive_ptr<edit_text_character> ptr =
ensureType<edit_text_character>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->getBorderColor().toRGB());
+ }
+ else // setter
+ {
+ rgba newColor;
+ newColor.parseRGB( fn.arg(0).to_number<uint32_t>(&fn.env()) );
+ ptr->setBorderColor(newColor);
+ }
+
+ return as_value();
}
} // namespace gnash
Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- server/edit_text_character.h 18 Jul 2007 02:26:53 -0000 1.36
+++ server/edit_text_character.h 18 Jul 2007 03:35:38 -0000 1.37
@@ -105,23 +105,46 @@
// See dox in character.h
void unload();
-private:
-
- /// Return true if HTML was allowed by definition
- bool htmlAllowed() const { return m_def->htmlAllowed(); }
+ /// Return true if the 'background' should be drawn
+ bool getDrawBackground() const;
- /// Return true if the 'background' member is set to true
- bool hasBackground() const;
+ /// Specify wheter to draw the background
+ void setDrawBackground(bool draw);
- /// Return the value of 'backgroundColor', or solid white if undefined.
+ /// Return color of the background
rgba getBackgroundColor() const;
+ /// Set color of the background
+ //
+ /// Use setDrawBackground to actually use this value.
+ ///
+ void setBackgroundColor(const rgba& col);
+
/// Return true if this TextField should have it's border visible
- bool hasBorder() const;
+ bool getDrawBorder() const;
+
+ /// Specify wheter to draw the border
+ void setDrawBorder(bool draw);
- /// Return the value of 'borderColor', or solid black if undefined.
+ /// Return color of the border
rgba getBorderColor() const;
+ /// Set color of the border
+ //
+ /// Use setDrawBorder to actually use this value.
+ ///
+ void setBorderColor(const rgba& col);
+
+private:
+
+ /// Return true if HTML text is allowed
+ //
+ /// TODO: use own flag for this, don't query the definition
+ /// everytime. This will allow support for the
+ /// ActionScript settable 'html' property.
+ ///
+ bool htmlAllowed() const { return m_def->htmlAllowed(); }
+
/// The actual text
std::string _text;
@@ -203,6 +226,14 @@
/// 'TextFields.variable'
std::string _variable_name;
+ bool _drawBackground;
+
+ rgba _backgroundColor;
+
+ bool _drawBorder;
+
+ rgba _borderColor;
+
protected:
#ifdef GNASH_USE_GC
Index: server/types.h
===================================================================
RCS file: /sources/gnash/gnash/server/types.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/types.h 18 Jul 2007 01:47:01 -0000 1.13
+++ server/types.h 18 Jul 2007 03:35:38 -0000 1.14
@@ -58,7 +58,8 @@
/// Parse a 32-bit unsigned integer
/// as three packed R,G,B bytes.
//
- /// Alpha will be untouched
+ /// Alpha will be untouched.
+ /// Blue is the least significant byte.
///
void parseRGB(uint32_t rgbCol)
{
@@ -67,6 +68,17 @@
m_b = (uint8_t)(rgbCol);
}
+ /// \brief
+ /// Return a 32-bit unsigned integer
+ /// as four packed R,G,B bytes.
+ //
+ /// Blue is the least significant byte.
+ ///
+ uint32_t toRGB()
+ {
+ return (m_r<<16) + (m_g<<8) + m_b;
+ }
+
/// Initialize from intput stream.
//
///
@@ -105,6 +117,16 @@
// neater string output (example: "0,0,0,255")
std::string toShortString() const;
+
+ bool operator== (const rgba& o) const
+ {
+ return m_r == o.m_r && m_g == o.m_g && m_b == o.m_b &&
m_a == o.m_a;
+ }
+
+ bool operator!= (const rgba& o) const
+ {
+ return ! ( *this == o );
+ }
};
std::ostream& operator<< (std::ostream& os, const rgba& r);
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Sandro Santilli, 2007/07/02
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Sandro Santilli, 2007/07/11
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Sandro Santilli, 2007/07/11
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Sandro Santilli, 2007/07/17
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...,
Sandro Santilli <=
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Udo Giacomozzi, 2007/07/20
- Re[2]: [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Udo Giacomozzi, 2007/07/23
- Re: [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., strk, 2007/07/23
- Re: [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., strk, 2007/07/22