Revision: 10272 http://pure-data.svn.sourceforge.net/pure-data/?rev=10272&view=rev Author: zmoelnig Date: 2008-09-01 14:36:04 +0000 (Mon, 01 Sep 2008)
Log Message: ----------- renamed [parentposition] to [canvasposition] (consistent naming scheme); added more helppatches
Modified Paths: -------------- trunk/externals/iem/iemguts/help/propertybang-help.pd
Added Paths: ----------- trunk/externals/iem/iemguts/help/canvasdollarzero-help.pd trunk/externals/iem/iemguts/help/canvasindex-help.pd trunk/externals/iem/iemguts/help/canvasposition-help.pd trunk/externals/iem/iemguts/help/sendcanvas-help.pd trunk/externals/iem/iemguts/src/canvasposition.c
Removed Paths: ------------- trunk/externals/iem/iemguts/src/parentposition.c
Added: trunk/externals/iem/iemguts/help/canvasdollarzero-help.pd =================================================================== --- trunk/externals/iem/iemguts/help/canvasdollarzero-help.pd (rev 0) +++ trunk/externals/iem/iemguts/help/canvasdollarzero-help.pd 2008-09-01 14:36:04 UTC (rev 10272) @@ -0,0 +1,32 @@ +#N canvas 251 447 635 427 10; +#X obj 99 229 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X obj 81 25 canvasdollarzero; +#X text 207 25 get $0 of the (parent) canvas; +#X msg 88 128 bang; +#X obj 88 148 canvasdollarzero; +#X symbolatom 88 168 10 0 0 0 - - -; +#X text 57 85 this object is a shameless clone of iemlib's [parentdollarzero] +with an added feature.; +#X text 53 194 the feature is , that you can query the $0 of _any_ +parent canvas; +#N canvas 0 0 781 383 canvasdollarzero 0; +#X obj 147 72 inlet; +#X text 298 167 "1" indicates to read the parent patch's (depth:1) +$0; +#X msg 147 126 bang; +#X symbolatom 182 188 10 0 0 0 - - -; +#X obj 147 213 outlet; +#X obj 147 166 canvasdollarzero 1; +#X text 125 275 ok , this example is not very splendid , as $0 is +the same for a patch and all it's subpatches anyhow ; nevertheless +, believe me that it also works with abstractions; +#X connect 0 0 2 0; +#X connect 2 0 5 0; +#X connect 5 0 3 0; +#X connect 5 0 4 0; +#X restore 99 248 pd canvasdollarzero 1; +#X text 58 308 (c) 2008 IOhannes m zmoelnig , Thomas Musil; +#X connect 0 0 8 0; +#X connect 3 0 4 0; +#X connect 4 0 5 0;
Added: trunk/externals/iem/iemguts/help/canvasindex-help.pd =================================================================== --- trunk/externals/iem/iemguts/help/canvasindex-help.pd (rev 0) +++ trunk/externals/iem/iemguts/help/canvasindex-help.pd 2008-09-01 14:36:04 UTC (rev 10272) @@ -0,0 +1,58 @@ +#N canvas 180 165 635 592 10; +#X msg 88 128 bang; +#X obj 81 25 canvasindex; +#X text 207 25 get the ID/index of an abstraction/subpatch within it's +containing patch; +#X text 99 88 this object allows you to dynamically find out indicies +to connect with dynamic patching; +#N canvas 0 0 450 300 object1 0; +#X obj 75 48 inlet; +#X obj 75 189 outlet; +#X obj 75 129 canvasindex; +#X obj 324 59 inlet; +#X connect 0 0 2 0; +#X connect 2 0 1 0; +#X restore 88 168 pd object1; +#X obj 88 148 t b b; +#N canvas 0 0 450 300 object2 0; +#X obj 75 48 inlet; +#X obj 75 189 outlet; +#X obj 75 129 canvasindex; +#X obj 281 205 outlet; +#X connect 0 0 2 0; +#X connect 2 0 1 0; +#X restore 188 168 pd object2; +#X floatatom 188 191 5 0 0 0 - - -; +#X floatatom 88 192 5 0 0 0 - - -; +#X text 47 547 (c) 2008 IOhannes m zmoelnig; +#X obj 88 288 namecanvas $0-canvas; +#X obj 88 269 send $0-canvas; +#X msg 88 245 connect $2 1 $1 1; +#X obj 88 222 pack; +#X msg 101 378 bang; +#X floatatom 101 422 5 0 0 0 - - -; +#N canvas 0 0 450 300 objectcount 0; +#X obj 75 48 inlet; +#X obj 75 189 outlet; +#X obj 75 129 canvasindex 1; +#X connect 0 0 2 0; +#X connect 2 1 1 0; +#X restore 101 398 pd objectcount; +#X text 71 347 the second outlet tells you , how many objects the +parent patch contains in total.; +#X text 55 461 you can specify the depth of the parent-patch via a +optional argument:; +#X obj 79 496 canvasindex 2; +#X text 178 494 will work on the grandparent (parent-depth:2) of this +patch; +#X connect 0 0 5 0; +#X connect 4 0 8 0; +#X connect 5 0 4 0; +#X connect 5 1 6 0; +#X connect 6 0 7 0; +#X connect 7 0 13 1; +#X connect 8 0 13 0; +#X connect 12 0 11 0; +#X connect 13 0 12 0; +#X connect 14 0 16 0; +#X connect 16 0 15 0;
Added: trunk/externals/iem/iemguts/help/canvasposition-help.pd =================================================================== --- trunk/externals/iem/iemguts/help/canvasposition-help.pd (rev 0) +++ trunk/externals/iem/iemguts/help/canvasposition-help.pd 2008-09-01 14:36:04 UTC (rev 10272) @@ -0,0 +1,62 @@ +#N canvas 1388 107 635 592 10; +#X obj 81 25 canvasindex; +#X text 47 547 (c) 2008 IOhannes m zmoelnig; +#X text 55 471 you can specify the depth of the parent-patch via a +optional argument:; +#X text 178 504 will work on the grandparent (parent-depth:2) of this +patch; +#X text 207 25 get/set the position of the containing patch within +it's parent; +#X text 39 88 this object allows you to retrieve the position of an +abstraction/subpatch within it's containing canvas; +#X msg 98 124 bang; +#X obj 98 172 unpack; +#X floatatom 137 194 5 0 0 0 - - -; +#X floatatom 98 194 5 0 0 0 - - -; +#X text 178 145 <--- you can move this object and click "bang" again +; +#X msg 88 253 bang; +#X obj 88 292 unpack; +#X floatatom 127 314 5 0 0 0 - - -; +#X floatatom 88 314 5 0 0 0 - - -; +#X text 168 269 <--- you can move this object and click "bang" again +; +#X text 39 218 you can also query the size of the containing canvas +via the 2nd outlet; +#N canvas 0 0 450 300 getsize 0; +#X obj 75 48 inlet; +#X obj 75 189 outlet; +#X obj 75 129 canvasposition; +#X connect 0 0 2 0; +#X connect 2 1 1 0; +#X restore 88 272 pd getsize; +#N canvas 0 0 450 300 getpos 0; +#X obj 75 48 inlet; +#X obj 75 189 outlet; +#X obj 75 129 canvasposition; +#X connect 0 0 2 0; +#X connect 2 0 1 0; +#X restore 98 148 pd getpos; +#X text 69 333 note: there is a bug in Pd that might require you to +save a patch , before the "size" will actually change; +#N canvas 0 0 450 300 setpos 0; +#X obj 75 48 inlet; +#X obj 75 129 canvasposition; +#X connect 0 0 1 0; +#X restore 100 440 pd setpos; +#X obj 103 398 hsl 128 15 100 400 0 0 empty empty empty -2 -8 0 10 +-262144 -1 -1 0 1; +#X obj 52 505 canvasposition 2; +#X text 46 368 finally you can move an object around (without any hackish +mouse emulation); +#X msg 100 418 $1 440; +#X connect 6 0 18 0; +#X connect 7 0 9 0; +#X connect 7 1 8 0; +#X connect 11 0 17 0; +#X connect 12 0 14 0; +#X connect 12 1 13 0; +#X connect 17 0 12 0; +#X connect 18 0 7 0; +#X connect 21 0 24 0; +#X connect 24 0 20 0;
Modified: trunk/externals/iem/iemguts/help/propertybang-help.pd =================================================================== --- trunk/externals/iem/iemguts/help/propertybang-help.pd 2008-09-01 13:59:31 UTC (rev 10271) +++ trunk/externals/iem/iemguts/help/propertybang-help.pd 2008-09-01 14:36:04 UTC (rev 10272) @@ -11,7 +11,7 @@ #X restore 86 152 pd with propertybang; #X obj 86 176 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; -#X text 174 44 enables the "property" menu for abstractions; +#X text 184 44 enables the "property" menu for abstractions; #X text 90 77 usage:; #X text 140 77 put a [propertybang] object into your abstraction; #X text 139 94 put your abstraction into your patch;
Added: trunk/externals/iem/iemguts/help/sendcanvas-help.pd =================================================================== --- trunk/externals/iem/iemguts/help/sendcanvas-help.pd (rev 0) +++ trunk/externals/iem/iemguts/help/sendcanvas-help.pd 2008-09-01 14:36:04 UTC (rev 10272) @@ -0,0 +1,27 @@ +#N canvas 251 447 635 427 10; +#X obj 81 25 sendcanvas; +#X text 168 27 send messages to a (parent) canvas; +#X obj 88 151 sendcanvas; +#X msg 88 130 obj 300 150 f; +#X text 57 85 this object will send messages to a canvas ; by default +it will send a message to the canvas containing it:; +#X text 53 194 but you can also send to a message to a parent-canvas +(of any depth); +#N canvas 0 0 781 310 sendcanvas 0; +#X obj 147 72 inlet; +#X obj 147 166 sendcanvas 1; +#X msg 147 126 obj 300 250 print; +#X text 252 170 "1" means that the message is sent to the parent-patch +(depth:1); +#X connect 0 0 2 0; +#X connect 2 0 1 0; +#X restore 99 248 pd sendcanvas; +#X obj 99 229 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X text 80 306 you can basically achieve this functionality with [namecanvas] +and an ordinary [send] ; so this object is merely convenient as you +can dynamify a canvas without prior thought to it; +#X text 58 295 note:; +#X text 72 390 (c) 2008 IOhannes m zmoelnig; +#X connect 3 0 2 0; +#X connect 7 0 6 0;
Copied: trunk/externals/iem/iemguts/src/canvasposition.c (from rev 10270, trunk/externals/iem/iemguts/src/parentposition.c) =================================================================== --- trunk/externals/iem/iemguts/src/canvasposition.c (rev 0) +++ trunk/externals/iem/iemguts/src/canvasposition.c 2008-09-01 14:36:04 UTC (rev 10272) @@ -0,0 +1,144 @@ + +/****************************************************** + * + * canvasposition - implementation file + * + * copyleft (c) IOhannes m zm\xF6lnig + * + * 2007:forum::f\xFCr::uml\xE4ute:2007 + * + * institute of electronic music and acoustics (iem) + * + ****************************************************** + * + * license: GNU General Public License v.2 + * + ******************************************************/ + + +/* + * this object provides a way to get and set the position of the containing + * abstraction within the parent-patch + * + * by default the position of the containing abstraction within the parent-patch is + * queried + * you can give the "depth" as argument; + * e.g. [canvasposition 1] will set/get the position of the abstraction containing the + * abstraction within its canvas. + */ + +#include "m_pd.h" + +#include "g_canvas.h" +#include "m_imp.h" + +/* ------------------------- canvasposition ---------------------------- */ + +static t_class *canvasposition_class; + +typedef struct _canvasposition +{ + t_object x_obj; + t_canvas *x_canvas; + + t_outlet*xoutlet, *youtlet; +} t_canvasposition; + + +static void canvasposition_bang(t_canvasposition *x) +{ + t_canvas*c=x->x_canvas; + t_canvas*c0=0; + + int x1=0, y1=0, width=0, height=0; + t_atom alist[2]; + + if(!c) return; + + + x1=c->gl_obj.te_xpix; + y1=c->gl_obj.te_ypix; + + + c0=c->gl_owner; + if(c0!=0) { + width= (int)(c0->gl_screenx2 - c0->gl_screenx1); + height=(int)(c0->gl_screeny2 - c0->gl_screeny1); + } + + SETFLOAT(alist, (t_float)width); + SETFLOAT(alist+1, (t_float)height); + outlet_list(x->youtlet, 0, 2, alist); + + // outlet_float(x->youtlet, y1); + SETFLOAT(alist, (t_float)x1); + SETFLOAT(alist+1, (t_float)y1); + outlet_list(x->xoutlet, 0, 2, alist); +} + +static void canvasposition_list(t_canvasposition *x, t_symbol*s, int argc, t_atom*argv) +{ + t_canvas*c=x->x_canvas; + t_canvas*c0=0; + int dx, dy; + + if(!c) return; + c0=c->gl_owner; + + if(argc==0){ + canvasposition_bang(x); + return; + } + + if(argc!=2 || (A_FLOAT != (argv+0)->a_type) || (A_FLOAT != (argv+1)->a_type)) { + pd_error(x, "expected <x> <y> as new position"); + return; + } + dx = atom_getint(argv+0) - c->gl_obj.te_xpix; + dy = atom_getint(argv+1) - c->gl_obj.te_ypix; + + if(c0&&glist_isvisible(c0)) { + gobj_displace((t_gobj*)c, c0, dx, dy); + canvas_fixlinesfor(c0, (t_text*)c); + } else { + c->gl_obj.te_xpix+=dx; + c->gl_obj.te_ypix+=dy; + } +} + +static void canvasposition_free(t_canvasposition *x) +{ + outlet_free(x->xoutlet); + outlet_free(x->youtlet); +} + +static void *canvasposition_new(t_floatarg f) +{ + t_canvasposition *x = (t_canvasposition *)pd_new(canvasposition_class); + t_glist *glist=(t_glist *)canvas_getcurrent(); + t_canvas *canvas=(t_canvas*)glist_getcanvas(glist); + int depth=(int)f; + + if(depth<0)depth=0; + while(depth && canvas) { + canvas=canvas->gl_owner; + depth--; + } + + x->x_canvas = canvas; + + x->xoutlet=outlet_new(&x->x_obj, &s_list); + x->youtlet=outlet_new(&x->x_obj, &s_list); + + return (x); +} + +void canvasposition_setup(void) +{ + canvasposition_class = class_new(gensym("canvasposition"), + (t_newmethod)canvasposition_new, (t_method)canvasposition_free, + sizeof(t_canvasposition), 0, + A_DEFFLOAT, 0); + class_addbang(canvasposition_class, (t_method)canvasposition_bang); + class_addlist(canvasposition_class, (t_method)canvasposition_list); +}
Property changes on: trunk/externals/iem/iemguts/src/canvasposition.c ___________________________________________________________________ Added: svn:mergeinfo +
Deleted: trunk/externals/iem/iemguts/src/parentposition.c =================================================================== --- trunk/externals/iem/iemguts/src/parentposition.c 2008-09-01 13:59:31 UTC (rev 10271) +++ trunk/externals/iem/iemguts/src/parentposition.c 2008-09-01 14:36:04 UTC (rev 10272) @@ -1,144 +0,0 @@ - -/****************************************************** - * - * parentposition - implementation file - * - * copyleft (c) IOhannes m zm\xF6lnig - * - * 2007:forum::f\xFCr::uml\xE4ute:2007 - * - * institute of electronic music and acoustics (iem) - * - ****************************************************** - * - * license: GNU General Public License v.2 - * - ******************************************************/ - - -/* - * this object provides a way to get and set the position of the containing - * abstraction within the parent-patch - * - * by default the position of the containing abstraction within the parent-patch is - * queried - * you can give the "depth" as argument; - * e.g. [parentposition 1] will set/get the position of the abstraction containing the - * abstraction within its canvas. - */ - -#include "m_pd.h" - -#include "g_canvas.h" -#include "m_imp.h" - -/* ------------------------- parentposition ---------------------------- */ - -static t_class *parentposition_class; - -typedef struct _parentposition -{ - t_object x_obj; - t_canvas *x_canvas; - - t_outlet*xoutlet, *youtlet; -} t_parentposition; - - -static void parentposition_bang(t_parentposition *x) -{ - t_canvas*c=x->x_canvas; - t_canvas*c0=0; - - int x1=0, y1=0, width=0, height=0; - t_atom alist[2]; - - if(!c) return; - - - x1=c->gl_obj.te_xpix; - y1=c->gl_obj.te_ypix; - - - c0=c->gl_owner; - if(c0!=0) { - width= (int)(c0->gl_screenx2 - c0->gl_screenx1); - height=(int)(c0->gl_screeny2 - c0->gl_screeny1); - } - - SETFLOAT(alist, (t_float)width); - SETFLOAT(alist+1, (t_float)height); - outlet_list(x->youtlet, 0, 2, alist); - - // outlet_float(x->youtlet, y1); - SETFLOAT(alist, (t_float)x1); - SETFLOAT(alist+1, (t_float)y1); - outlet_list(x->xoutlet, 0, 2, alist); -} - -static void parentposition_list(t_parentposition *x, t_symbol*s, int argc, t_atom*argv) -{ - t_canvas*c=x->x_canvas; - t_canvas*c0=0; - int dx, dy; - - if(!c) return; - c0=c->gl_owner; - - if(argc==0){ - parentposition_bang(x); - return; - } - - if(argc!=2 || (A_FLOAT != (argv+0)->a_type) || (A_FLOAT != (argv+1)->a_type)) { - pd_error(x, "expected <x> <y> as new position"); - return; - } - dx = atom_getint(argv+0) - c->gl_obj.te_xpix; - dy = atom_getint(argv+1) - c->gl_obj.te_ypix; - - if(c0&&glist_isvisible(c0)) { - gobj_displace((t_gobj*)c, c0, dx, dy); - canvas_fixlinesfor(c0, (t_text*)c); - } else { - c->gl_obj.te_xpix+=dx; - c->gl_obj.te_ypix+=dy; - } -} - -static void parentposition_free(t_parentposition *x) -{ - outlet_free(x->xoutlet); - outlet_free(x->youtlet); -} - -static void *parentposition_new(t_floatarg f) -{ - t_parentposition *x = (t_parentposition *)pd_new(parentposition_class); - t_glist *glist=(t_glist *)canvas_getcurrent(); - t_canvas *canvas=(t_canvas*)glist_getcanvas(glist); - int depth=(int)f; - - if(depth<0)depth=0; - while(depth && canvas) { - canvas=canvas->gl_owner; - depth--; - } - - x->x_canvas = canvas; - - x->xoutlet=outlet_new(&x->x_obj, &s_list); - x->youtlet=outlet_new(&x->x_obj, &s_list); - - return (x); -} - -void parentposition_setup(void) -{ - parentposition_class = class_new(gensym("parentposition"), - (t_newmethod)parentposition_new, (t_method)parentposition_free, - sizeof(t_parentposition), 0, - A_DEFFLOAT, 0); - class_addbang(parentposition_class, (t_method)parentposition_bang); - class_addlist(parentposition_class, (t_method)parentposition_list); -}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.