From a90ba60492c6a20536cbaceff47c65f43ff654ce Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Thu, 21 Nov 2013 14:59:49 -0500 Subject: [PATCH] Added Jonathan Wilkes' patch for improved classinfo, canvasinfo, and pdinfo objects. --- pd/src/m_pd.h | 5 ++++- pd/src/x_interface.c | 33 +++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/pd/src/m_pd.h b/pd/src/m_pd.h index 571177a48..c6131db15 100644 --- a/pd/src/m_pd.h +++ b/pd/src/m_pd.h @@ -11,7 +11,7 @@ extern "C" { #define PD_MAJOR_VERSION 0 #define PD_MINOR_VERSION 42 #define PD_BUGFIX_VERSION 7 -#define PD_TEST_VERSION "20130906" +#define PD_TEST_VERSION "20131117" #define PDL2ORK /* old name for "MSW" flag -- we have to take it for the sake of many old @@ -448,6 +448,9 @@ EXTERN void class_set_extern_dir(t_symbol *s); #define CLASS_MAINSIGNALIN(c, type, field) \ class_domainsignalin(c, (char *)(&((type *)0)->field) - (char *)0) + /* classtable functions */ +EXTERN t_class *classtable_findbyname(t_symbol *s); + /* prototype for functions to save Pd's to a binbuf */ typedef void (*t_savefn)(t_gobj *x, t_binbuf *b); EXTERN void class_setsavefn(t_class *c, t_savefn f); diff --git a/pd/src/x_interface.c b/pd/src/x_interface.c index cae5e20f7..1803d9027 100644 --- a/pd/src/x_interface.c +++ b/pd/src/x_interface.c @@ -17,8 +17,6 @@ #define MAXNDEV 20 #define DEVDESCSIZE 80 -extern t_class *classtable_findbyname(t_symbol *s); - /* -------------------------- print ------------------------------ */ t_class *print_class; @@ -268,18 +266,22 @@ void canvasinfo_filename(t_canvasinfo *x, t_symbol *s, int argc, t_atom *argv) void canvasinfo_hitbox(t_canvasinfo *x, t_floatarg xpos, t_floatarg ypos) { t_canvas *c = canvasinfo_dig(x); - int x1, y1, x2, y2; + int x1, y1, x2, y2, indexno; t_gobj *ob = canvas_findhitbox(c, xpos, ypos, &x1, &y1, &x2, &y2); if (ob) { - t_atom at[5]; + t_gobj *y; + for (indexno = 0, y = c->gl_list; y && y != ob; y = y->g_next) + indexno++; + t_atom at[6]; char *classname = class_getname(ob->g_pd); SETSYMBOL(at, gensym(classname)); - SETFLOAT(at+1, (t_float)x1); - SETFLOAT(at+2, (t_float)y1); - SETFLOAT(at+3, (t_float)x2); - SETFLOAT(at+4, (t_float)y2); - info_out((t_text *)x, gensym("hitbox"), 5, at); + SETFLOAT(at+1, (t_float)indexno); + SETFLOAT(at+2, (t_float)x1); + SETFLOAT(at+3, (t_float)y1); + SETFLOAT(at+4, (t_float)x2); + SETFLOAT(at+5, (t_float)y2); + info_out((t_text *)x, gensym("hitbox"), 6, at); } else info_out((t_text *)x, gensym("hitbox"), 0, 0); @@ -953,13 +955,16 @@ void classinfo_setup(void) post("classinfo: v.0.1"); post("stable classinfo methods: size"); -/* todo: add "instance" method to return instances of a class on a canvas */ +/* + todo: make an objectinfo class to get the kind of info that canvasinfo "hitbox" + currently gives +*/ } void x_interface_setup(void) { - print_setup(); - canvasinfo_setup(); - pdinfo_setup(); - classinfo_setup(); + print_setup(); + canvasinfo_setup(); + pdinfo_setup(); + classinfo_setup(); } -- GitLab