[GEM-cvs] Gem/src/Controls gemlist.cpp, NONE, 1.1 gemlist.h, NONE, 1.1
Brought to you by:
zmoelnig
From: Cyrille H. <nu...@us...> - 2008-01-05 22:03:12
|
Update of /cvsroot/pd-gem/Gem/src/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12078/d/Controls Added Files: gemlist.cpp gemlist.h Log Message: add gemlist object --- NEW FILE: gemlist.h --- /*----------------------------------------------------------------- LOG GEM - Graphics Environment for Multimedia this object work with gemlist exactly like pd [float] work with float Copyright (c) 1997-1999 Mark Danks. ma...@da... Copyright (c) Günther Geiger. ge...@ep... Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmo...@ie... For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. -----------------------------------------------------------------*/ #ifndef INCLUDE_GEMLIST_H_ #define INCLUDE_GEMLIST_H_ #include "Base/GemBase.h" /*----------------------------------------------------------------- ------------------------------------------------------------------- CLASS gemlist DESCRIPTION "gemlist" - send the curent gemlist when banged. The curent gemlist can be set via the hot or cold inlet -----------------------------------------------------------------*/ class GEM_EXTERN gemlist : public GemBase { CPPEXTERN_HEADER(gemlist, GemBase) public: ////////// // Constructor gemlist(); protected: ////////// // Destructor virtual ~gemlist(); ////////// // Push the current state virtual void render(GemState *state); ////////// virtual void postrender(GemState *state); ////////// void trigger(); ////////// // curent state GemState* m_curent_state; ///////// bool m_valide_state; ////////// t_inlet *m_inlet; virtual void rightRender(GemState *state); private: ////////// // Static member callbacks static void triggerMessCallback(void *data); static void gem_rightMessCallback(void *x, t_symbol *s, int argc, t_atom *argv); }; #endif // for header file --- NEW FILE: gemlist.cpp --- //////////////////////////////////////////////////////// // // GEM - Graphics Environment for Multimedia // // ch...@ch... // // Implementation file // // Copyright (c) 1997-1999 Mark Danks. // Copyright (c) Günther Geiger. // Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM // For information on usage and redistribution, and for a DISCLAIMER OF ALL // WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. // ///////////////////////////////////////////////////////// #include "gemlist.h" #include "Base/GemState.h" CPPEXTERN_NEW(gemlist) ///////////////////////////////////////////////////////// // // gemlist // ///////////////////////////////////////////////////////// // Constructor // ///////////////////////////////////////////////////////// gemlist :: gemlist() { m_inlet = inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("gem_state"), gensym("gem_right")); // create the cold inlet m_valide_state=false; } ///////////////////////////////////////////////////////// // Destructor // ///////////////////////////////////////////////////////// gemlist :: ~gemlist() { inlet_free(m_inlet); } ///////////////////////////////////////////////////////// // render // ///////////////////////////////////////////////////////// void gemlist :: render(GemState *state) { m_curent_state=state; //copy curent state for later use m_valide_state=true; } ///////////////////////////////////////////////////////// // postrender // ///////////////////////////////////////////////////////// void gemlist :: postrender(GemState *) { // m_valide_state=false; // this is to early to reset the m_valide_state // when should we call this??? // TODO : fix this. } ///////////////////////////////////////////////////////// // bang // ///////////////////////////////////////////////////////// void gemlist :: trigger() { if(m_valide_state) { // outlet the curent state when banged t_atom ap[2]; ap->a_type=A_POINTER; ap->a_w.w_gpointer=(t_gpointer *)m_cache; (ap+1)->a_type=A_POINTER; (ap+1)->a_w.w_gpointer=(t_gpointer *)m_curent_state; outlet_anything(this->m_out1, gensym("gem_state"), 2, ap); } else error("you should not bang the gemlist now"); } ///////////////////////////////////////////////////////// // rightRender // ///////////////////////////////////////////////////////// void gemlist :: rightRender(GemState *state) { m_curent_state=state; m_valide_state=true; // get the curent state on the right inlet } ///////////////////////////////////////////////////////// // static member function // ///////////////////////////////////////////////////////// void gemlist :: obj_setupCallback(t_class *classPtr) { class_addbang(classPtr, (t_method)&gemlist::triggerMessCallback); class_addmethod(classPtr, (t_method)&gemlist::gem_rightMessCallback, gensym("gem_right"), A_GIMME, A_NULL); } void gemlist::triggerMessCallback(void *data) { GetMyClass(data)->trigger(); } void gemlist::gem_rightMessCallback(void *data, t_symbol *s, int argc, t_atom *argv) { if (argc==1 && argv->a_type==A_FLOAT){ } else if (argc==2 && argv->a_type==A_POINTER && (argv+1)->a_type==A_POINTER){ GetMyClass(data)->m_cache = (GemCache*)argv->a_w.w_gpointer; GetMyClass(data)->rightRender((GemState *)(argv+1)->a_w.w_gpointer); } else GetMyClass(data)->error("wrong righthand arguments...."); } |