1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#N struct template9 float x float y float w float h float q;
#N canvas 223 50 652 591 12;
#X floatatom 279 333 4 0 0 0 - - - 0;
#N canvas 895 64 388 446 data9 1;
#X scalar template9 19 186 73 25 9 \;;
#X scalar template9 293 328 38 32 66 \;;
#X scalar template9 202 32 46 71 78 \;;
#X scalar template9 50 321 49 46 220 \;;
#X scalar template9 140 183 28 72 634 \;;
#X scalar template9 250 125 46 11 48 \;;
#X scalar template9 26 62 70 11 903 \;;
#X scalar template9 275 36 49 23 152 \;;
#X scalar template9 230 175 25 27 710 \;;
#X scalar template9 311 254 50 25 612 \;;
#X scalar template9 19 114 77 26 16 \;;
#X scalar template9 177 241 39 66 866 \;;
#X scalar template9 44 239 27 27 125 \;;
#X scalar template9 117 111 66 32 319 \;;
#X scalar template9 135 61 50 25 454 \;;
#X scalar template9 316 143 21 45 583 \;;
#X scalar template9 270 230 25 38 548 \;;
#X scalar template9 237 278 24 73 214 \;;
#X scalar template9 143 332 49 77 649 \;;
#X scalar template9 288 91 72 19 325 \;;
#X coords 0 446 1 445 0 0 0;
#X restore 508 286 pd data9;
#N canvas 282 376 705 419 template9 0;
#X obj 393 207 filledpolygon q 0 1 0 0 w 0 w h 0 h;
#X obj 394 234 drawnumber q 0 0 0;
#X obj 171 124 struct template9 float x float y float w float h float q;
#X obj 171 268 outlet;
#X obj 182 159 print struct-template9;
#X text 347 158 <-- print all messages.;
#X text 42 17 [struct] outputs messages notifying you when objects of this structure are interacted with. In run mode you get: 'click' (when you click on them) and 'change' (when you change field values by dragging). In edit mode you get: 'select' when you select the object \, 'deselect' when you deselect it and 'displace' when you move it around. Here we catch 'change' and 'select' interactions and pass the pointer through with the [route] object., f 86;
#X obj 171 199 route select change displace;
#X obj 299 229 unpack p;
#X text 153 316 Note: later we'll see how to deal with arrays in data structures. Unfortunately \, at least until now \, you can't have messages like 'change' when clicking and dragging an array element value., f 65;
#X connect 2 0 4 0;
#X connect 2 0 7 0;
#X connect 7 0 3 0;
#X connect 7 1 3 0;
#X connect 7 2 8 0;
#X connect 8 0 3 0;
#X restore 279 236 pd template9;
#X obj 279 305 get template9 x y w h q;
#X floatatom 397 333 4 0 0 0 - - - 0;
#X floatatom 358 333 4 0 0 0 - - - 0;
#X floatatom 318 333 4 0 0 0 - - - 0;
#X floatatom 437 333 4 0 0 0 - - - 0;
#X msg 279 513 \; set-x set \$1;
#X msg 318 475 \; set-y set \$1;
#X msg 358 437 \; set-w set \$1;
#X msg 397 398 \; set-h set \$1;
#X msg 437 359 \; set-q set \$1;
#X floatatom 79 255 5 0 0 0 - set-x - 0;
#X obj 79 292 set template9 x;
#X obj 79 350 set template9 y;
#X obj 79 408 set template9 w;
#X obj 79 465 set template9 h;
#X obj 79 522 set template9 q;
#X floatatom 79 326 5 0 0 0 - set-y - 0;
#X floatatom 79 384 5 0 0 0 - set-w - 0;
#X floatatom 79 442 5 0 0 0 - set-h - 0;
#X floatatom 79 499 5 0 0 0 - set-q - 0;
#X text 375 236 <-- open for details;
#X text 46 17 The [struct] object outputs a pointers in different interaction situations as in the case of any selected object of 'template9' or when you click and change any parameter. This patch demonstrates catching these interactions., f 79;
#X text 46 64 When in run mode (that is not in edit mode) you can click on any corner of the rectangles in the [pd data9] window to drag and change its size or click on the numbers and drag to change the color number. You'll then see the parameters come out of the [get] object \, which outputs the 5 parameters from the [struct]. You can also set the number boxes connected to the [set] objects so you're able to change them., f 79;
#X text 46 156 If you go into edit mode in the [pd data9] window \, you can also select a scalar (note the blue "selection" rectangle) and drag it. The 5 parameters should also show up under the [get] object. The blue "selection" rectangle also notices when the object that got selected gets moved or resized via the [set] object., f 79;
#X connect 0 0 8 0;
#X connect 2 0 3 0;
#X connect 2 0 14 1;
#X connect 2 0 18 1;
#X connect 2 0 17 1;
#X connect 2 0 16 1;
#X connect 2 0 15 1;
#X connect 3 0 0 0;
#X connect 3 1 6 0;
#X connect 3 2 5 0;
#X connect 3 3 4 0;
#X connect 3 4 7 0;
#X connect 4 0 11 0;
#X connect 5 0 10 0;
#X connect 6 0 9 0;
#X connect 7 0 12 0;
#X connect 13 0 14 0;
#X connect 19 0 15 0;
#X connect 20 0 16 0;
#X connect 21 0 17 0;
#X connect 22 0 18 0;
|