Personal tools
You are here: Home community conventions graz 2004 Old Documents, wikis, etc... content CSpd Tooltips for pd-0.38
Views

'Common subdirectories: ../../old/pd-0.38-0test7/src/autom4te.cache and ./autom4te.cache diff -u ../../old/pd-0.38-0test7/src/g_canvas.h ./g_canvas.h --- ../../old/pd-0.38-0test7/src/g_canvas.h 2004-09-05 19:37:44.000000000 +0200 +++ ./g_canvas.h 2004-10-02 11:42:09.600472632 +0200 @@ -446,7 +446,8 @@ EXTERN void canvas_restoreconnections(t_canvas x); EXTERN void canvas_redraw(t_canvas x);

-EXTERN t_inlet canvas_addinlet(t_canvas x, t_pd who, t_symbol sym); +EXTERN t_inlet canvas_addinlet(t_canvas x, t_pd who, t_symbol sym, + t_symbol h); EXTERN void canvas_rminlet(t_canvas x, t_inlet ip); EXTERN t_outlet canvas_addoutlet(t_canvas x, t_pd who, t_symbol sym); EXTERN void canvas_rmoutlet(t_canvas x, t_outlet *op); diff -u ../../old/pd-0.38-0test7/src/g_editor.c ./g_editor.c --- ../../old/pd-0.38-0test7/src/g_editor.c 2004-09-10 05:28:22.000000000 +0200 +++ ./g_editor.c 2004-10-02 12:03:35.664961112 +0200 @@ -15,6 +15,7 @@

void open_via_helppath(const char name, const char dir); char class_gethelpdir(t_class c); +char inlet_tip(t_inlet i,int num);

/ ------------------ forward declarations --------------- / static void canvas_doclear(t_canvas *x); @@ -751,6 +752,18 @@ } }

+void canvas_inlettip(t_canvas x,t_object ob,int closest,int xpos,int ypos) +{ + if (!sys_tooltips) return; + if (ob->ob_pd->c_firstin) closest--; + if (closest < 0) + sys_vgui(".x%lx.c create text %d %d -anchor sw -text \"%s\" -tags y\n", + (t_int)x, xpos, ypos,ob->ob_pd->c_firsttip->s_name); + else + sys_vgui(".x%lx.c create text %d %d -anchor sw -text \"%s\" -tags y\n", + (t_int)x, xpos, ypos-4,inlet_tip(ob->te_inlet,closest)); +} + / check if a point lies in a gobj. / int canvas_hitbox(t_canvas x, t_gobj y, int xpos, int ypos, int x1p, int y1p, int x2p, int y2p) @@ -1064,7 +1077,7 @@ else { / look for an outlet / - int noutlet; + int noutlet, ninlet; if (ob && (noutlet = obj_noutlets(ob)) && ypos >= y2-4) { int width = x2 - x1; @@ -1088,9 +1101,26 @@ } else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT); } + else if (doit) goto nooutletafterall; } + + / look for an inlet / + else if (ob && (ninlet = obj_ninlets(ob)) && ypos <= y1+4) + { + int width = x2 - x1; + int nin1 = (ninlet > 1 ? ninlet - 1 : 1); + int closest = ((xpos-x1) (nin1) + width/2)/width; + int hotspot = x1 + + (width - IOWIDTH) closest / (nin1); + if (closest < ninlet && + xpos >= (hotspot-1) && xpos <= hotspot + (IOWIDTH+1)) + { + canvas_inlettip(x,ob,closest,xpos,ypos); + } + } + / not in an outlet; select and move / else if (doit) { @@ -1275,8 +1305,12 @@ canvas_getindex(x, &ob2->ob_g), closest2), "connect"); } - else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT); - return; + else + { + canvas_setcursor(x, CURSOR_EDITMODE_CONNECT); + canvas_inlettip(x,ob2,closest2,xpos,ypos); + } + return; } } canvas_setcursor(x, CURSOR_EDITMODE_NOTHING); @@ -1501,6 +1535,8 @@ bug("editor"); return; } + sys_vgui(".x%lx.c delete y\n",x); / GG: bad hack / + glist_setlastxy(x, xpos, ypos); if (x->gl_editor->e_onmotion == MA_MOVE) { diff -u ../../old/pd-0.38-0test7/src/g_graph.c ./g_graph.c --- ../../old/pd-0.38-0test7/src/g_graph.c 2004-09-05 19:55:31.000000000 +0200 +++ ./g_graph.c 2004-10-02 11:42:09.628468376 +0200 @@ -258,9 +258,10 @@ / --------------- inlets and outlets ----------- /

-t_inlet canvas_addinlet(t_canvas x, t_pd who, t_symbol s) +t_inlet canvas_addinlet(t_canvas x, t_pd who, t_symbol s, t_symbol h) { t_inlet ip = inlet_new(&x->gl_obj, who, s, 0); + inlet_settip(ip,h); if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner)) { gobj_vis(&x->gl_gobj, x->gl_owner, 0); diff -u ../../old/pd-0.38-0test7/src/g_io.c ./g_io.c --- ../../old/pd-0.38-0test7/src/g_io.c 2004-09-14 04:48:41.000000000 +0200 +++ ./g_io.c 2004-10-02 11:42:09.638466856 +0200 @@ -53,7 +53,7 @@ { t_vinlet x = (t_vinlet )pd_new(vinlet_class); x->x_canvas = canvas_getcurrent(); - x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, 0); + x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, 0, s); x->x_bufsize = 0; x->x_buf = 0; outlet_new(&x->x_obj, 0); @@ -254,7 +254,7 @@ { t_vinlet x = (t_vinlet )pd_new(vinlet_class); x->x_canvas = canvas_getcurrent(); - x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, &s_signal); + x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, &s_signal,s); x->x_endbuf = x->x_buf = (t_float )getbytes(0); x->x_bufsize = 0; x->x_directsignal = 0; diff -u ../../old/pd-0.38-0test7/src/m_class.c ./m_class.c --- ../../old/pd-0.38-0test7/src/m_class.c 2004-09-05 19:37:44.000000000 +0200 +++ ./m_class.c 2004-10-02 11:42:09.646465640 +0200 @@ -209,6 +209,7 @@ c->c_wb = (typeflag == CLASS_PATCHABLE ? &text_widgetbehavior : 0); c->c_pwb = 0; c->c_firstin = ((flags & CLASS_NOINLET) == 0); + c->c_firsttip = gensym("?"); c->c_patchable = (typeflag == CLASS_PATCHABLE); c->c_gobj = (typeflag >= CLASS_GOBJ); c->c_drawcommand = 0; diff -u ../../old/pd-0.38-0test7/src/m_glob.c ./m_glob.c --- ../../old/pd-0.38-0test7/src/m_glob.c 2004-09-05 19:37:44.000000000 +0200 +++ ./m_glob.c 2004-10-02 11:42:09.650465032 +0200 @@ -30,6 +30,7 @@ void glob_ping(t_pd dummy); void glob_watchdog(t_pd dummy); void glob_savepreferences(t_pd dummy); +void glob_tooltips(t_pd *dummy, t_float f);

