[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv... |
Date: |
Thu, 21 Sep 2006 13:54:45 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/09/21 13:54:45
Modified files:
. : ChangeLog
server : sprite_instance.cpp sprite_instance.h
Log message:
sprite_instance: public method and a lazily-allocated map for textfield
variables; scan textfield variable names in both set_member and get_member;
compiler warnings removed
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.894&r2=1.895
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.55&r2=1.56
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.25&r2=1.26
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.894
retrieving revision 1.895
diff -u -b -r1.894 -r1.895
--- ChangeLog 21 Sep 2006 12:41:39 -0000 1.894
+++ ChangeLog 21 Sep 2006 13:54:45 -0000 1.895
@@ -1,3 +1,9 @@
+2006-09-21 Sandro Santilli <address@hidden>
+
+ * server/sprite_instance.{h,cpp}: added new set_textfield_variable
+ public method and a lazily-allocated map for textfield variables;
+ scan textfield variable names in both set_member and get_member.
+
2006-09-21 Markus Gothe <address@hidden>
* libbase/yasper: Added "Yet Another SmrtPtr Library".
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- server/sprite_instance.cpp 20 Sep 2006 17:23:57 -0000 1.55
+++ server/sprite_instance.cpp 21 Sep 2006 13:54:45 -0000 1.56
@@ -945,6 +945,13 @@
return true;
}
+ // Try textfield variables
+ edit_text_character* etc = get_textfield_variable(name.c_str());
+ if ( etc )
+ {
+ val->set_string(etc->get_text_value());
+ }
+
return false;
}
@@ -1027,7 +1034,7 @@
}
// TODO
-character* sprite_instance::add_empty_movieclip(const char* name, int depth)
+character* sprite_instance::add_empty_movieclip(const char* /*name*/, int
/*depth*/)
{
// cxform color_transform;
// matrix matrix;
@@ -1044,6 +1051,7 @@
// 0);
// return sprite;
+ log_warning("add_empty_movieclip unimplemented");
return NULL;
}
@@ -1145,6 +1153,9 @@
void sprite_instance::set_member(const tu_stringi& name,
const as_value& val)
{
+#ifdef DEBUG_DYNTEXT_VARIABLES
+log_msg("sprite[%p]::set_member(%s, %s)", (void*)this, name.c_str(),
val.to_string());
+#endif
as_standard_member std_member = get_standard_member(name);
switch (std_member)
{
@@ -1359,6 +1370,26 @@
}
}
+#ifdef DEBUG_DYNTEXT_VARIABLES
+log_msg(" not a standard member nor a character");
+#endif
+
+ // Try textfield variables
+ edit_text_character* etc = get_textfield_variable(name.c_str());
+ if ( etc )
+ {
+#ifdef DEBUG_DYNTEXT_VARIABLES
+log_msg(" it's a Text Variable!");
+#endif
+ etc->set_text_value(val.to_string());
+ }
+#ifdef DEBUG_DYNTEXT_VARIABLES
+ else
+ {
+log_msg(" it's NOT a Text Variable!");
+ }
+#endif
+
// If that didn't work, set a variable within this environment.
m_as_environment.set_member(name, val);
}
@@ -2302,4 +2333,41 @@
{
m_root->set_background_color(color);
}
+
+/* public */
+void
+sprite_instance::set_textfield_variable(const std::string& name,
+ edit_text_character* ch)
+{
+ assert(ch);
+
+ // lazy allocation
+ if ( ! _text_variables.get() )
+ {
+ _text_variables.reset(new TextfieldMap);
+ }
+
+ // TODO: should variable name be considered case-insensitive ?
+ _text_variables->operator[] (name) = ch;
+}
+
+/* private */
+edit_text_character*
+sprite_instance::get_textfield_variable(const std::string& name)
+{
+ // nothing allocated yet...
+ if ( _text_variables.get() == NULL ) return NULL;
+
+ // TODO: should variable name be considered case-insensitive ?
+ TextfieldMap::iterator it = _text_variables->find(name);
+ if ( it == _text_variables->end() )
+ {
+ return NULL;
+ }
+ else
+ {
+ return it->second.get_ptr();
+ }
+}
+
} // namespace gnash
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/sprite_instance.h 21 Sep 2006 10:13:11 -0000 1.25
+++ server/sprite_instance.h 21 Sep 2006 13:54:45 -0000 1.26
@@ -46,7 +46,9 @@
#endif
#include <vector>
+#include <map>
+#include "edit_text_character.h" // temp hack
#include "movie_definition.h" // for inlines
#include "dlist.h" // DisplayList
//#include "stream.h"
@@ -56,6 +58,7 @@
// Forward declarations
namespace gnash {
class movie_root;
+ //class edit_text_character;
}
namespace gnash
@@ -481,8 +484,22 @@
}
}
+ as_environment& get_environment() {
+ return m_as_environment;
+ }
+
+ /// \brief
+ /// Set a TextField variable to this timeline
+ //
+ /// A TextField variable is a variable that acts
+ /// as a setter/getter for a TextField 'text' member.
+ ///
+ void set_textfield_variable(const std::string& name,
+ edit_text_character* ch);
+
private:
+
mouse_state m_mouse_state;
/// \brief
@@ -524,6 +541,28 @@
float m_frame_time;
bool m_has_keypress_event;
+ /// A container for textfields, indexed by their variable name
+ typedef std::map< std::string, smart_ptr<edit_text_character> >
TextfieldMap;
+
+ /// We'll only allocate Textfield variables map if
+ /// we need them (ie: anyone calls set_textfield_variable)
+ ///
+ std::auto_ptr<TextfieldMap> _text_variables;
+
+ /// \brief
+ /// Returns a TextField given it's variable name,
+ /// or NULL if no such variable name is known.
+ //
+ /// A TextField variable is a variable that acts
+ /// as a setter/getter for a TextField 'text' member.
+ ///
+ /// Search is case-sensitive.
+ ///
+ /// @todo find out wheter we should be case sensitive or not
+ ///
+ edit_text_character* get_textfield_variable(const std::string& name);
+
+
protected:
bool m_on_event_load_called;
- [Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv...,
Sandro Santilli <=