[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: |
Thu, 20 Sep 2007 14:07:31 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/09/20 14:07:31
Modified files:
. : ChangeLog
server : edit_text_character.cpp edit_text_character.h
sprite_instance.cpp
testsuite/misc-swfc.all: edittext_test1.sc
Log message:
* server/edit_text_character.{cpp,h}: add an updateText method
intended to be called by sprite_instance when a registered
text variable is updated; have set_text_value forward the
text change back to the sprite_instance where any
variable name is registered, for proper distribution of
the new text to any other TextField registered with the
same variable.
* server/sprite_instance.cpp (set_text_value): use the new
updateText to update TextField text when variable name is
updated.
* testsuite/misc-swfc.all/edittext_test1.sc: more successes.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4360&r2=1.4361
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.118&r2=1.119
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.349&r2=1.350
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-swfc.all/edittext_test1.sc?cvsroot=gnash&r1=1.4&r2=1.5
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4360
retrieving revision 1.4361
diff -u -b -r1.4360 -r1.4361
--- ChangeLog 20 Sep 2007 11:29:12 -0000 1.4360
+++ ChangeLog 20 Sep 2007 14:07:30 -0000 1.4361
@@ -1,5 +1,19 @@
2007-09-20 Sandro Santilli <address@hidden>
+ * server/edit_text_character.{cpp,h}: add an updateText method
+ intended to be called by sprite_instance when a registered
+ text variable is updated; have set_text_value forward the
+ text change back to the sprite_instance where any
+ variable name is registered, for proper distribution of
+ the new text to any other TextField registered with the
+ same variable.
+ * server/sprite_instance.cpp (set_text_value): use the new
+ updateText to update TextField text when variable name is
+ updated.
+ * testsuite/misc-swfc.all/edittext_test1.sc: more successes.
+
+2007-09-20 Sandro Santilli <address@hidden>
+
* server/edit_text_character.{cpp,h}: define a private method
to parse the text variable into a sprite_instance and property name
components, to be used later to update the state of a registered
Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -b -r1.118 -r1.119
--- server/edit_text_character.cpp 20 Sep 2007 11:29:13 -0000 1.118
+++ server/edit_text_character.cpp 20 Sep 2007 14:07:31 -0000 1.119
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: edit_text_character.cpp,v 1.118 2007/09/20 11:29:13 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.119 2007/09/20 14:07:31 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -695,24 +695,24 @@
}
void
-edit_text_character::set_text_value(const char* new_text_cstr)
+edit_text_character::updateText(const std::string& new_text)
{
- std::string new_text;
- if ( new_text_cstr ) new_text = new_text_cstr;
+ unsigned int maxLen = m_def->get_max_length();
- if (_text == new_text)
+ std::string newText = new_text; // copy needed for eventual resize
+ if (maxLen && newText.length() > maxLen )
+ {
+ newText.resize(maxLen);
+ }
+
+ if (_text == newText)
{
return;
}
set_invalidated();
- _text = new_text;
- if (m_def->get_max_length() > 0
- && _text.length() > m_def->get_max_length() )
- {
- _text.resize(m_def->get_max_length());
- }
+ _text = newText;
format_text();
@@ -720,6 +720,31 @@
}
+void
+edit_text_character::set_text_value(const char* new_text_cstr)
+{
+ std::string newText;
+ if ( new_text_cstr ) newText = new_text_cstr;
+
+ updateText(newText);
+
+ if ( ! _variable_name.empty() && _text_variable_registered )
+ {
+ // TODO: notify sprite_instance if we have a variable name !
+ VariableRef ref = parseTextVariableRef(_variable_name);
+ sprite_instance* sp = ref.first;
+ if ( sp )
+ {
+ sp->set_member(ref.second, newText); // we shouldn't
truncate, right ?
+ }
+ else
+ {
+ // nothing to do (too early ?)
+ log_debug("set_text_value: variable name %s points to
an unexisting sprite", _variable_name.c_str());
+ }
+ }
+}
+
std::string
edit_text_character::get_text_value() const
{
Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- server/edit_text_character.h 20 Sep 2007 11:29:13 -0000 1.52
+++ server/edit_text_character.h 20 Sep 2007 14:07:31 -0000 1.53
@@ -96,8 +96,18 @@
void set_variable_name(const std::string& newname);
/// Set our text to the given string.
+ //
+ /// This function will also update any registered variable
+ ///
void set_text_value(const char* new_text);
+ /// Set our text to the given string by effect of an update of a
registered variable name
+ //
+ /// This cal only updates the text and is only meant to be called by
ourselves
+ /// or by sprite_instance when a registered TextVariable is updated.
+ ///
+ void updateText(const std::string& s);
+
/// Return value of our text.
std::string get_text_value() const;
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.349
retrieving revision 1.350
diff -u -b -r1.349 -r1.350
--- server/sprite_instance.cpp 20 Sep 2007 09:51:12 -0000 1.349
+++ server/sprite_instance.cpp 20 Sep 2007 14:07:31 -0000 1.350
@@ -2209,7 +2209,7 @@
for (TextFieldPtrVect::iterator i=etc->begin(), e=etc->end();
i!=e; ++i)
{
TextFieldPtr tf = *i;
- tf->set_text_value(val.to_string(env).c_str());
+ tf->updateText(val.to_string(env));
}
}
#ifdef DEBUG_DYNTEXT_VARIABLES
Index: testsuite/misc-swfc.all/edittext_test1.sc
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-swfc.all/edittext_test1.sc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- testsuite/misc-swfc.all/edittext_test1.sc 20 Sep 2007 08:43:35 -0000
1.4
+++ testsuite/misc-swfc.all/edittext_test1.sc 20 Sep 2007 14:07:31 -0000
1.5
@@ -74,7 +74,7 @@
// (the InitialText in DefineTextField tag, make sense!)
check_equals(_root.textVar2, 'Hello');
check_equals(edtext1.text, 'Hello');
- xcheck_equals(_root.textVar1, 'new-string-frame3');
+ check_equals(_root.textVar1, 'new-string-frame3');
.end
@@ -85,7 +85,7 @@
check_equals(edtext1.variable, 'textVar1');
// edtext1.text also restore to the value of
// _root.textVar1(the registered variable)
- xcheck_equals(edtext1.text, 'new-string-frame3');
+ check_equals(edtext1.text, 'new-string-frame3');
.end
@@ -93,14 +93,14 @@
.action:
edtext1.text = 'new-string-frame6';
check_equals(edtext1.text, 'new-string-frame6');
- xcheck_equals(_root.textVar1, 'new-string-frame6');
+ check_equals(_root.textVar1, 'new-string-frame6');
// Rename the EditText variable to 'textVar3'
edtext1.variable = 'textVar3';
// textVar3 automatically initialized to 'Hello'
// (the InitialText in DefineTextField tag, make sense!)
check_equals(_root.textVar3, 'Hello');
- xcheck_equals(_root.textVar1, 'new-string-frame6');
+ check_equals(_root.textVar1, 'new-string-frame6');
.end
.frame 7
@@ -145,7 +145,7 @@
.action:
edtext2.text = 'value_changed';
check_equals(edtext2.text, 'value_changed');
- xcheck_equals(textVar4, 'value_changed');
+ check_equals(textVar4, 'value_changed');
.end
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Sandro Santilli, 2007/09/04
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Ivor Blockley, 2007/09/05
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Sandro Santilli, 2007/09/17
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Sandro Santilli, 2007/09/19
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Sandro Santilli, 2007/09/20
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...,
Sandro Santilli <=
- [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ..., Sandro Santilli, 2007/09/20