void alsa_resync( void);

@@ -108,6 +109,8 @@ class_addmethod(glob_pdobject, (t_method)glob_ping, gensym("ping"), 0); class_addmethod(glob_pdobject, (t_method)glob_savepreferences, gensym("save-preferences"), 0); + class_addmethod(glob_pdobject, (t_method)glob_tooltips, + gensym("tooltips"), A_DEFFLOAT, 0); #ifdef UNIX class_addmethod(glob_pdobject, (t_method)glob_watchdog, gensym("watchdog"), 0); diff -u ../../old/pd-0.38-0test7/src/m_imp.h ./m_imp.h --- ../../old/pd-0.38-0test7/src/m_imp.h 2004-09-05 19:37:44.000000000 +0200 +++ ./m_imp.h 2004-10-02 11:42:09.653464576 +0200 @@ -52,6 +52,7 @@ char c_patchable; / true if we have a t_object header / char c_firstin; / if patchable, true if draw first inlet / char c_drawcommand; / a drawing command for a template / + t_symbol* c_firsttip; };

diff -u ../../old/pd-0.38-0test7/src/m_obj.c ./m_obj.c --- ../../old/pd-0.38-0test7/src/m_obj.c 2004-09-05 19:37:44.000000000 +0200 +++ ./m_obj.c 2004-10-02 11:42:09.657463968 +0200 @@ -22,6 +22,8 @@ t_sample iu_floatsignalvalue; };

+int sys_tooltips = 1; + struct _inlet { t_pd i_pd; @@ -30,6 +32,7 @@ t_pd i_dest; t_symbol i_symfrom; union inletunion i_un; + t_symbol* i_tip; };

#define i_symto i_un.iu_symto @@ -72,6 +75,29 @@ x->i_symfrom->s_name, s->s_name); }

+void inlet_settip(t_inlet i,t_symbol s) +{ + i->i_tip = s; +} + +void glob_tooltips(t_pd dummy, t_float f) +{ + sys_tooltips = f; +} + +char inlet_tip(t_inlet i,int num) +{ + if (num < 0) return "???"; + while (num-- && i) + i = i->i_next; + + if (i) + if (i->i_tip) { + return i->i_tip->s_name; + } + return "?"; +} + / LATER figure out how to make these efficient: / static void inlet_bang(t_inlet x) { diff -u ../../old/pd-0.38-0test7/src/m_pd.h ./m_pd.h --- ../../old/pd-0.38-0test7/src/m_pd.h 2004-09-14 04:47:34.000000000 +0200 +++ ./m_pd.h 2004-10-02 12:30:55.198714096 +0200 @@ -338,6 +338,8 @@ EXTERN t_inlet floatinlet_new(t_object owner, t_float fp); EXTERN t_inlet symbolinlet_new(t_object owner, t_symbol sp); EXTERN void inlet_free(t_inlet x); +EXTERN void class_settip(t_class x,t_symbol s); +EXTERN void inlet_settip(t_inlet i,t_symbol s);

EXTERN t_outlet outlet_new(t_object owner, t_symbol s); EXTERN void outlet_bang(t_outlet x); diff -u ../../old/pd-0.38-0test7/src/s_stuff.h ./s_stuff.h --- ../../old/pd-0.38-0test7/src/s_stuff.h 2004-09-05 19:37:44.000000000 +0200 +++ ./s_stuff.h 2004-10-02 11:42:09.669462144 +0200 @@ -38,6 +38,7 @@ extern int sys_noloadbang; extern int sys_nogui; extern char *sys_guicmd; +extern int sys_tooltips;

EXTERN int sys_nearestfontsize(int fontsize); EXTERN int sys_hostfontsize(int fontsize);'



Powered by IEM Powered by Plone Section 508 WCAG Valid XHTML Valid CSS Usable in any browser