From 9c3ae143b3d288c1363a191d7175383135dd0de0 Mon Sep 17 00:00:00 2001 From: Thomas O Fredericks Date: Thu, 5 Nov 2009 23:31:16 +0000 Subject: A few fixes and a new pmenu test svn path=/trunk/externals/tof/; revision=12723 --- src/menubutton.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/menubutton.c') diff --git a/src/menubutton.c b/src/menubutton.c index bba287c..a96d81d 100644 --- a/src/menubutton.c +++ b/src/menubutton.c @@ -158,6 +158,23 @@ static void menubutton_clear(t_menubutton* x) { } } +static void menubutton_size(t_menubutton* x,t_symbol *s, int argc, t_atom *argv) { + + if (argc>2) argc =2; + switch (argc) { + case 2: if ( (argv+1)->a_type == A_FLOAT) x->x_height = atom_getfloat(argv+1); + case 1: if ( argv->a_type == A_FLOAT) x->x_width = atom_getfloat(argv); + break; + } + + if ( x->x_width < 10) x->x_width = 10; + if ( x->x_height < 10) x->x_height = 10; + + if ( menubutton_w_is_visible(x) ) { + menubutton_w_resize(x); + } +} + static void menubutton_add(t_menubutton* x, t_symbol *s, int argc, t_atom *argv) { @@ -403,6 +420,9 @@ static void *menubutton_new(t_symbol *s, int argc, t_atom *argv) DEBUG(post("send: %s receive: %s",x->send->s_name,x->receive->s_name);) + if ( x->x_width < 10) x->x_width = 10; + if ( x->x_height < 10) x->x_height = 10; + // Bind receiver if ( x->receive != x->s_empty ) pd_bind(&x->x_obj.ob_pd, x->receive); @@ -455,7 +475,8 @@ void menubutton_setup(void) { class_addmethod(menubutton_class, (t_method)menubutton_colors, gensym("colors"),A_GIMME,0); - + class_addmethod(menubutton_class, (t_method)menubutton_size, + gensym("size"),A_GIMME,0); class_addmethod(menubutton_class, (t_method)menubutton_set, gensym("set"),A_GIMME,0); -- cgit v1.2.1