aboutsummaryrefslogtreecommitdiff
path: root/popup
diff options
context:
space:
mode:
Diffstat (limited to 'popup')
-rw-r--r--popup/README.txt5
-rw-r--r--popup/popup-help.pd45
-rw-r--r--popup/popup.c56
3 files changed, 86 insertions, 20 deletions
diff --git a/popup/README.txt b/popup/README.txt
index bd6a801..6b517a7 100644
--- a/popup/README.txt
+++ b/popup/README.txt
@@ -26,7 +26,7 @@ USAGE:
Put the binary in your extra folder.
Put the helpfile in your 5.reference folder.
-Arguments: [pixel width] [background colour] [name] [opt1] [opt2] [...]
+Arguments: [pixel width] [pixel height] [background colour] [name] [opt1] [opt2] [...]
Methods:
@@ -34,8 +34,11 @@ Methods:
name [name] Popup's name
bgcolour [colour] Background Colour (white, green, #5500ff)
options [opt1] [...] List of the popup options
+ append [opt1] [...] Add the arg list to the bottom of the current options
BUGS:
- Do not use a loadbang to set a patch-default value. Will cause a segfault.
+ The left outlet will send a "bang" message when we're ready to set values,
+ see example patch on how to use this to set a default value.
Have Fun.
diff --git a/popup/popup-help.pd b/popup/popup-help.pd
index d08d280..2aa0ae8 100644
--- a/popup/popup-help.pd
+++ b/popup/popup-help.pd
@@ -1,20 +1,35 @@
-#N canvas 154 131 631 317 10;
-#X obj 66 220 popup 124 25 white 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 i26 i27 i28 i29 i30;
-#X obj 67 265 print index;
-#X msg 79 100 name popup;
-#X obj 169 266 print symbol;
-#X floatatom 44 78 5 0 0 0 - - -;
-#X msg 126 156 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 i26 i27 i28 i29 i30;
-#X msg 109 130 bgcolour black;
+#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 connect 0 0 1 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 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 5 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 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;
diff --git a/popup/popup.c b/popup/popup.c
index c082751..854a185 100644
--- a/popup/popup.c
+++ b/popup/popup.c
@@ -154,7 +154,7 @@ static void create_widget(t_popup *x, t_glist *glist)
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",
canvas, x, x->x_options[i]->s_name, canvas, x, x->x_options[i]->s_name, x, i);
}
-
+
DEBUG(post("id: .x%x.c.s%x", canvas, x);)
DEBUG(post("create_widget end");)
}
@@ -182,6 +182,9 @@ static void popup_drawme(t_popup *x, t_glist *glist, int firsttime)
// 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);}
}
@@ -382,11 +385,11 @@ void popup_options(t_popup* x, t_symbol *s, int argc, t_atom *argv)
}
/* function to change colour of popup background */
-void popup_bgcolour(t_popup* x, t_symbol* col)
+static void popup_bgcolour(t_popup* x, t_symbol* col)
{
DEBUG(post("bgcolour start");)
- x->x_colour->s_name = col->s_name;
+ x->x_colour = col;
sys_vgui(".x%x.c.s%x configure -background \"%s\"\n", x->x_glist, x, col->s_name);
}
@@ -416,6 +419,44 @@ static void popup_iselect(t_popup* x, t_floatarg item)
DEBUG(post("iselect end");)
}
+/* 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 */
+void popup_append(t_popup* x, t_symbol *s, int argc, t_atom *argv)
+{
+ DEBUG(post("append start");)
+
+ int i, new_limit;
+
+ new_limit = x->x_num_options + argc;
+
+ for(i=x->x_num_options ; i<new_limit ; i++)
+ {
+ x->x_options[i] = atom_getsymbol(argv+i-x->x_num_options);
+ 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, x->x_options[i]->s_name, x->x_glist, x, x->x_options[i]->s_name, x, i);
+ }
+
+ x->x_num_options = new_limit;
+
+ DEBUG(post("append end");)
+}
+
+
+
static t_class *popup_class;
@@ -471,6 +512,7 @@ static void *popup_new(t_symbol *s, int argc, t_atom *argv)
return (x);
DEBUG(post("popup new end");)
+
}
void popup_setup(void) {
@@ -499,6 +541,12 @@ void popup_setup(void) {
gensym("bgcolour"),
A_DEFSYMBOL,
0);
+
+ class_addmethod(popup_class, (t_method)popup_append,
+ gensym("append"),
+ A_GIMME,
+ 0);
+
class_doaddfloat(popup_class, (t_method)popup_iselect);
class_setwidget(popup_class,&popup_widgetbehavior);
@@ -506,7 +554,7 @@ void popup_setup(void) {
class_setsavefn(popup_class,&popup_save);
#endif
- post("Popup v0.1 Ben Bogart.\nCVS: $Revision: 1.8 $ $Date: 2004-11-07 17:53:46 $");
+ post("Popup v0.1 Ben Bogart.\nCVS: $Revision: 1.9 $ $Date: 2004-12-13 23:56:59 $");
}