Update of /cvsroot/pure-data/externals/bbogart/popup In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27794
Modified Files: popup-help.pd popup.c Log Message: Added second inlet to choose popup value via symbol name rather than index value.
Index: popup.c =================================================================== RCS file: /cvsroot/pure-data/externals/bbogart/popup/popup.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** popup.c 13 Dec 2004 23:56:59 -0000 1.9 --- popup.c 14 Jan 2005 20:12:00 -0000 1.10 *************** *** 45,48 **** --- 45,49 ---- t_glist * x_glist; t_outlet* out2; + t_inlet* in2; int x_rect_width; int x_rect_height; *************** *** 63,67 ****
/* Append " x " to the following line to show debugging messages */ ! #define DEBUG(x)
--- 64,68 ----
/* Append " x " to the following line to show debugging messages */ ! #define DEBUG(x)
*************** *** 97,102 **** sys_vgui(".x%x.c create rectangle %d %d %d %d -tags {%xi%d %xi}\n", glist_getcanvas(glist), ! onset, text_ypix(&x->x_obj, glist), ! onset + IOWIDTH, text_ypix(&x->x_obj, glist)+1, x, i, x); else --- 98,103 ---- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags {%xi%d %xi}\n", glist_getcanvas(glist), ! onset, text_ypix(&x->x_obj, glist)-2, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist)-1, x, i, x); else *************** *** 104,108 **** glist_getcanvas(glist), x, i, onset, text_ypix(&x->x_obj, glist), ! onset + IOWIDTH, text_ypix(&x->x_obj, glist)+1); } --- 105,109 ---- glist_getcanvas(glist), x, i, onset, text_ypix(&x->x_obj, glist), ! onset + IOWIDTH, text_ypix(&x->x_obj, glist)-1); } *************** *** 174,189 **** } else { ! sys_vgui(".x%x.c coords %xS \ ! %d %d\n", canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); } ! draw_inlets(x, glist, firsttime, 2,1); // draw_handle(x, glist, firsttime);
! DEBUG(post("drawme end");)
! // Output a bang to first outlet when we're ready to receive float messages the first time!. ! if(firsttime) {outlet_bang(x->x_obj.ob_outlet);} }
--- 175,189 ---- } else { ! sys_vgui(".x%x.c coords %xS %d %d\n", canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); } ! draw_inlets(x, glist, firsttime, 2,2); // draw_handle(x, glist, firsttime);
! // Output a bang to first outlet when we're ready to receive float messages the first time!. ! if(firsttime) {outlet_bang(x->x_obj.ob_outlet);}
! DEBUG(post("drawme end");) }
*************** *** 420,437 **** }
! /* Function to append symbols to popup list ! static void popup_append(t_popup* x, t_symbol *item) { ! // Add menu item ! sys_vgui(".x%x.c.s%x.menu add command -label "%s" -command {.x%x.c.s%x configure -text "%s" ; popup_sel%x "%d"} \n", ! x->x_glist, x, item->s_name, x->x_glist, x, item->s_name, x, (x->x_num_options-1) ); ! ! post("orig num_options: %d", x->x_num_options);
! // Incriment num_options ! x->x_num_options++;
! post("post num_options: %d", x->x_num_options); ! } */
/* Function to append symbols to popup list */ --- 420,444 ---- }
! /* Function to choose value via symbol name */ ! static void popup_symselect(t_popup* x, t_symbol *s) { ! int i,match=0;
! /* Compare inlet symbol to each option */ ! for(i=0; i<x->x_num_options; i++) ! { ! if(x->x_options[i]->s_name == s->s_name) ! { ! sys_vgui(".x%x.c.s%x configure -text "%s" ; popup_sel%x "%d" \n", ! glist_getcanvas(x->x_glist), x, x->x_options[i]->s_name,x, i); ! match = 1; ! break; ! } ! }
! if(match != 1) ! post("popup: '%s' is not an available option.", s->s_name); ! ! }
/* Function to append symbols to popup list */ *************** *** 508,513 **** sys_vgui("proc popup_sel%x {index} {\n pd [concat popup%p output $index \;]\n }\n",x,x);
outlet_new(&x->x_obj, &s_float); ! x->out2 = outlet_new(&x->x_obj, &s_symbol); return (x);
--- 515,522 ---- sys_vgui("proc popup_sel%x {index} {\n pd [concat popup%p output $index \;]\n }\n",x,x);
+ /* Add symbol inlet (hard to say how this actually works?? */ + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("symbol"), gensym("")); outlet_new(&x->x_obj, &s_float); ! x->out2 = outlet_new(&x->x_obj, &s_symbol); return (x);
*************** *** 548,553 **** --- 557,569 ---- 0);
+ class_addmethod(popup_class, (t_method)popup_symselect, + gensym(""), + A_DEFSYMBOL, + 0); + class_doaddfloat(popup_class, (t_method)popup_iselect);
+ // class_addsymbol(popup_class, (t_method)popup_symselect); + class_setwidget(popup_class,&popup_widgetbehavior); #if PD_MINOR_VERSION >= 37
Index: popup-help.pd =================================================================== RCS file: /cvsroot/pure-data/externals/bbogart/popup/popup-help.pd,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** popup-help.pd 13 Dec 2004 23:56:59 -0000 1.5 --- popup-help.pd 14 Jan 2005 20:11:59 -0000 1.6 *************** *** 1,35 **** ! #N canvas 119 198 631 397 10; ! #X obj 106 300 popup 124 25 grey90 duh! one two three four five six seven eight nine ten eleven twelve thirteen i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30; ! #X obj 152 359 print index; ! #X msg 96 108 name popup; ! #X obj 239 359 print symbol; ! #X floatatom 43 94 5 0 0 0 - - -; ! #X text 13 11 popup , a popup menu for PD. Copyright Ben Bogart 2004 ! Released under the GPL.; #X text 14 43 Left outlet sends out a bang on load , used to set default value. Using a loadbang to send a float will result in a crash.; ! #X msg 173 235 options; ! #X msg 166 186 options one two three four five six seven eight nine ten eleven twelve thirteen i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30; ! #X msg 184 261 append append-one append-two append-three; ! #X obj 106 332 route bang; ! #X msg 33 298 10; ! #X text 187 332 Choose 10 as the default value on load , does send output.; ! #X msg 119 133 bgcolour #047992; ! #X msg 149 160 bgcolour grey90; ! #X connect 0 0 10 0; #X connect 0 1 3 0; #X connect 2 0 0 0; #X connect 4 0 0 0; #X connect 7 0 0 0; #X connect 8 0 0 0; ! #X connect 9 0 0 0; ! #X connect 10 0 11 0; ! #X connect 10 1 1 0; ! #X connect 11 0 0 0; #X connect 13 0 0 0; ! #X connect 14 0 0 0; --- 1,39 ---- ! #N canvas 119 198 626 449 10; ! #X obj 106 340 popup 124 25 grey90 duh! one two three four five six seven eight nine ten eleven twelve thirteen i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30; ! #X obj 152 399 print index; ! #X msg 30 98 name popup; ! #X obj 239 399 print symbol; ! #X floatatom 163 292 5 0 0 0 - - -; #X text 14 43 Left outlet sends out a bang on load , used to set default value. Using a loadbang to send a float will result in a crash.; ! #X msg 107 225 options; ! #X msg 100 176 options one two three four five six seven eight nine ten eleven twelve thirteen i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30; ! #X msg 118 251 append append-one append-two append-three; ! #X obj 106 372 route bang; ! #X msg 33 338 10; ! #X text 187 372 Choose 10 as the default value on load , does send output.; ! #X msg 53 123 bgcolour #047992; ! #X msg 83 150 bgcolour grey90; ! #X symbolatom 223 315 10 0 0 0 - - -; ! #X text 209 289 Select by index; ! #X text 302 314 Select by symbol name; ! #X text 13 11 popup , a popup menu for PD. Copyright Ben Bogart 2004 ! , 2005 Released under the GPL.; ! #X connect 0 0 9 0; #X connect 0 1 3 0; #X connect 2 0 0 0; #X connect 4 0 0 0; + #X connect 6 0 0 0; #X connect 7 0 0 0; #X connect 8 0 0 0; ! #X connect 9 0 10 0; ! #X connect 9 1 1 0; ! #X connect 10 0 0 0; ! #X connect 12 0 0 0; #X connect 13 0 0 0; ! #X connect 14 0 0 1;