aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/menubutton.c23
-rw-r--r--src/menubutton_w.h18
2 files changed, 36 insertions, 5 deletions
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);
diff --git a/src/menubutton_w.h b/src/menubutton_w.h
index 8166d83..b519463 100644
--- a/src/menubutton_w.h
+++ b/src/menubutton_w.h
@@ -10,6 +10,9 @@ static int menubutton_w_is_visible(t_menubutton* x) {
}
+
+
+
static void menubutton_w_disable(t_menubutton*x, t_float f){
int i = (int)f;
@@ -151,7 +154,8 @@ static void menubutton_w_create_widget(t_menubutton *x)
sys_vgui("destroy .x%x.c.s%x\n",x->x_glist,x);
// Create menubutton and menu
- sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -justify left -relief flat -anchor w -indicatoron 0 -text \"%s\" -direction flush -menu $%xw.menu ; menu $%xw.menu -relief solid -tearoff 0 \n",
+
+ sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -justify left -relief flat -anchor e -indicatoron 0 -text \"%s\" -direction flush -menu $%xw.menu ; menu $%xw.menu -relief solid -tearoff 0 \n",
x,x->x_glist,x,x,temp_name->s_name,x,x);
menubutton_w_apply_colors(x);
@@ -172,13 +176,13 @@ static void menubutton_w_draw_contour(t_menubutton *x, t_glist *glist, int draw)
int onset = text_xpix(&x->x_obj, glist);
if (draw==CREATE) {
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xR -outline \"%s\" \n",
- glist,
+ glist_getcanvas(glist),
onset, text_ypix(&x->x_obj, glist) ,
onset + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height,
- x,x->co_color->s_name); //"green"
+ x,x->co_color->s_name);
} else if (draw==UPDATE) {
sys_vgui(".x%x.c coords %xR %d %d %d %d\n",
- glist, x,
+ glist_getcanvas(glist), x,
onset, text_ypix(&x->x_obj, glist) ,
onset + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height );
} else {
@@ -187,6 +191,12 @@ static void menubutton_w_draw_contour(t_menubutton *x, t_glist *glist, int draw)
}
+static void menubutton_w_resize(t_menubutton* x) {
+
+ sys_vgui(".x%x.c itemconfigure %xS -width %i -height %i \n", x->x_glist, x,x->x_width-1,x->x_height-1);
+ menubutton_w_draw_contour(x,x->x_glist,UPDATE);
+ canvas_fixlinesfor(x->x_glist,(t_text*) x);
+}
static void menubutton_w_drawme(t_menubutton *x, t_glist *glist, int draw)
{