diff options
-rw-r--r-- | help/canvasdollarzero-help.pd | 32 | ||||
-rw-r--r-- | help/canvasindex-help.pd | 58 | ||||
-rw-r--r-- | help/canvasposition-help.pd | 62 | ||||
-rw-r--r-- | help/propertybang-help.pd | 2 | ||||
-rw-r--r-- | help/sendcanvas-help.pd | 27 | ||||
-rw-r--r-- | src/canvasposition.c (renamed from src/parentposition.c) | 36 |
6 files changed, 198 insertions, 19 deletions
diff --git a/help/canvasdollarzero-help.pd b/help/canvasdollarzero-help.pd new file mode 100644 index 0000000..4a12721 --- /dev/null +++ b/help/canvasdollarzero-help.pd @@ -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; diff --git a/help/canvasindex-help.pd b/help/canvasindex-help.pd new file mode 100644 index 0000000..92e969e --- /dev/null +++ b/help/canvasindex-help.pd @@ -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; diff --git a/help/canvasposition-help.pd b/help/canvasposition-help.pd new file mode 100644 index 0000000..8c230af --- /dev/null +++ b/help/canvasposition-help.pd @@ -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; diff --git a/help/propertybang-help.pd b/help/propertybang-help.pd index 30b33ba..8c7696d 100644 --- a/help/propertybang-help.pd +++ b/help/propertybang-help.pd @@ -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; diff --git a/help/sendcanvas-help.pd b/help/sendcanvas-help.pd new file mode 100644 index 0000000..9f8b01d --- /dev/null +++ b/help/sendcanvas-help.pd @@ -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; diff --git a/src/parentposition.c b/src/canvasposition.c index 086c902..03f839c 100644 --- a/src/parentposition.c +++ b/src/canvasposition.c @@ -1,7 +1,7 @@ /****************************************************** * - * parentposition - implementation file + * canvasposition - implementation file * * copyleft (c) IOhannes m zmölnig * @@ -23,7 +23,7 @@ * 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 + * e.g. [canvasposition 1] will set/get the position of the abstraction containing the * abstraction within its canvas. */ @@ -32,20 +32,20 @@ #include "g_canvas.h" #include "m_imp.h" -/* ------------------------- parentposition ---------------------------- */ +/* ------------------------- canvasposition ---------------------------- */ -static t_class *parentposition_class; +static t_class *canvasposition_class; -typedef struct _parentposition +typedef struct _canvasposition { t_object x_obj; t_canvas *x_canvas; t_outlet*xoutlet, *youtlet; -} t_parentposition; +} t_canvasposition; -static void parentposition_bang(t_parentposition *x) +static void canvasposition_bang(t_canvasposition *x) { t_canvas*c=x->x_canvas; t_canvas*c0=0; @@ -76,7 +76,7 @@ static void parentposition_bang(t_parentposition *x) outlet_list(x->xoutlet, 0, 2, alist); } -static void parentposition_list(t_parentposition *x, t_symbol*s, int argc, t_atom*argv) +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; @@ -86,7 +86,7 @@ static void parentposition_list(t_parentposition *x, t_symbol*s, int argc, t_ato c0=c->gl_owner; if(argc==0){ - parentposition_bang(x); + canvasposition_bang(x); return; } @@ -106,15 +106,15 @@ static void parentposition_list(t_parentposition *x, t_symbol*s, int argc, t_ato } } -static void parentposition_free(t_parentposition *x) +static void canvasposition_free(t_canvasposition *x) { outlet_free(x->xoutlet); outlet_free(x->youtlet); } -static void *parentposition_new(t_floatarg f) +static void *canvasposition_new(t_floatarg f) { - t_parentposition *x = (t_parentposition *)pd_new(parentposition_class); + 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; @@ -133,12 +133,12 @@ static void *parentposition_new(t_floatarg f) return (x); } -void parentposition_setup(void) +void canvasposition_setup(void) { - parentposition_class = class_new(gensym("parentposition"), - (t_newmethod)parentposition_new, (t_method)parentposition_free, - sizeof(t_parentposition), 0, + canvasposition_class = class_new(gensym("canvasposition"), + (t_newmethod)canvasposition_new, (t_method)canvasposition_free, + sizeof(t_canvasposition), 0, A_DEFFLOAT, 0); - class_addbang(parentposition_class, (t_method)parentposition_bang); - class_addlist(parentposition_class, (t_method)parentposition_list); + class_addbang(canvasposition_class, (t_method)canvasposition_bang); + class_addlist(canvasposition_class, (t_method)canvasposition_list); } |