gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash/server Key.cpp button.cpp


From: Vitaly Alexeev
Subject: [Gnash-commit] gnash/server Key.cpp button.cpp
Date: Wed, 05 Jul 2006 12:43:49 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Vitaly Alexeev <alexeev>        06/07/05 12:43:49

Modified files:
        server         : Key.cpp button.cpp 

Log message:
        added button keypress event handler

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Key.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button.cpp?cvsroot=gnash&r1=1.18&r2=1.19

Patches:
Index: Key.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/Key.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Key.cpp     24 Jun 2006 16:04:06 -0000      1.6
+++ Key.cpp     5 Jul 2006 12:43:49 -0000       1.7
@@ -398,6 +398,7 @@
                        return;
                }
        }
+       listener->add_ref();
        s_keypress_listeners.push_back(listener);
 }
 
@@ -409,6 +410,7 @@
                if (*iter == listener)
                {
                        iter = s_keypress_listeners.erase(iter);
+                       listener->drop_ref();
                        continue;
                }
                iter++;

Index: button.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- button.cpp  1 Jul 2006 20:44:10 -0000       1.18
+++ button.cpp  5 Jul 2006 12:43:49 -0000       1.19
@@ -14,6 +14,8 @@
 #include "stream.h"
 #include "movie_definition.h"
 #include "sprite_instance.h"
+#include "Key.h"
+
 
 
 /** \page buttons Buttons and mouse behaviour
@@ -321,21 +323,84 @@
                        const matrix&   mat = 
m_def->m_button_records[r].m_button_matrix;
                        const cxform&   cx = 
m_def->m_button_records[r].m_button_cxform;
 
-                       // Vitaly: hack, FIXME
-                       //smart_ptr<character> ch = 
bdef->m_character_def->create_character_instance((sprite_instance*)this, id);
                        smart_ptr<character> ch = 
bdef->m_character_def->create_character_instance(this, id);
-                       //smart_ptr<character> ch = 
bdef->m_character_def->create_character_instance(parent /*must be this*/, id);
                        m_record_character[r] = ch;
                        ch->set_matrix(mat);
                        ch->set_cxform(cx);
                        ch->restart();
                }
+
+               // check up presence KeyPress events
+               for (unsigned int i = 0; i < m_def->m_button_actions.size(); 
i++)
+               {
+                       if (m_def->m_button_actions[i].m_conditions & 0xFE00)   
// check up on CondKeyPress: UB[7]
+                       {
+                               add_keypress_listener(this);
+                               break;
+                       }
+               }
+
        }
 
        ~button_character_instance()
        {
        }
 
+       // called from keypress listener only
+       bool on_event(event_id id)
+       {
+
+               if (id.m_id != event_id::KEY_PRESS)
+               {
+                       return false;
+               }
+
+               bool called = false;
+
+               static const event_id s_key[32] =
+               {
+                       event_id(),
+                       event_id(event_id::KEY_PRESS, key::LEFT),
+                       event_id(event_id::KEY_PRESS, key::RIGHT),
+                       event_id(event_id::KEY_PRESS, key::HOME),
+                       event_id(event_id::KEY_PRESS, key::END),
+                       event_id(event_id::KEY_PRESS, key::INSERT),
+                       event_id(event_id::KEY_PRESS, key::DELETEKEY),
+                       event_id(),
+                       event_id(event_id::KEY_PRESS, key::BACKSPACE),  //8
+                       event_id(),
+                       event_id(),
+                       event_id(),
+                       event_id(),
+                       event_id(event_id::KEY_PRESS, key::ENTER),      //13
+                       event_id(event_id::KEY_PRESS, key::UP),
+                       event_id(event_id::KEY_PRESS, key::DOWN),
+                       event_id(event_id::KEY_PRESS, key::PGUP),
+                       event_id(event_id::KEY_PRESS, key::PGDN),
+                       event_id(event_id::KEY_PRESS, key::TAB),
+                       // 32-126 folows ASCII
+               };
+
+
+               // Add appropriate actions to the movie's execute list...
+               for (unsigned int i = 0; i < m_def->m_button_actions.size(); 
i++)
+               {
+                       int keycode = (m_def->m_button_actions[i].m_conditions 
& 0xFE00) >> 9;
+                       event_id key_event = keycode < 32 ? s_key[keycode] : 
event_id(event_id::KEY_PRESS, (key::code) keycode);
+                       if (key_event == id)
+                       {
+                               // Matching action.
+                               for (unsigned int j = 0; j < 
m_def->m_button_actions[i].m_actions.size(); j++)
+                               {
+                                       
get_parent()->add_action_buffer(m_def->m_button_actions[i].m_actions[j]);
+                               }
+                               called = true;
+                       }
+               }
+
+               return called;
+       }
+
        movie_root*     get_root() { return get_parent()->get_root(); }
 
        void    restart()




reply via email to

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