From d49dbfcc95e0415f780bc957bb94391902f2067f Mon Sep 17 00:00:00 2001 From: Mathieu L Bouchard <matju@artengine.ca> Date: Thu, 7 Aug 2014 17:49:21 -0400 Subject: [PATCH] =?UTF-8?q?refactor=C2=A0:=20merge=20t=5Fiem=5Ffstyle=5Ffl?= =?UTF-8?q?ags=20and=20t=5Fiem=5Finit=5Fsymargs=20into=20t=5Fiemgui.=20rem?= =?UTF-8?q?ove=20type=20t=5Fiemguidummy.=20remove=20fields=20x=5Frcv=5Fabl?= =?UTF-8?q?e,=20x=5Fsnd=5Fable=20and=20x=5Ffont.=20removed=20redundant=20a?= =?UTF-8?q?rg=20"void=20*x"=20in=209=20old=20g=5Fall=5Fguis.c=20functions.?= =?UTF-8?q?=20added=20dummy=20"send"=20method=20to=20[vu]=20for=20consiste?= =?UTF-8?q?ncy.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pd/src/g_all_guis.c | 382 ++++++++++++++++++++++---------------------- pd/src/g_bang.c | 119 ++++---------- pd/src/g_hdial.c | 138 ++++------------ pd/src/g_hslider.c | 113 ++++--------- pd/src/g_mycanvas.c | 91 +++-------- pd/src/g_numbox.c | 158 +++++++----------- pd/src/g_toggle.c | 105 +++--------- pd/src/g_vdial.c | 131 ++++----------- pd/src/g_vslider.c | 109 ++++--------- pd/src/g_vumeter.c | 136 +++++----------- pd/src/m_conf.c | 2 + 11 files changed, 492 insertions(+), 992 deletions(-) diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 51e549114..f44f6bcf3 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -185,11 +185,11 @@ t_symbol *iemgui_raute2dollar(t_symbol *s) void iemgui_verify_snd_ne_rcv(t_iemgui *iemgui) { - iemgui->x_fsf.x_put_in2out = 1; - if(iemgui->x_fsf.x_snd_able && iemgui->x_fsf.x_rcv_able) + iemgui->x_put_in2out = 1; + if(iemgui_has_snd(iemgui) && iemgui_has_rcv(iemgui)) { - if(!strcmp(iemgui->x_snd->s_name, iemgui->x_rcv->s_name)) - iemgui->x_fsf.x_put_in2out = 0; + if(iemgui->x_snd==iemgui->x_rcv) + iemgui->x_put_in2out = 0; } } @@ -203,7 +203,7 @@ t_symbol *iemgui_new_dogetname(t_iemgui *iemgui, int indx, t_atom *argv) sprintf(str, "%d", (int)atom_getintarg(indx, 100000, argv)); return (gensym(str)); } - else return (gensym("empty")); + else return s_empty; } void iemgui_new_getnames(t_iemgui *iemgui, int indx, t_atom *argv) @@ -214,7 +214,7 @@ void iemgui_new_getnames(t_iemgui *iemgui, int indx, t_atom *argv) iemgui->x_rcv = iemgui_new_dogetname(iemgui, indx+1, argv); iemgui->x_lab = iemgui_new_dogetname(iemgui, indx+2, argv); } - else iemgui->x_snd = iemgui->x_rcv = iemgui->x_lab = gensym("empty"); + else iemgui->x_snd = iemgui->x_rcv = iemgui->x_lab = s_empty; iemgui->x_snd_unexpanded = iemgui->x_rcv_unexpanded = iemgui->x_lab_unexpanded = 0; iemgui->x_binbufindex = indx; @@ -250,7 +250,7 @@ static void iemgui_init_sym2dollararg(t_iemgui *iemgui, t_symbol **symp, } else if (fallback) *symp = fallback; - else *symp = gensym("empty"); + else *symp = s_empty; } } @@ -348,118 +348,94 @@ void iemgui_all_raute2dollar(t_symbol **srlsym) srlsym[2] = iemgui_raute2dollar(srlsym[2]); } -void iemgui_send(void *x, t_iemgui *iemgui, t_symbol *s) +void iemgui_send(t_iemgui *x, t_symbol *s) { t_symbol *snd; - int sndable=1, oldsndrcvable=0; + int oldsndrcvable=0; + if(iemgui_has_rcv(x)) oldsndrcvable += IEM_GUI_OLD_RCV_FLAG; + if(iemgui_has_snd(x)) oldsndrcvable += IEM_GUI_OLD_SND_FLAG; - if(iemgui->x_fsf.x_rcv_able) - oldsndrcvable += IEM_GUI_OLD_RCV_FLAG; - if(iemgui->x_fsf.x_snd_able) - oldsndrcvable += IEM_GUI_OLD_SND_FLAG; - - if(!strcmp(s->s_name, "empty")) sndable = 0; snd = iemgui_raute2dollar(s); - iemgui->x_snd_unexpanded = snd; - iemgui->x_snd = snd = canvas_realizedollar(iemgui->x_glist, snd); - iemgui->x_fsf.x_snd_able = sndable; - iemgui_verify_snd_ne_rcv(iemgui); - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_IO + oldsndrcvable); + x->x_snd_unexpanded = snd; + x->x_snd = snd = canvas_realizedollar(x->x_glist, snd); + iemgui_verify_snd_ne_rcv(x); + x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_IO + oldsndrcvable); } -void iemgui_receive(void *x, t_iemgui *iemgui, t_symbol *s) +void iemgui_receive(t_iemgui *x, t_symbol *s) { t_symbol *rcv; - int rcvable=1, oldsndrcvable=0; - - if(iemgui->x_fsf.x_rcv_able) - oldsndrcvable += IEM_GUI_OLD_RCV_FLAG; - if(iemgui->x_fsf.x_snd_able) - oldsndrcvable += IEM_GUI_OLD_SND_FLAG; + int oldsndrcvable=0; + if(iemgui_has_rcv(x)) oldsndrcvable += IEM_GUI_OLD_RCV_FLAG; + if(iemgui_has_snd(x)) oldsndrcvable += IEM_GUI_OLD_SND_FLAG; - if(!strcmp(s->s_name, "empty")) rcvable = 0; rcv = iemgui_raute2dollar(s); - iemgui->x_rcv_unexpanded = rcv; - rcv = canvas_realizedollar(iemgui->x_glist, rcv); - if(rcvable) + x->x_rcv_unexpanded = rcv; + rcv = canvas_realizedollar(x->x_glist, rcv); + if(iemgui_has_rcv(x)) { - if(strcmp(rcv->s_name, iemgui->x_rcv->s_name)) + if(rcv!=x->x_rcv) { - if(iemgui->x_fsf.x_rcv_able) - pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv); - iemgui->x_rcv = rcv; - pd_bind(&iemgui->x_obj.ob_pd, iemgui->x_rcv); + if(iemgui_has_rcv(x)) + pd_unbind((t_pd *)x, x->x_rcv); + x->x_rcv = rcv; + pd_bind((t_pd *)x, x->x_rcv); } } - else if(!rcvable && iemgui->x_fsf.x_rcv_able) + else if(s!=s_empty && iemgui_has_rcv(x)) { - pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv); - iemgui->x_rcv = rcv; + pd_unbind((t_pd *)x, x->x_rcv); + x->x_rcv = rcv; } - iemgui->x_fsf.x_rcv_able = rcvable; - iemgui_verify_snd_ne_rcv(iemgui); - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_IO + oldsndrcvable); + iemgui_verify_snd_ne_rcv(x); + x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_IO + oldsndrcvable); } -void iemgui_label(void *x, t_iemgui *iemgui, t_symbol *s) +void iemgui_label(t_iemgui *x, t_symbol *s) { - t_symbol *lab; - - /* tb: fix for empty label { */ - if (s == gensym("")) - s = gensym("empty"); - /* tb } */ + if (s == &s_) s = s_empty; //tb: fix for empty label + t_symbol *lab = iemgui_raute2dollar(s); + x->x_lab_unexpanded = lab; + x->x_lab = lab = canvas_realizedollar(x->x_glist, lab); - lab = iemgui_raute2dollar(s); - iemgui->x_lab_unexpanded = lab; - iemgui->x_lab = lab = canvas_realizedollar(iemgui->x_glist, lab); - - if(glist_isvisible(iemgui->x_glist)) + if(glist_isvisible(x->x_glist)) { sys_vgui(".x%lx.c itemconfigure %lxLABEL -text {%s} \n", - glist_getcanvas(iemgui->x_glist), x, - strcmp(s->s_name, "empty")?iemgui->x_lab->s_name:""); - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); + glist_getcanvas(x->x_glist), x, + s!=s_empty?x->x_lab->s_name:""); + iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_CONFIG); } } -void iemgui_label_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) +void iemgui_label_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { - iemgui->x_ldx = (int)atom_getintarg(0, ac, av); - iemgui->x_ldy = (int)atom_getintarg(1, ac, av); - if(glist_isvisible(iemgui->x_glist)) + x->x_ldx = (int)atom_getintarg(0, ac, av); + x->x_ldy = (int)atom_getintarg(1, ac, av); + if(glist_isvisible(x->x_glist)) { sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", - glist_getcanvas(iemgui->x_glist), x, - text_xpix((t_object *)x,iemgui->x_glist)+iemgui->x_ldx, - text_ypix((t_object *)x,iemgui->x_glist)+iemgui->x_ldy); - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); + glist_getcanvas(x->x_glist), x, + text_xpix((t_object *)x,x->x_glist)+x->x_ldx, + text_ypix((t_object *)x,x->x_glist)+x->x_ldy); + iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_CONFIG); } } -void iemgui_label_font(void *x, t_iemgui *iemgui, - t_symbol *s, int ac, t_atom *av) +void iemgui_label_font(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { int f = (int)atom_getintarg(0, ac, av); - - if(f == 1) strcpy(iemgui->x_font, "helvetica"); - else if(f == 2) strcpy(iemgui->x_font, "times"); - else - { - f = 0; - strcpy(iemgui->x_font, sys_font); - } - iemgui->x_fsf.x_font_style = f; + if (f<0 || f>2) f=0; + x->x_font_style = f; f = (int)atom_getintarg(1, ac, av); if(f < 4) f = 4; - iemgui->x_fontsize = f; - if(glist_isvisible(iemgui->x_glist)) + x->x_fontsize = f; + if(glist_isvisible(x->x_glist)) { sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s}\n", - glist_getcanvas(iemgui->x_glist), x, iemgui->x_font, - iemgui->x_fontsize, sys_fontweight); - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); + glist_getcanvas(x->x_glist), x, iemgui_font(x), + x->x_fontsize, sys_fontweight); + iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_CONFIG); } } @@ -496,9 +472,9 @@ void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, { //fprintf(stderr,"iemgui_label_getrect\n"); - if (strcmp(x_gui.x_lab->s_name, "empty")) + if (x_gui.x_lab!=s_empty) { - switch(x_gui.x_fsf.x_font_style) + switch(x_gui.x_font_style) { case 1: width_multiplier = 0.83333; @@ -520,7 +496,7 @@ void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, } actual_height = actual_fontsize; //exceptions - if (x_gui.x_fsf.x_font_style == 0 && + if (x_gui.x_font_style == 0 && (actual_fontsize == 8 || actual_fontsize == 13 || actual_fontsize % 10 == 1 || actual_fontsize % 10 == 6 || (actual_fontsize > 48 && actual_fontsize < 100 && @@ -528,10 +504,10 @@ void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, { actual_fontsize += 1; } - else if (x_gui.x_fsf.x_font_style == 1 && actual_fontsize >= 5 && + else if (x_gui.x_font_style == 1 && actual_fontsize >= 5 && actual_fontsize < 13 && actual_fontsize % 2 == 1) actual_fontsize += 1; - else if (x_gui.x_fsf.x_font_style == 2 && actual_fontsize >= 5 && + else if (x_gui.x_font_style == 2 && actual_fontsize >= 5 && actual_fontsize % 2 == 1) actual_fontsize += 1; if (actual_height == 9) @@ -548,7 +524,7 @@ void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, //DEBUG //fprintf(stderr,"%f %d %d\n", width_multiplier, - // label_length, x_gui.x_fsf.x_font_style); + // label_length, x_gui.x_font_style); //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x); //sys_vgui(".x%lx.c create rectangle %d %d %d %d " // "-tags iemguiDEBUG\n", @@ -565,24 +541,24 @@ void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, } } -void iemgui_shouldvis(void *x, t_iemgui *iemgui, int mode) +void iemgui_shouldvis(t_iemgui *x, int mode) { gop_redraw = 1; - if(gobj_shouldvis(x, iemgui->x_glist)) + if(gobj_shouldvis((t_gobj *)x, x->x_glist)) { - if (!iemgui->x_vis) + if (!x->x_vis) { //fprintf(stderr,"draw new %d\n", mode); - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_NEW); - canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); - iemgui->x_vis = 1; - if (iemgui->x_glist != glist_getcanvas(iemgui->x_glist)) + x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_NEW); + canvas_fixlinesfor(glist_getcanvas(x->x_glist), (t_text*)x); + x->x_vis = 1; + if (x->x_glist != glist_getcanvas(x->x_glist)) { /* if we are inside gop and just have had our object's properties changed we'll adjust our layer position to ensure that ordering is honored */ - t_canvas *canvas = glist_getcanvas(iemgui->x_glist); - t_gobj *y = (t_gobj *)iemgui->x_glist; + t_canvas *canvas = glist_getcanvas(x->x_glist); + t_gobj *y = (t_gobj *)x->x_glist; gobj_vis(y, canvas, 0); gobj_vis(y, canvas, 1); // reorder it visually @@ -637,71 +613,70 @@ void iemgui_shouldvis(void *x, t_iemgui *iemgui, int mode) */ } } - //fprintf(stderr,"draw move iemgui->x_w=%d\n", iemgui->x_w); - (*iemgui->x_draw)(x, iemgui->x_glist, mode); - canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); + //fprintf(stderr,"draw move x->x_w=%d\n", x->x_w); + x->x_draw(x, x->x_glist, mode); + canvas_fixlinesfor(glist_getcanvas(x->x_glist), (t_text*)x); } - else if (iemgui->x_vis) + else if (x->x_vis) { //fprintf(stderr,"draw erase %d\n", mode); - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_ERASE); - iemgui->x_vis = 0; + x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_ERASE); + x->x_vis = 0; } gop_redraw = 0; } -void iemgui_size(void *x, t_iemgui *iemgui) +void iemgui_size(t_iemgui *x) { - if(glist_isvisible(iemgui->x_glist)) - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); + if(glist_isvisible(x->x_glist)) + iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_MOVE); } -void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) +void iemgui_delta(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { - iemgui->x_obj.te_xpix += (int)atom_getintarg(0, ac, av); - iemgui->x_obj.te_ypix += (int)atom_getintarg(1, ac, av); - if(glist_isvisible(iemgui->x_glist)) + x->x_obj.te_xpix += (int)atom_getintarg(0, ac, av); + x->x_obj.te_ypix += (int)atom_getintarg(1, ac, av); + if(glist_isvisible(x->x_glist)) { - //fprintf(stderr,"iemgui_delta->shouldvis\n"); - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_MOVE); } } -void iemgui_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) +void iemgui_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { - iemgui->x_obj.te_xpix = (int)atom_getintarg(0, ac, av); - iemgui->x_obj.te_ypix = (int)atom_getintarg(1, ac, av); - if(glist_isvisible(iemgui->x_glist)) - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); + x->x_obj.te_xpix = (int)atom_getintarg(0, ac, av); + x->x_obj.te_ypix = (int)atom_getintarg(1, ac, av); + if(glist_isvisible(x->x_glist)) + iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_MOVE); } -void iemgui_color(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) +void iemgui_color(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { - iemgui->x_bcol = iemgui_compatible_col(atom_getintarg(0, ac, av)); + x->x_bcol = iemgui_compatible_col(atom_getintarg(0, ac, av)); if(ac > 2) { - iemgui->x_fcol = iemgui_compatible_col(atom_getintarg(1, ac, av)); - iemgui->x_lcol = iemgui_compatible_col(atom_getintarg(2, ac, av)); + x->x_fcol = iemgui_compatible_col(atom_getintarg(1, ac, av)); + x->x_lcol = iemgui_compatible_col(atom_getintarg(2, ac, av)); } else - iemgui->x_lcol = iemgui_compatible_col(atom_getintarg(1, ac, av)); - if(glist_isvisible(iemgui->x_glist)) - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_CONFIG); + x->x_lcol = iemgui_compatible_col(atom_getintarg(1, ac, av)); + if(glist_isvisible(x->x_glist)) + x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_CONFIG); } void iemgui_displace(t_gobj *z, t_glist *glist, int dx, int dy) { - t_iemguidummy *x = (t_iemguidummy *)z; - x->x_gui.x_obj.te_xpix += dx; - x->x_gui.x_obj.te_ypix += dy; - iemgui_shouldvis(x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + t_iemgui *x = (t_iemgui *)z; + x->x_obj.te_xpix += dx; + x->x_obj.te_ypix += dy; + iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_MOVE); } void iemgui_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy) { - t_iemguidummy *x = (t_iemguidummy *)z; - x->x_gui.x_obj.te_xpix += dx; - x->x_gui.x_obj.te_ypix += dy; + t_iemgui *x = (t_iemgui *)z; + x->x_obj.te_xpix += dx; + x->x_obj.te_ypix += dy; //(*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_MOVE); canvas_fixlinesfor(glist_getcanvas(glist), (t_text *)z); } @@ -709,10 +684,10 @@ void iemgui_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy) void iemgui_select(t_gobj *z, t_glist *glist, int selected) { - t_iemguidummy *x = (t_iemguidummy *)z; + t_iemgui *x = (t_iemgui *)z; - x->x_gui.x_fsf.x_selected = selected; - (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_SELECT); + x->x_selected = selected; + (*x->x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_SELECT); } void iemgui_delete(t_gobj *z, t_glist *glist) @@ -722,19 +697,19 @@ void iemgui_delete(t_gobj *z, t_glist *glist) void iemgui_vis(t_gobj *z, t_glist *glist, int vis) { - t_iemguidummy *x = (t_iemguidummy *)z; + t_iemgui *x = (t_iemgui *)z; if (gobj_shouldvis(z, glist)) { if (vis) { - (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_NEW); - x->x_gui.x_vis = 1; + (*x->x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_NEW); + x->x_vis = 1; } else { - (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_ERASE); + (*x->x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_ERASE); sys_unqueuegui(z); - x->x_gui.x_vis = 0; + x->x_vis = 0; } } } @@ -768,11 +743,11 @@ int iemgui_dialog(t_iemgui *iemgui, t_symbol **srl, int argc, t_atom *argv) int bcol = (int)atom_getintarg(14, argc, argv); int fcol = (int)atom_getintarg(15, argc, argv); int lcol = (int)atom_getintarg(16, argc, argv); - int sndable=1, rcvable=1, oldsndrcvable=0; + int rcvable=1, oldsndrcvable=0; - if(iemgui->x_fsf.x_rcv_able) + if(iemgui_has_rcv(iemgui)) oldsndrcvable += IEM_GUI_OLD_RCV_FLAG; - if(iemgui->x_fsf.x_snd_able) + if(iemgui_has_snd(iemgui)) oldsndrcvable += IEM_GUI_OLD_SND_FLAG; if(IS_A_SYMBOL(argv,7)) srl[0] = atom_getsymbolarg(7, argc, argv); @@ -796,43 +771,33 @@ int iemgui_dialog(t_iemgui *iemgui, t_symbol **srl, int argc, t_atom *argv) srl[2] = gensym(str); } if(init != 0) init = 1; - iemgui->x_isa.x_loadinit = init; - if(!strcmp(srl[0]->s_name, "empty")) sndable = 0; - if(!strcmp(srl[1]->s_name, "empty")) rcvable = 0; + iemgui->x_loadinit = init; iemgui_all_raute2dollar(srl); iemgui_all_dollararg2sym(iemgui, srl); if(rcvable) { - if(strcmp(srl[1]->s_name, iemgui->x_rcv->s_name)) + if(srl[1]!=iemgui->x_rcv) { - if(iemgui->x_fsf.x_rcv_able) + if(iemgui_has_rcv(iemgui)) pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv); iemgui->x_rcv = srl[1]; pd_bind(&iemgui->x_obj.ob_pd, iemgui->x_rcv); } } - else if(!rcvable && iemgui->x_fsf.x_rcv_able) + else if(!rcvable && iemgui_has_rcv(iemgui)) { pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv); iemgui->x_rcv = srl[1]; } iemgui->x_snd = srl[0]; - iemgui->x_fsf.x_snd_able = sndable; - iemgui->x_fsf.x_rcv_able = rcvable; iemgui->x_lcol = lcol & 0xffffff; iemgui->x_fcol = fcol & 0xffffff; iemgui->x_bcol = bcol & 0xffffff; iemgui->x_lab = srl[2]; iemgui->x_ldx = ldx; iemgui->x_ldy = ldy; - if(f == 1) strcpy(iemgui->x_font, "helvetica"); - else if(f == 2) strcpy(iemgui->x_font, "times"); - else - { - f = 0; - strcpy(iemgui->x_font, sys_font); - } - iemgui->x_fsf.x_font_style = f; + if(f<0 || f>2) f=0; + iemgui->x_font_style = f; if(fs < 4) fs = 4; iemgui->x_fontsize = fs; @@ -841,41 +806,37 @@ int iemgui_dialog(t_iemgui *iemgui, t_symbol **srl, int argc, t_atom *argv) return(oldsndrcvable); } -void iem_inttosymargs(t_iem_init_symargs *symargp, int n) +void iem_inttosymargs(t_iemgui *x, int n) { - memset(symargp, 0, sizeof(*symargp)); - symargp->x_loadinit = (n >> 0); - symargp->x_scale = (n >> 20); - symargp->x_flashed = 0; - symargp->x_locked = 0; - symargp->x_reverse = 0; - symargp->dummy = 0; + x->x_loadinit = (n >> 0); + x->x_scale = (n >> 20); + x->x_flashed = 0; + x->x_locked = 0; + x->x_reverse = 0; } -int iem_symargstoint(t_iem_init_symargs *symargp) +int iem_symargstoint(t_iemgui *x) { return ( - (((symargp->x_loadinit & 1) << 0) | - ((symargp->x_scale & 1) << 20))); + (((x->x_loadinit & 1) << 0) | + ((x->x_scale & 1) << 20))); } -void iem_inttofstyle(t_iem_fstyle_flags *fstylep, int n) +void iem_inttofstyle(t_iemgui *x, int n) { - memset(fstylep, 0, sizeof(*fstylep)); - fstylep->x_font_style = (n >> 0); - fstylep->x_selected = 0; - fstylep->x_finemoved = 0; - fstylep->x_put_in2out = 0; - fstylep->x_change = 0; - fstylep->x_thick = 0; - fstylep->x_lin0_log1 = 0; - fstylep->x_steady = 0; - fstylep->dummy = 0; -} - -int iem_fstyletoint(t_iem_fstyle_flags *fstylep) + x->x_font_style = (n >> 0); + x->x_selected = 0; + x->x_finemoved = 0; + x->x_put_in2out = 0; + x->x_change = 0; + x->x_thick = 0; + x->x_lin0_log1 = 0; + x->x_steady = 0; +} + +int iem_fstyletoint(t_iemgui *x) { - return ((fstylep->x_font_style << 0) & 63); + return ((x->x_font_style << 0) & 63); } char *iem_get_tag(t_canvas *glist, t_iemgui *iem_obj) @@ -954,7 +915,7 @@ const char *nlet_tag, const char *class_tag) { void scalehandle_draw_select2(t_iemgui *x, t_glist *canvas, const char *class_tag, int sx, int sy) { char *nlet_tag = iem_get_tag(canvas, (t_iemgui *)x); scalehandle_draw_select(x->x_handle,canvas,sx,sy,nlet_tag,class_tag); - if (strcmp(x->x_lab->s_name, "empty") != 0) + if (x->x_lab!=s_empty) { scalehandle_draw_select(x->x_lhandle,canvas,x->x_ldx,x->x_ldy,nlet_tag,class_tag); } @@ -1107,7 +1068,7 @@ void scalehandle_drag_scale(t_scalehandle *h) { // IEMGUI refactor (by Mathieu) void iemgui_tag_selected(t_iemgui *x, t_glist *canvas, const char *class_tag) { - if(x->x_fsf.x_selected) + if(x->x_selected) sys_vgui(".x%lx.c addtag selected withtag %lx%s\n", canvas, x, class_tag); else sys_vgui(".x%lx.c dtag %lx%s selected\n", canvas, x, class_tag); @@ -1118,8 +1079,8 @@ void iemgui_label_draw_new(t_iemgui *x, t_glist *canvas, int xpos, int ypos, con "-font {{%s} -%d %s} -fill #%6.6x " "-tags {%lxLABEL %lx%s text iemgui %s}\n", canvas, xpos+x->x_ldx, ypos+x->x_ldy, - strcmp(x->x_lab->s_name, "empty")?x->x_lab->s_name:"", - x->x_font, x->x_fontsize, sys_fontweight, + x->x_lab!=s_empty?x->x_lab->s_name:"", + iemgui_font(x), x->x_fontsize, sys_fontweight, x->x_lcol, x, x, class_tag, nlet_tag); } void iemgui_label_draw_move(t_iemgui *x, t_glist *canvas, int xpos, int ypos) { @@ -1127,19 +1088,19 @@ void iemgui_label_draw_move(t_iemgui *x, t_glist *canvas, int xpos, int ypos) { canvas, x, xpos+x->x_ldx, ypos+x->x_ldy); } void iemgui_label_draw_config(t_iemgui *x, t_glist *canvas) { - if (x->x_fsf.x_selected && x->x_glist == canvas) + if (x->x_selected && x->x_glist == canvas) sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} " "-fill $pd_colors(selection) -text {%s} \n", - canvas, x, x->x_font, x->x_fontsize, sys_fontweight, - strcmp(x->x_lab->s_name, "empty")?x->x_lab->s_name:""); + canvas, x, iemgui_font(x), x->x_fontsize, sys_fontweight, + x->x_lab!=s_empty?x->x_lab->s_name:""); else sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} " "-fill #%6.6x -text {%s} \n", - canvas, x, x->x_font, x->x_fontsize, sys_fontweight, - x->x_lcol, strcmp(x->x_lab->s_name, "empty")?x->x_lab->s_name:""); + canvas, x, iemgui_font(x), x->x_fontsize, sys_fontweight, + x->x_lcol, x->x_lab!=s_empty?x->x_lab->s_name:""); } void iemgui_label_draw_select(t_iemgui *x, t_glist *canvas) { - if(x->x_fsf.x_selected) + if(x->x_selected) sys_vgui(".x%lx.c itemconfigure %lxLABEL " "-fill $pd_colors(selection)\n", canvas, x); else @@ -1162,7 +1123,7 @@ void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags, const char * c->c_wb->w_getrectfn((t_gobj *)x,canvas,&x1,&y1,&x2,&y2); a=old_sr_flags&IEM_GUI_OLD_SND_FLAG; - //b=x->x_fsf.x_snd_able; // not inited at moment of new + //b=iemgui_has_snd(x); // not inited at moment of new b=x->x_snd!=s_empty; //printf("a=%d b=%d snd=%s\n",a,b,x->x_snd->s_name); if(a && !b) @@ -1177,7 +1138,7 @@ void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags, const char * sys_vgui(".x%lx.c delete %lx%s%so%d\n", canvas, x, class_tag, nlet_tag, 0); a=old_sr_flags&IEM_GUI_OLD_RCV_FLAG; - //b=x->x_fsf.x_rcv_able; // not inited at moment of new + //b=iemgui_has_rcv(x); // not inited at moment of new b=x->x_rcv!=s_empty; //printf("a=%d b=%d rcv=%s\n",a,b,x->x_rcv->s_name); if(a && !b) @@ -1210,3 +1171,34 @@ void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl) { wb->w_clickfn = cl; wb->w_displacefnwtag = iemgui_displace_withtag; } + +const char *iemgui_font(t_iemgui *x) { + int f = x->x_font_style; + if(f == 0) return sys_font; + if(f == 1) return "helvetica"; + if(f == 2) return "times"; + return "invalid-font"; +} + +void iemgui_class_addmethods(t_class *c) { + class_addmethod(c, (t_method)iemgui_delta, + gensym("delta"), A_GIMME, 0); + class_addmethod(c, (t_method)iemgui_pos, + gensym("pos"), A_GIMME, 0); + class_addmethod(c, (t_method)iemgui_color, + gensym("color"), A_GIMME, 0); + class_addmethod(c, (t_method)iemgui_send, + gensym("send"), A_DEFSYM, 0); + class_addmethod(c, (t_method)iemgui_receive, + gensym("receive"), A_DEFSYM, 0); + class_addmethod(c, (t_method)iemgui_label, + gensym("label"), A_DEFSYM, 0); + class_addmethod(c, (t_method)iemgui_label_pos, + gensym("label_pos"), A_GIMME, 0); + class_addmethod(c, (t_method)iemgui_label_font, + gensym("label_font"), A_GIMME, 0); +} + +void g_iemgui_setup (void) { + s_empty = gensym("empty"); +} diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c index 559075ec8..044a69f5a 100644 --- a/pd/src/g_bang.c +++ b/pd/src/g_bang.c @@ -111,17 +111,17 @@ void bng_draw_move(t_bng *x, t_glist *glist) sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x -r %f\n", canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, cr); iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxBNG%so%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xpos, ypos + x->x_gui.x_h-1, xpos + IOWIDTH, ypos + x->x_gui.x_h); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxBNG%si%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xpos, ypos, xpos + IOWIDTH, ypos+1); /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) bng_draw_select(x, x->x_gui.x_glist); } } @@ -141,7 +141,7 @@ void bng_draw_config(t_bng* x, t_glist* glist) void bng_draw_select(t_bng* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_fsf.x_selected) + if(x->x_gui.x_selected) { /* check if we are drawing inside a gop abstraction visible on parent canvas -- if so, disable highlighting */ @@ -268,10 +268,10 @@ static void bng_save(t_gobj *z, t_binbuf *b) (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix, gensym("bng"), x->x_gui.x_w, x->x_flashtime_hold, x->x_flashtime_break, - iem_symargstoint(&x->x_gui.x_isa), + iem_symargstoint(&x->x_gui), srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, - iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + iem_fstyletoint(&x->x_gui), x->x_gui.x_fontsize, bflcol[0], bflcol[1], bflcol[2]); binbuf_addv(b, ";"); } @@ -311,10 +311,10 @@ static void bng_properties(t_gobj *z, t_glist *owner) %d %d %d\n", x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_flashtime_break, x->x_flashtime_hold, 2,/*min_max_schedule+clip*/ - -1, x->x_gui.x_isa.x_loadinit, -1, -1,/*no linlog, no multi*/ + -1, x->x_gui.x_loadinit, -1, -1,/*no linlog, no multi*/ srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, - x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + x->x_gui.x_font_style, x->x_gui.x_fontsize, 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } @@ -338,32 +338,33 @@ static void bng_set(t_bng *x) static void bng_bout1(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/ { - if(!x->x_gui.x_fsf.x_put_in2out) + fprintf(stderr,"bng_bout1: snd=%s rcv=%s\n",x->x_gui.x_snd->s_name,x->x_gui.x_rcv->s_name); + if(!x->x_gui.x_put_in2out) { - x->x_gui.x_isa.x_locked = 1; + x->x_gui.x_locked = 1; clock_delay(x->x_clock_lck, 2); } outlet_bang(x->x_gui.x_obj.ob_outlet); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing && - x->x_gui.x_fsf.x_put_in2out) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing && + x->x_gui.x_put_in2out) pd_bang(x->x_gui.x_snd->s_thing); } static void bng_bout2(t_bng *x)/*wird immer gesendet, wenn moeglich*/ { - if(!x->x_gui.x_fsf.x_put_in2out) + if(!x->x_gui.x_put_in2out) { - x->x_gui.x_isa.x_locked = 1; + x->x_gui.x_locked = 1; clock_delay(x->x_clock_lck, 2); } outlet_bang(x->x_gui.x_obj.ob_outlet); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_bang(x->x_gui.x_snd->s_thing); } static void bng_bang(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/ { - if(!x->x_gui.x_isa.x_locked) + if(!x->x_gui.x_locked) { bng_set(x); bng_bout1(x); @@ -372,7 +373,7 @@ static void bng_bang(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/ static void bng_bang2(t_bng *x)/*wird immer gesendet, wenn moeglich*/ { - if(!x->x_gui.x_isa.x_locked) + if(!x->x_gui.x_locked) { bng_set(x); bng_bout2(x); @@ -396,10 +397,10 @@ static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { bng_draw_select(x, x->x_gui.x_glist); } @@ -445,7 +446,7 @@ static void bng_anything(t_bng *x, t_symbol *s, int argc, t_atom *argv) static void bng_loadbang(t_bng *x) { - if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) + if(!sys_noloadbang && x->x_gui.x_loadinit) { bng_set(x); bng_bout2(x); @@ -456,42 +457,18 @@ static void bng_size(t_bng *x, t_symbol *s, int ac, t_atom *av) { x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_h = x->x_gui.x_w; - iemgui_size((void *)x, &x->x_gui); + iemgui_size(&x->x_gui); } -static void bng_delta(t_bng *x, t_symbol *s, int ac, t_atom *av) -{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} - -static void bng_pos(t_bng *x, t_symbol *s, int ac, t_atom *av) -{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} - static void bng_flashtime(t_bng *x, t_symbol *s, int ac, t_atom *av) { bng_check_minmax(x, (int)atom_getintarg(0, ac, av), (int)atom_getintarg(1, ac, av)); } -static void bng_color(t_bng *x, t_symbol *s, int ac, t_atom *av) -{iemgui_color((void *)x, &x->x_gui, s, ac, av);} - -static void bng_send(t_bng *x, t_symbol *s) -{iemgui_send(x, &x->x_gui, s);} - -static void bng_receive(t_bng *x, t_symbol *s) -{iemgui_receive(x, &x->x_gui, s);} - -static void bng_label(t_bng *x, t_symbol *s) -{iemgui_label((void *)x, &x->x_gui, s);} - -static void bng_label_pos(t_bng *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} - -static void bng_label_font(t_bng *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} - static void bng_init(t_bng *x, t_floatarg f) { - x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; + x->x_gui.x_loadinit = (f==0.0)?0:1; } static void bng_tick_hld(t_bng *x) @@ -507,7 +484,7 @@ static void bng_tick_brk(t_bng *x) static void bng_tick_lck(t_bng *x) { - x->x_gui.x_isa.x_locked = 0; + x->x_gui.x_locked = 0; } static void *bng_new(t_symbol *s, int argc, t_atom *argv) @@ -520,8 +497,8 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME; - iem_inttosymargs(&x->x_gui.x_isa, 0); - iem_inttofstyle(&x->x_gui.x_fsf, 0); + iem_inttosymargs(&x->x_gui, 0); + iem_inttofstyle(&x->x_gui, 0); if((argc == 14)&&IS_A_FLOAT(argv,0) &&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2) @@ -537,11 +514,11 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) a = (int)atom_getintarg(0, argc, argv); fthold = (int)atom_getintarg(1, argc, argv); ftbreak = (int)atom_getintarg(2, argc, argv); - iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(3, argc, argv)); + iem_inttosymargs(&x->x_gui, atom_getintarg(3, argc, argv)); iemgui_new_getnames(&x->x_gui, 4, argv); ldx = (int)atom_getintarg(7, argc, argv); ldy = (int)atom_getintarg(8, argc, argv); - iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv)); + iem_inttofstyle(&x->x_gui, atom_getintarg(9, argc, argv)); fs = (int)atom_getintarg(10, argc, argv); bflcol[0] = (int)atom_getintarg(11, argc, argv); bflcol[1] = (int)atom_getintarg(12, argc, argv); @@ -551,25 +528,10 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.x_draw = (t_iemfunptr)bng_draw; - x->x_gui.x_fsf.x_snd_able = 1; - x->x_gui.x_fsf.x_rcv_able = 1; x->x_flashed = 0; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); - if (!strcmp(x->x_gui.x_snd->s_name, "empty")) - x->x_gui.x_fsf.x_snd_able = 0; - if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) - x->x_gui.x_fsf.x_rcv_able = 0; - if (x->x_gui.x_fsf.x_font_style == 1) - strcpy(x->x_gui.x_font, "helvetica"); - else if (x->x_gui.x_fsf.x_font_style == 2) - strcpy(x->x_gui.x_font, "times"); - else - { - x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); - } - - if (x->x_gui.x_fsf.x_rcv_able) + if (x->x_gui.x_font_style<0 || x->x_gui.x_font_style>2) x->x_gui.x_font_style=0; + if (iemgui_has_rcv(&x->x_gui)) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; @@ -581,7 +543,7 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.x_h = x->x_gui.x_w; bng_check_minmax(x, ftbreak, fthold); iemgui_all_colfromload(&x->x_gui, bflcol); - x->x_gui.x_isa.x_locked = 0; + x->x_gui.x_locked = 0; iemgui_verify_snd_ne_rcv(&x->x_gui); x->x_clock_hld = clock_new(x, (t_method)bng_tick_hld); x->x_clock_brk = clock_new(x, (t_method)bng_tick_brk); @@ -598,7 +560,7 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) static void bng_ff(t_bng *x) { - if(x->x_gui.x_fsf.x_rcv_able) + if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); clock_free(x->x_clock_lck); clock_free(x->x_clock_brk); @@ -625,22 +587,9 @@ void g_bang_setup(void) A_GIMME, 0); class_addmethod(bng_class, (t_method)bng_loadbang, gensym("loadbang"), 0); class_addmethod(bng_class, (t_method)bng_size, gensym("size"), A_GIMME, 0); - class_addmethod(bng_class, (t_method)bng_delta, gensym("delta"), - A_GIMME, 0); - class_addmethod(bng_class, (t_method)bng_pos, gensym("pos"), A_GIMME, 0); + iemgui_class_addmethods(bng_class); class_addmethod(bng_class, (t_method)bng_flashtime, gensym("flashtime"), A_GIMME, 0); - class_addmethod(bng_class, (t_method)bng_color, gensym("color"), - A_GIMME, 0); - class_addmethod(bng_class, (t_method)bng_send, gensym("send"), A_DEFSYM, 0); - class_addmethod(bng_class, (t_method)bng_receive, gensym("receive"), - A_DEFSYM, 0); - class_addmethod(bng_class, (t_method)bng_label, gensym("label"), - A_DEFSYM, 0); - class_addmethod(bng_class, (t_method)bng_label_pos, gensym("label_pos"), - A_GIMME, 0); - class_addmethod(bng_class, (t_method)bng_label_font, gensym("label_font"), - A_GIMME, 0); class_addmethod(bng_class, (t_method)bng_init, gensym("init"), A_FLOAT, 0); scalehandle_class = class_new(gensym("_scalehandle"), 0, 0, @@ -655,6 +604,4 @@ void g_bang_setup(void) class_sethelpsymbol(bng_class, gensym("bng")); class_setsavefn(bng_class, bng_save); class_setpropertiesfn(bng_class, bng_properties); - - s_empty = gensym("empty"); } diff --git a/pd/src/g_hdial.c b/pd/src/g_hdial.c index 067ace9d5..5eadf09ee 100644 --- a/pd/src/g_hdial.c +++ b/pd/src/g_hdial.c @@ -123,14 +123,14 @@ void hradio_draw_move(t_hradio *x, t_glist *glist) xx22 += dx; } iemgui_label_draw_move(&x->x_gui,canvas,xx11b,yy11); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxHRDO%so%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xx11b, yy12-1, xx11b + IOWIDTH, yy12); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxHRDO%si%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1); /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) hradio_draw_select(x, x->x_gui.x_glist); } } @@ -158,7 +158,7 @@ void hradio_draw_config(t_hradio* x, t_glist* glist) void hradio_draw_select(t_hradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_fsf.x_selected) + if(x->x_gui.x_selected) { // check if we are drawing inside a gop abstraction // visible on parent canvas. If so, disable highlighting @@ -285,10 +285,10 @@ static void hradio_save(t_gobj *z, t_binbuf *b) (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class ? gensym("hdl") : gensym("hradio")), x->x_gui.x_w, - x->x_change, iem_symargstoint(&x->x_gui.x_isa), x->x_number, + x->x_change, iem_symargstoint(&x->x_gui), x->x_number, srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, - iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + iem_fstyletoint(&x->x_gui), x->x_gui.x_fontsize, bflcol[0], bflcol[1], bflcol[2], x->x_on); binbuf_addv(b, ";"); } @@ -313,10 +313,10 @@ static void hradio_properties(t_gobj *z, t_glist *owner) %d %d %d\n", x->x_gui.x_w, IEM_GUI_MINSIZE, 0,/*no_schedule*/ - hchange, x->x_gui.x_isa.x_loadinit, -1, x->x_number, + hchange, x->x_gui.x_loadinit, -1, x->x_number, srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, - x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + x->x_gui.x_font_style, x->x_gui.x_fontsize, 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); @@ -354,11 +354,11 @@ static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); } /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { hradio_draw_select(x, x->x_gui.x_glist); } @@ -405,20 +405,20 @@ static void hradio_bang(t_hradio *x) SETFLOAT(x->x_at, (t_float)x->x_on_old); SETFLOAT(x->x_at+1, 0.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } x->x_on_old = x->x_on; SETFLOAT(x->x_at, (t_float)x->x_on); SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } else { outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); } } @@ -439,7 +439,7 @@ static void hradio_fout(t_hradio *x, t_floatarg f) SETFLOAT(x->x_at, (t_float)x->x_on_old); SETFLOAT(x->x_at+1, 0.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } if(x->x_on != x->x_on_old) @@ -450,7 +450,7 @@ static void hradio_fout(t_hradio *x, t_floatarg f) SETFLOAT(x->x_at, (t_float)x->x_on); SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } else @@ -460,7 +460,7 @@ static void hradio_fout(t_hradio *x, t_floatarg f) if (i != x->x_on_old) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); } } @@ -479,12 +479,12 @@ static void hradio_float(t_hradio *x, t_floatarg f) /* compatibility with earlier "vdial" behavior */ if((x->x_change)&&(i != x->x_on_old)) { - if(x->x_gui.x_fsf.x_put_in2out) + if(x->x_gui.x_put_in2out) { SETFLOAT(x->x_at, (t_float)x->x_on_old); SETFLOAT(x->x_at+1, 0.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } } @@ -493,12 +493,12 @@ static void hradio_float(t_hradio *x, t_floatarg f) x->x_on = i; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); x->x_on_old = x->x_on; - if(x->x_gui.x_fsf.x_put_in2out) + if(x->x_gui.x_put_in2out) { SETFLOAT(x->x_at, (t_float)x->x_on); SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } } @@ -508,10 +508,10 @@ static void hradio_float(t_hradio *x, t_floatarg f) x->x_on = i; if (i != x->x_on_old) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - if (x->x_gui.x_fsf.x_put_in2out) + if (x->x_gui.x_put_in2out) { outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); } } @@ -538,7 +538,7 @@ static int hradio_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, static void hradio_loadbang(t_hradio *x) { - if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) + if(!sys_noloadbang && x->x_gui.x_loadinit) hradio_bang(x); } @@ -565,36 +565,12 @@ static void hradio_size(t_hradio *x, t_symbol *s, int ac, t_atom *av) { x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_h = x->x_gui.x_w; - iemgui_size((void *)x, &x->x_gui); + iemgui_size(&x->x_gui); } -static void hradio_delta(t_hradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} - -static void hradio_pos(t_hradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} - -static void hradio_color(t_hradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_color((void *)x, &x->x_gui, s, ac, av);} - -static void hradio_send(t_hradio *x, t_symbol *s) -{iemgui_send(x, &x->x_gui, s);} - -static void hradio_receive(t_hradio *x, t_symbol *s) -{iemgui_receive(x, &x->x_gui, s);} - -static void hradio_label(t_hradio *x, t_symbol *s) -{iemgui_label((void *)x, &x->x_gui, s);} - -static void hradio_label_pos(t_hradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} - -static void hradio_label_font(t_hradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} - static void hradio_init(t_hradio *x, t_floatarg f) { - x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; + x->x_gui.x_loadinit = (f==0.0)?0:1; } static void hradio_double_change(t_hradio *x) @@ -611,8 +587,8 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) int ldx=0, ldy=-8, chg=1, num=8; int fs=10; - iem_inttosymargs(&x->x_gui.x_isa, 0); - iem_inttofstyle(&x->x_gui.x_fsf, 0); + iem_inttosymargs(&x->x_gui, 0); + iem_inttofstyle(&x->x_gui, 0); if((argc == 15)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2) &&IS_A_FLOAT(argv,3) @@ -625,12 +601,12 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) { a = (int)atom_getintarg(0, argc, argv); chg = (int)atom_getintarg(1, argc, argv); - iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv)); + iem_inttosymargs(&x->x_gui, atom_getintarg(2, argc, argv)); num = (int)atom_getintarg(3, argc, argv); iemgui_new_getnames(&x->x_gui, 4, argv); ldx = (int)atom_getintarg(7, argc, argv); ldy = (int)atom_getintarg(8, argc, argv); - iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv)); + iem_inttofstyle(&x->x_gui, atom_getintarg(9, argc, argv)); fs = (int)atom_getintarg(10, argc, argv); bflcol[0] = (int)atom_getintarg(11, argc, argv); bflcol[1] = (int)atom_getintarg(12, argc, argv); @@ -639,22 +615,8 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) } else iemgui_new_getnames(&x->x_gui, 4, 0); x->x_gui.x_draw = (t_iemfunptr)hradio_draw; - x->x_gui.x_fsf.x_snd_able = 1; - x->x_gui.x_fsf.x_rcv_able = 1; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); - if (!strcmp(x->x_gui.x_snd->s_name, "empty")) - x->x_gui.x_fsf.x_snd_able = 0; - if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) - x->x_gui.x_fsf.x_rcv_able = 0; - if (x->x_gui.x_fsf.x_font_style == 1) - strcpy(x->x_gui.x_font, "helvetica"); - else if(x->x_gui.x_fsf.x_font_style == 2) - strcpy(x->x_gui.x_font, "times"); - else - { - x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); - } + if (x->x_gui.x_font_style<0 || x->x_gui.x_font_style>2) x->x_gui.x_font_style=0; if(num < 1) num = 1; if(num > IEM_RADIO_MAX) @@ -664,13 +626,13 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) on = 0; if(on >= x->x_number) on = x->x_number - 1; - if(x->x_gui.x_isa.x_loadinit) + if(x->x_gui.x_loadinit) x->x_on = on; else x->x_on = 0; x->x_on_old = x->x_on; x->x_change = (chg==0)?0:1; - if (x->x_gui.x_fsf.x_rcv_able) + if (iemgui_has_rcv(&x->x_gui)) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; @@ -702,7 +664,7 @@ static void *hdial_new(t_symbol *s, int argc, t_atom *argv) static void hradio_ff(t_hradio *x) { - if(x->x_gui.x_fsf.x_rcv_able) + if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -726,22 +688,7 @@ void g_hradio_setup(void) gensym("set"), A_FLOAT, 0); class_addmethod(hradio_class, (t_method)hradio_size, gensym("size"), A_GIMME, 0); - class_addmethod(hradio_class, (t_method)hradio_delta, - gensym("delta"), A_GIMME, 0); - class_addmethod(hradio_class, (t_method)hradio_pos, - gensym("pos"), A_GIMME, 0); - class_addmethod(hradio_class, (t_method)hradio_color, - gensym("color"), A_GIMME, 0); - class_addmethod(hradio_class, (t_method)hradio_send, - gensym("send"), A_DEFSYM, 0); - class_addmethod(hradio_class, (t_method)hradio_receive, - gensym("receive"), A_DEFSYM, 0); - class_addmethod(hradio_class, (t_method)hradio_label, - gensym("label"), A_DEFSYM, 0); - class_addmethod(hradio_class, (t_method)hradio_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(hradio_class, (t_method)hradio_label_font, - gensym("label_font"), A_GIMME, 0); + iemgui_class_addmethods(hradio_class); class_addmethod(hradio_class, (t_method)hradio_init, gensym("init"), A_FLOAT, 0); class_addmethod(hradio_class, (t_method)hradio_number, @@ -783,22 +730,7 @@ void g_hradio_setup(void) gensym("set"), A_FLOAT, 0); class_addmethod(hradio_old_class, (t_method)hradio_size, gensym("size"), A_GIMME, 0); - class_addmethod(hradio_old_class, (t_method)hradio_delta, - gensym("delta"), A_GIMME, 0); - class_addmethod(hradio_old_class, (t_method)hradio_pos, - gensym("pos"), A_GIMME, 0); - class_addmethod(hradio_old_class, (t_method)hradio_color, - gensym("color"), A_GIMME, 0); - class_addmethod(hradio_old_class, (t_method)hradio_send, - gensym("send"), A_DEFSYM, 0); - class_addmethod(hradio_old_class, (t_method)hradio_receive, - gensym("receive"), A_DEFSYM, 0); - class_addmethod(hradio_old_class, (t_method)hradio_label, - gensym("label"), A_DEFSYM, 0); - class_addmethod(hradio_old_class, (t_method)hradio_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(hradio_old_class, (t_method)hradio_label_font, - gensym("label_font"), A_GIMME, 0); + iemgui_class_addmethods(hradio_old_class); class_addmethod(hradio_old_class, (t_method)hradio_init, gensym("init"), A_FLOAT, 0); class_addmethod(hradio_old_class, (t_method)hradio_number, diff --git a/pd/src/g_hslider.c b/pd/src/g_hslider.c index 2519831d1..ed12172e7 100644 --- a/pd/src/g_hslider.c +++ b/pd/src/g_hslider.c @@ -121,18 +121,18 @@ static void hslider_draw_move(t_hslider *x, t_glist *glist) canvas, x, r, ypos+2, r, ypos + x->x_gui.x_h-2); iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxHSLDR%so%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xpos, ypos + x->x_gui.x_h-1, xpos+7, ypos + x->x_gui.x_h); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxHSLDR%si%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xpos, ypos, xpos+7, ypos+1); /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { hslider_draw_select(x, x->x_gui.x_glist); } @@ -151,7 +151,7 @@ static void hslider_draw_config(t_hslider* x,t_glist* glist) static void hslider_draw_select(t_hslider* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_fsf.x_selected) + if(x->x_gui.x_selected) { // check if we are drawing inside a gop abstraction // visible on parent canvas. If so, disable highlighting @@ -287,10 +287,10 @@ static void hslider_save(t_gobj *z, t_binbuf *b) (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix, gensym("hsl"), x->x_gui.x_w, x->x_gui.x_h, (t_float)x->x_min, (t_float)x->x_max, - x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa), + x->x_lin0_log1, iem_symargstoint(&x->x_gui), srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, - iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + iem_fstyletoint(&x->x_gui), x->x_gui.x_fontsize, bflcol[0], bflcol[1], bflcol[2], x->x_val, x->x_steady); binbuf_addv(b, ";"); @@ -333,9 +333,9 @@ void hslider_check_minmax(t_hslider *x, double min, double max) x->x_min = min; x->x_max = max; if(x->x_min > x->x_max) /* bugfix */ - x->x_gui.x_isa.x_reverse = 1; + x->x_gui.x_reverse = 1; else - x->x_gui.x_isa.x_reverse = 0; + x->x_gui.x_reverse = 0; if(x->x_lin0_log1) x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_w - 1); else @@ -359,10 +359,10 @@ static void hslider_properties(t_gobj *z, t_glist *owner) %d %d %d\n", x->x_gui.x_w, IEM_SL_MINSIZE, x->x_gui.x_h, IEM_GUI_MINSIZE, x->x_min, x->x_max, 0.0,/*no_schedule*/ - x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/ + x->x_lin0_log1, x->x_gui.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/ srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, - x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + x->x_gui.x_font_style, x->x_gui.x_fontsize, 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } @@ -371,7 +371,7 @@ static void hslider_set(t_hslider *x, t_floatarg f) /* bugfix */ { double g; - if(x->x_gui.x_isa.x_reverse) /* bugfix */ + if(x->x_gui.x_reverse) /* bugfix */ { if(f > x->x_min) f = x->x_min; @@ -415,7 +415,7 @@ static void hslider_bang(t_hslider *x) if((out < 1.0e-10)&&(out > -1.0e-10)) out = 0.0; outlet_float(x->x_gui.x_obj.ob_outlet, out); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, out); } @@ -451,10 +451,10 @@ static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { hslider_draw_select(x, x->x_gui.x_glist); } @@ -470,7 +470,7 @@ static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy) x->x_is_last_float = 0; int old = x->x_val; - if(x->x_gui.x_fsf.x_finemoved) + if(x->x_gui.x_finemoved) x->x_pos += (int)dx; else x->x_pos += 100*(int)dx; @@ -527,9 +527,9 @@ static int hslider_newclick(t_gobj *z, struct _glist *glist, hslider_click(x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); if(shift) - x->x_gui.x_fsf.x_finemoved = 1; + x->x_gui.x_finemoved = 1; else - x->x_gui.x_fsf.x_finemoved = 0; + x->x_gui.x_finemoved = 0; } return (1); } @@ -539,39 +539,15 @@ static void hslider_size(t_hslider *x, t_symbol *s, int ac, t_atom *av) hslider_check_width(x, (int)atom_getintarg(0, ac, av)); if(ac > 1) x->x_gui.x_h = iemgui_clip_size((int)atom_getintarg(1, ac, av)); - iemgui_size((void *)x, &x->x_gui); + iemgui_size(&x->x_gui); } -static void hslider_delta(t_hslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} - -static void hslider_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} - static void hslider_range(t_hslider *x, t_symbol *s, int ac, t_atom *av) { hslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av), (double)atom_getfloatarg(1, ac, av)); } -static void hslider_color(t_hslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_color((void *)x, &x->x_gui, s, ac, av);} - -static void hslider_send(t_hslider *x, t_symbol *s) -{iemgui_send(x, &x->x_gui, s);} - -static void hslider_receive(t_hslider *x, t_symbol *s) -{iemgui_receive(x, &x->x_gui, s);} - -static void hslider_label(t_hslider *x, t_symbol *s) -{iemgui_label((void *)x, &x->x_gui, s);} - -static void hslider_label_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} - -static void hslider_label_font(t_hslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} - static void hslider_log(t_hslider *x) { x->x_lin0_log1 = 1; @@ -586,7 +562,7 @@ static void hslider_lin(t_hslider *x) static void hslider_init(t_hslider *x, t_floatarg f) { - x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; + x->x_gui.x_loadinit = (f==0.0)?0:1; } static void hslider_steady(t_hslider *x, t_floatarg f) @@ -612,17 +588,17 @@ static void hslider_float(t_hslider *x, t_floatarg f) out = (double)(x->x_val)*0.01*x->x_k + x->x_min; if((out < 1.0e-10)&&(out > -1.0e-10)) out = 0.0; - if(x->x_gui.x_fsf.x_put_in2out) + if(x->x_gui.x_put_in2out) { outlet_float(x->x_gui.x_obj.ob_outlet, out); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, out); } } static void hslider_loadbang(t_hslider *x) { - if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) + if(!sys_noloadbang && x->x_gui.x_loadinit) { (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); hslider_bang(x); @@ -638,8 +614,8 @@ static void *hslider_new(t_symbol *s, int argc, t_atom *argv) int fs=10; double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1); - iem_inttosymargs(&x->x_gui.x_isa, 0); - iem_inttofstyle(&x->x_gui.x_fsf, 0); + iem_inttosymargs(&x->x_gui, 0); + iem_inttofstyle(&x->x_gui, 0); if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1) &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3) @@ -656,11 +632,11 @@ static void *hslider_new(t_symbol *s, int argc, t_atom *argv) min = (double)atom_getfloatarg(2, argc, argv); max = (double)atom_getfloatarg(3, argc, argv); lilo = (int)atom_getintarg(4, argc, argv); - iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv)); + iem_inttosymargs(&x->x_gui, atom_getintarg(5, argc, argv)); iemgui_new_getnames(&x->x_gui, 6, argv); ldx = (int)atom_getintarg(9, argc, argv); ldy = (int)atom_getintarg(10, argc, argv); - iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv)); + iem_inttofstyle(&x->x_gui, atom_getintarg(11, argc, argv)); fs = (int)atom_getintarg(12, argc, argv); bflcol[0] = (int)atom_getintarg(13, argc, argv); bflcol[1] = (int)atom_getintarg(14, argc, argv); @@ -673,13 +649,11 @@ static void *hslider_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.x_draw = (t_iemfunptr)hslider_draw; - x->x_gui.x_fsf.x_snd_able = 1; - x->x_gui.x_fsf.x_rcv_able = 1; x->x_is_last_float = 0; x->x_last = 0.0; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); - if(x->x_gui.x_isa.x_loadinit) + if(x->x_gui.x_loadinit) x->x_val = v; else x->x_val = 0; @@ -688,18 +662,8 @@ static void *hslider_new(t_symbol *s, int argc, t_atom *argv) x->x_lin0_log1 = lilo; if(steady != 0) steady = 1; x->x_steady = steady; - if (!strcmp(x->x_gui.x_snd->s_name, "empty")) - x->x_gui.x_fsf.x_snd_able = 0; - if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) - x->x_gui.x_fsf.x_rcv_able = 0; - if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); - else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); - else - { - x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); - } - if(x->x_gui.x_fsf.x_rcv_able) + if (x->x_gui.x_font_style<0 || x->x_gui.x_font_style>2) x->x_gui.x_font_style=0; + if(iemgui_has_rcv(&x->x_gui)) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; @@ -724,7 +688,7 @@ static void *hslider_new(t_symbol *s, int argc, t_atom *argv) static void hslider_free(t_hslider *x) { - if(x->x_gui.x_fsf.x_rcv_able) + if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -753,24 +717,9 @@ void g_hslider_setup(void) gensym("set"), A_FLOAT, 0); class_addmethod(hslider_class, (t_method)hslider_size, gensym("size"), A_GIMME, 0); - class_addmethod(hslider_class, (t_method)hslider_delta, - gensym("delta"), A_GIMME, 0); - class_addmethod(hslider_class, (t_method)hslider_pos, - gensym("pos"), A_GIMME, 0); + iemgui_class_addmethods(hslider_class); class_addmethod(hslider_class, (t_method)hslider_range, gensym("range"), A_GIMME, 0); - class_addmethod(hslider_class, (t_method)hslider_color, - gensym("color"), A_GIMME, 0); - class_addmethod(hslider_class, (t_method)hslider_send, - gensym("send"), A_DEFSYM, 0); - class_addmethod(hslider_class, (t_method)hslider_receive, - gensym("receive"), A_DEFSYM, 0); - class_addmethod(hslider_class, (t_method)hslider_label, - gensym("label"), A_DEFSYM, 0); - class_addmethod(hslider_class, (t_method)hslider_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(hslider_class, (t_method)hslider_label_font, - gensym("label_font"), A_GIMME, 0); class_addmethod(hslider_class, (t_method)hslider_log, gensym("log"), 0); class_addmethod(hslider_class, (t_method)hslider_lin, gensym("lin"), 0); class_addmethod(hslider_class, (t_method)hslider_init, diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c index 9f769be2b..d86061251 100644 --- a/pd/src/g_mycanvas.c +++ b/pd/src/g_mycanvas.c @@ -76,7 +76,7 @@ void my_canvas_draw_move(t_my_canvas *x, t_glist *glist) xpos + x->x_gui.x_w, ypos + x->x_gui.x_h); iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { my_canvas_draw_select(x, x->x_gui.x_glist); } @@ -88,7 +88,7 @@ void my_canvas_draw_config(t_my_canvas* x, t_glist* glist) t_canvas *canvas=glist_getcanvas(glist); sys_vgui(".x%lx.c itemconfigure %lxRECT -fill #%6.6x -stroke #%6.6x\n", canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol); - if (x->x_gui.x_fsf.x_selected && x->x_gui.x_glist == canvas) + if (x->x_gui.x_selected && x->x_gui.x_glist == canvas) sys_vgui(".x%lx.c itemconfigure %lxBASE " "-stroke $pd_colors(selection)\n", canvas, x); else @@ -100,7 +100,7 @@ void my_canvas_draw_config(t_my_canvas* x, t_glist* glist) void my_canvas_draw_select(t_my_canvas* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_fsf.x_selected) + if(x->x_gui.x_selected) { // check if we are drawing inside a gop abstraction // visible on parent canvas @@ -241,8 +241,8 @@ static void my_canvas_save(t_gobj *z, t_binbuf *b) (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix, gensym("cnv"), x->x_gui.x_w, x->x_vis_w, x->x_vis_h, srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, - iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, - bflcol[0], bflcol[2], iem_symargstoint(&x->x_gui.x_isa)); + iem_fstyletoint(&x->x_gui), x->x_gui.x_fontsize, + bflcol[0], bflcol[2], iem_symargstoint(&x->x_gui)); binbuf_addv(b, ";"); } @@ -266,14 +266,14 @@ static void my_canvas_properties(t_gobj *z, t_glist *owner) -1, -1, -1, -1,/*no linlog, no init, no multi*/ srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, - x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + x->x_gui.x_font_style, x->x_gui.x_fontsize, 0xffffff & x->x_gui.x_bcol, -1/*no frontcolor*/, 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } static void my_canvas_get_pos(t_my_canvas *x) { - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) { x->x_at[0].a_w.w_float = text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist); x->x_at[1].a_w.w_float = text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist); @@ -291,7 +291,7 @@ static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv int h = (int)atom_getintarg(3, argc, argv); iemgui_dialog(&x->x_gui, srl, argc, argv); - x->x_gui.x_isa.x_loadinit = 0; + x->x_gui.x_loadinit = 0; if(a < 1) a = 1; x->x_gui.x_w = a; @@ -304,10 +304,10 @@ static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv x->x_vis_h = h; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { my_canvas_draw_select(x, x->x_gui.x_glist); } @@ -326,15 +326,9 @@ static void my_canvas_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) i = 1; x->x_gui.x_w = i; x->x_gui.x_h = i; - iemgui_size((void *)x, &x->x_gui); + iemgui_size(&x->x_gui); } -static void my_canvas_delta(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) -{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} - -static void my_canvas_pos(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) -{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} - static void my_canvas_vis_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) { int i; @@ -354,24 +348,6 @@ static void my_canvas_vis_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); } -static void my_canvas_color(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) -{iemgui_color((void *)x, &x->x_gui, s, ac, av);} - -static void my_canvas_send(t_my_canvas *x, t_symbol *s) -{iemgui_send(x, &x->x_gui, s);} - -static void my_canvas_receive(t_my_canvas *x, t_symbol *s) -{iemgui_receive(x, &x->x_gui, s);} - -static void my_canvas_label(t_my_canvas *x, t_symbol *s) -{iemgui_label((void *)x, &x->x_gui, s);} - -static void my_canvas_label_pos(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} - -static void my_canvas_label_font(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} - static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) { t_my_canvas *x = (t_my_canvas *)pd_new(my_canvas_class); @@ -380,8 +356,8 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) int ldx=20, ldy=12, i=0; int fs=14; - iem_inttosymargs(&x->x_gui.x_isa, 0); - iem_inttofstyle(&x->x_gui.x_fsf, 0); + iem_inttosymargs(&x->x_gui, 0); + iem_inttofstyle(&x->x_gui, 0); if(((argc >= 10)&&(argc <= 13)) &&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)) @@ -416,23 +392,17 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.x_labelbindex = i+4; ldx = (int)atom_getintarg(i+4, argc, argv); ldy = (int)atom_getintarg(i+5, argc, argv); - iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(i+6, argc, argv)); + iem_inttofstyle(&x->x_gui, atom_getintarg(i+6, argc, argv)); fs = (int)atom_getintarg(i+7, argc, argv); bflcol[0] = (int)atom_getintarg(i+8, argc, argv); bflcol[2] = (int)atom_getintarg(i+9, argc, argv); } if((argc == 13)&&IS_A_FLOAT(argv,i+10)) { - iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(i+10, argc, argv)); + iem_inttosymargs(&x->x_gui, atom_getintarg(i+10, argc, argv)); } x->x_gui.x_draw = (t_iemfunptr)my_canvas_draw; - x->x_gui.x_fsf.x_snd_able = 1; - x->x_gui.x_fsf.x_rcv_able = 1; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); - if (!strcmp(x->x_gui.x_snd->s_name, "empty")) - x->x_gui.x_fsf.x_snd_able = 0; - if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) - x->x_gui.x_fsf.x_rcv_able = 0; if(a < 1) a = 1; x->x_gui.x_w = a; @@ -443,16 +413,8 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) if(h < 1) h = 1; x->x_vis_h = h; - if(x->x_gui.x_fsf.x_font_style == 1) - strcpy(x->x_gui.x_font, "helvetica"); - else if(x->x_gui.x_fsf.x_font_style == 2) - strcpy(x->x_gui.x_font, "times"); - else - { - x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); - } - if (x->x_gui.x_fsf.x_rcv_able) + if (x->x_gui.x_font_style<0 || x->x_gui.x_font_style>2) x->x_gui.x_font_style=0; + if (iemgui_has_rcv(&x->x_gui)) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; @@ -473,7 +435,7 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) static void my_canvas_ff(t_my_canvas *x) { - if(x->x_gui.x_fsf.x_rcv_able) + if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -491,24 +453,9 @@ void g_mycanvas_setup(void) gensym("dialog"), A_GIMME, 0); class_addmethod(my_canvas_class, (t_method)my_canvas_size, gensym("size"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_delta, - gensym("delta"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_pos, - gensym("pos"), A_GIMME, 0); + iemgui_class_addmethods(my_canvas_class); class_addmethod(my_canvas_class, (t_method)my_canvas_vis_size, gensym("vis_size"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_color, - gensym("color"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_send, - gensym("send"), A_DEFSYM, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_receive, - gensym("receive"), A_DEFSYM, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_label, - gensym("label"), A_DEFSYM, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_label_font, - gensym("label_font"), A_GIMME, 0); class_addmethod(my_canvas_class, (t_method)my_canvas_get_pos, gensym("get_pos"), 0); diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c index 272d1b62f..53edd0be2 100644 --- a/pd/src/g_numbox.c +++ b/pd/src/g_numbox.c @@ -44,9 +44,9 @@ static t_class *my_numbox_class; static void my_numbox_tick_reset(t_my_numbox *x) { - if(x->x_gui.x_fsf.x_change && x->x_gui.x_glist) + if(x->x_gui.x_change && x->x_gui.x_glist) { - x->x_gui.x_fsf.x_change = 0; + x->x_gui.x_change = 0; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); } } @@ -67,8 +67,8 @@ void my_numbox_clip(t_my_numbox *x) int my_numbox_calc_fontwidth2(t_my_numbox *x, int w, int h, int fontsize) { int f=31; - if (x->x_gui.x_fsf.x_font_style == 1) f = 27; - else if(x->x_gui.x_fsf.x_font_style == 2) f = 25; + if (x->x_gui.x_font_style == 1) f = 27; + else if(x->x_gui.x_font_style == 2) f = 25; return (fontsize * f * w) / 36 + (h / 2) + 4; } @@ -144,7 +144,7 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist) } if (glist_isvisible(glist)) { - if(x->x_gui.x_fsf.x_change) + if(x->x_gui.x_change) { if(x->x_buf[0]) { @@ -172,7 +172,7 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist) else { char color[64]; - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) sprintf(color, "$pd_colors(selection)"); else sprintf(color, "#%6.6x", x->x_gui.x_fcol); @@ -248,7 +248,7 @@ static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist) "-font {{%s} -%d %s} -fill #%6.6x " "-tags {%lxNUMBER %lxNUM %s noscroll text iemgui}\n", canvas, xpos+half+2, ypos+half+d, - x->x_buf, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_buf, iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_fcol, x, x, nlet_tag); //} } @@ -273,12 +273,12 @@ static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist) xpos, ypos + x->x_gui.x_h); if (x->x_hide_frame <= 1) { - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxNUM%so%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xpos, ypos + x->x_gui.x_h-1, xpos+IOWIDTH, ypos + x->x_gui.x_h); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxNUM%si%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xpos, ypos, @@ -293,7 +293,7 @@ static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist) sys_vgui(".x%lx.c coords %lxNUMBER %d %d\n", canvas, x, xpos+half+2, ypos+half+d); /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) my_numbox_draw_select(x, x->x_gui.x_glist); } } @@ -301,19 +301,19 @@ static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist) static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - if (x->x_gui.x_fsf.x_selected && x->x_gui.x_glist == canvas) + if (x->x_gui.x_selected && x->x_gui.x_glist == canvas) { sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} -%d %s} " "-fill $pd_colors(selection)\n" ".x%lx.c itemconfigure %lxBASE2 " "-stroke $pd_colors(selection)\n", - canvas, x, x->x_gui.x_font, + canvas, x, iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, canvas,x); /* sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} %d %s} " "-fill $pd_colors(selection)\n", - canvas, x, x->x_gui.x_font, + canvas, x, iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight); sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill $pd_colors(selection)\n", canvas, x); @@ -324,13 +324,13 @@ static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist) sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} -%d %s} " "-fill #%6.6x \n .x%lx.c itemconfigure %lxBASE2 " "-stroke #%6.6x\n", - canvas, x, x->x_gui.x_font, + canvas, iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_fcol, canvas, x, x->x_gui.x_fcol); /*sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} %d %s} " "-fill #%6.6x \n", - canvas, x, x->x_gui.x_font, + canvas, x, iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_fcol); sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill #%6.6x\n", @@ -346,11 +346,11 @@ static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist) static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_fsf.x_selected) + if(x->x_gui.x_selected) { - if(x->x_gui.x_fsf.x_change) + if(x->x_gui.x_change) { - x->x_gui.x_fsf.x_change = 0; + x->x_gui.x_change = 0; clock_unset(x->x_clock_reset); x->x_buf[0] = 0; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); @@ -445,8 +445,8 @@ static void my_numbox__motionhook(t_scalehandle *sh, IEM_FONT_MINSIZE); int f = 31; - if (x->x_gui.x_fsf.x_font_style == 1) f = 27; - else if(x->x_gui.x_fsf.x_font_style == 2) f = 25; + if (x->x_gui.x_font_style == 1) f = 27; + else if(x->x_gui.x_font_style == 2) f = 25; int char_w = (x->x_tmpfontsize * f) / 36; /* get the new total width */ @@ -525,9 +525,9 @@ static void my_numbox_save(t_gobj *z, t_binbuf *b) t_symbol *srl[3]; iemgui_save(&x->x_gui, srl, bflcol); - if(x->x_gui.x_fsf.x_change) + if(x->x_gui.x_change) { - x->x_gui.x_fsf.x_change = 0; + x->x_gui.x_change = 0; clock_unset(x->x_clock_reset); x->x_gui.x_changed = 1; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); @@ -536,10 +536,10 @@ static void my_numbox_save(t_gobj *z, t_binbuf *b) (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix, gensym("nbx"), x->x_gui.x_w, x->x_gui.x_h, (t_float)x->x_min, (t_float)x->x_max, - x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa), + x->x_lin0_log1, iem_symargstoint(&x->x_gui), srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, - iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + iem_fstyletoint(&x->x_gui), x->x_gui.x_fontsize, bflcol[0], bflcol[1], bflcol[2], x->x_val, x->x_log_height, x->x_hide_frame); binbuf_addv(b, ";"); @@ -590,9 +590,9 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner) t_symbol *srl[3]; iemgui_properties(&x->x_gui, srl); - if(x->x_gui.x_fsf.x_change) + if(x->x_gui.x_change) { - x->x_gui.x_fsf.x_change = 0; + x->x_gui.x_change = 0; clock_unset(x->x_clock_reset); x->x_gui.x_changed = 1; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); @@ -609,11 +609,11 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner) x->x_gui.x_w, 1, x->x_gui.x_h, 8, x->x_min, x->x_max, x->x_hide_frame, /*EXCEPTION: x_hide_frame instead of schedule*/ - x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, -1, + x->x_lin0_log1, x->x_gui.x_loadinit, -1, x->x_log_height, /*no multi, but iem-characteristic*/ srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, - x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + x->x_gui.x_font_style, x->x_gui.x_fontsize, 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); @@ -622,7 +622,7 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner) static void my_numbox_bang(t_my_numbox *x) { outlet_float(x->x_gui.x_obj.ob_outlet, x->x_val); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_val); } @@ -662,19 +662,19 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc, //if (need_to_redraw) { (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_NEW); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_NEW); /*} else { (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); }*/ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { my_numbox_draw_select(x, x->x_gui.x_glist); } @@ -693,7 +693,7 @@ static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy) double k2=1.0; int old = x->x_val; - if(x->x_gui.x_fsf.x_finemoved) + if(x->x_gui.x_finemoved) k2 = 0.01; if(x->x_lin0_log1) x->x_val *= pow(x->x_k, -k2*dy); @@ -726,20 +726,20 @@ static int my_numbox_newclick(t_gobj *z, struct _glist *glist, my_numbox_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); if(shift) - x->x_gui.x_fsf.x_finemoved = 1; + x->x_gui.x_finemoved = 1; else - x->x_gui.x_fsf.x_finemoved = 0; - if(!x->x_gui.x_fsf.x_change) + x->x_gui.x_finemoved = 0; + if(!x->x_gui.x_change) { clock_delay(x->x_clock_wait, 50); - x->x_gui.x_fsf.x_change = 1; + x->x_gui.x_change = 1; clock_delay(x->x_clock_reset, 3000); x->x_buf[0] = 0; } else { - x->x_gui.x_fsf.x_change = 0; + x->x_gui.x_change = 0; clock_unset(x->x_clock_reset); x->x_buf[0] = 0; x->x_gui.x_changed = 1; @@ -786,7 +786,7 @@ static void my_numbox_hide_frame(t_my_numbox *x, t_floatarg lh) static void my_numbox_float(t_my_numbox *x, t_floatarg f) { my_numbox_set(x, f); - if(x->x_gui.x_fsf.x_put_in2out) + if(x->x_gui.x_put_in2out) my_numbox_bang(x); } @@ -806,15 +806,9 @@ static void my_numbox_size(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) x->x_gui.x_h = h; } x->x_numwidth = my_numbox_calc_fontwidth(x); - iemgui_size((void *)x, &x->x_gui); + iemgui_size(&x->x_gui); } -static void my_numbox_delta(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) -{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} - -static void my_numbox_pos(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) -{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} - static void my_numbox_range(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) { if(my_numbox_check_minmax(x, (double)atom_getfloatarg(0, ac, av), @@ -826,21 +820,6 @@ static void my_numbox_range(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) } } -static void my_numbox_color(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) -{iemgui_color((void *)x, &x->x_gui, s, ac, av);} - -static void my_numbox_send(t_my_numbox *x, t_symbol *s) -{iemgui_send(x, &x->x_gui, s);} - -static void my_numbox_receive(t_my_numbox *x, t_symbol *s) -{iemgui_receive(x, &x->x_gui, s);} - -static void my_numbox_label(t_my_numbox *x, t_symbol *s) -{iemgui_label((void *)x, &x->x_gui, s);} - -static void my_numbox_label_pos(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} - static void my_numbox_label_font(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) { @@ -852,9 +831,9 @@ static void my_numbox_label_font(t_my_numbox *x, f = (int)atom_getintarg(0, ac, av); if((f < 0) || (f > 2)) f = 0; - x->x_gui.x_fsf.x_font_style = f; + x->x_gui.x_font_style = f; x->x_numwidth = my_numbox_calc_fontwidth(x); - iemgui_label_font((void *)x, &x->x_gui, s, ac, av); + iemgui_label_font(&x->x_gui, s, ac, av); } static void my_numbox_log(t_my_numbox *x) @@ -875,12 +854,12 @@ static void my_numbox_lin(t_my_numbox *x) static void my_numbox_init(t_my_numbox *x, t_floatarg f) { - x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; + x->x_gui.x_loadinit = (f==0.0)?0:1; } static void my_numbox_loadbang(t_my_numbox *x) { - if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) + if(!sys_noloadbang && x->x_gui.x_loadinit) { sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); my_numbox_bang(x); @@ -896,7 +875,7 @@ static void my_numbox_key(void *z, t_floatarg fkey) if (c == 0) { - x->x_gui.x_fsf.x_change = 0; + x->x_gui.x_change = 0; clock_unset(x->x_clock_reset); x->x_gui.x_changed = 1; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); @@ -927,7 +906,7 @@ static void my_numbox_key(void *z, t_floatarg fkey) { x->x_val = atof(x->x_buf); x->x_buf[0] = 0; - x->x_gui.x_fsf.x_change = 0; + x->x_gui.x_change = 0; clock_unset(x->x_clock_reset); my_numbox_clip(x); my_numbox_bang(x); @@ -971,11 +950,11 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) min = (double)atom_getfloatarg(2, argc, argv); max = (double)atom_getfloatarg(3, argc, argv); lilo = (int)atom_getintarg(4, argc, argv); - iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv)); + iem_inttosymargs(&x->x_gui, atom_getintarg(5, argc, argv)); iemgui_new_getnames(&x->x_gui, 6, argv); ldx = (int)atom_getintarg(9, argc, argv); ldy = (int)atom_getintarg(10, argc, argv); - iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv)); + iem_inttofstyle(&x->x_gui, atom_getintarg(11, argc, argv)); fs = (int)atom_getintarg(12, argc, argv); bflcol[0] = (int)atom_getintarg(13, argc, argv); bflcol[1] = (int)atom_getintarg(14, argc, argv); @@ -994,10 +973,8 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) x->x_hide_frame = (int)atom_getintarg(18, argc, argv); } x->x_gui.x_draw = (t_iemfunptr)my_numbox_draw; - x->x_gui.x_fsf.x_snd_able = 1; - x->x_gui.x_fsf.x_rcv_able = 1; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); - if(x->x_gui.x_isa.x_loadinit) + if(x->x_gui.x_loadinit) x->x_val = v; else x->x_val = 0.0; @@ -1006,20 +983,8 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) if(log_height < 10) log_height = 10; x->x_log_height = log_height; - if (!strcmp(x->x_gui.x_snd->s_name, "empty")) - x->x_gui.x_fsf.x_snd_able = 0; - if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) - x->x_gui.x_fsf.x_rcv_able = 0; - if (x->x_gui.x_fsf.x_font_style == 1) - strcpy(x->x_gui.x_font, "helvetica"); - else if(x->x_gui.x_fsf.x_font_style == 2) - strcpy(x->x_gui.x_font, "times"); - else - { - x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); - } - if (x->x_gui.x_fsf.x_rcv_able) + if (x->x_gui.x_font_style<0 || x->x_gui.x_font_style>2) x->x_gui.x_font_style=0; + if (iemgui_has_rcv(&x->x_gui)) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; @@ -1039,7 +1004,7 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) iemgui_verify_snd_ne_rcv(&x->x_gui); x->x_clock_reset = clock_new(x, (t_method)my_numbox_tick_reset); x->x_clock_wait = clock_new(x, (t_method)my_numbox_tick_wait); - x->x_gui.x_fsf.x_change = 0; + x->x_gui.x_change = 0; outlet_new(&x->x_gui.x_obj, &s_float); x->x_gui. x_handle = scalehandle_new(scalehandle_class,(t_iemgui *)x,1); @@ -1055,7 +1020,7 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) static void my_numbox_free(t_my_numbox *x) { - if(x->x_gui.x_fsf.x_rcv_able) + if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); clock_free(x->x_clock_reset); clock_free(x->x_clock_wait); @@ -1086,24 +1051,9 @@ void g_numbox_setup(void) gensym("set"), A_FLOAT, 0); class_addmethod(my_numbox_class, (t_method)my_numbox_size, gensym("size"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_delta, - gensym("delta"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_pos, - gensym("pos"), A_GIMME, 0); + iemgui_class_addmethods(my_numbox_class); class_addmethod(my_numbox_class, (t_method)my_numbox_range, gensym("range"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_color, - gensym("color"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_send, - gensym("send"), A_DEFSYM, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_receive, - gensym("receive"), A_DEFSYM, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_label, - gensym("label"), A_DEFSYM, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_label_font, - gensym("label_font"), A_GIMME, 0); class_addmethod(my_numbox_class, (t_method)my_numbox_log, gensym("log"), 0); class_addmethod(my_numbox_class, (t_method)my_numbox_lin, diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c index 03a00c193..5e9683f99 100644 --- a/pd/src/g_toggle.c +++ b/pd/src/g_toggle.c @@ -124,15 +124,15 @@ void toggle_draw_move(t_toggle *x, t_glist *glist) canvas, x, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w-1, yy+w+1); iemgui_label_draw_move(&x->x_gui,canvas,xx,yy); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxTGL%so%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxTGL%si%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xx, yy, xx + IOWIDTH, yy+1); /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) toggle_draw_select(x, x->x_gui.x_glist); } } @@ -158,7 +158,7 @@ void toggle_draw_config(t_toggle* x, t_glist* glist) void toggle_draw_select(t_toggle* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_fsf.x_selected) + if(x->x_gui.x_selected) { // check if we are drawing inside a gop abstraction // visible on parent canvas @@ -286,10 +286,10 @@ static void toggle_save(t_gobj *z, t_binbuf *b) (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix, gensym("tgl"), x->x_gui.x_w, - iem_symargstoint(&x->x_gui.x_isa), + iem_symargstoint(&x->x_gui), srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, - iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + iem_fstyletoint(&x->x_gui), x->x_gui.x_fontsize, bflcol[0], bflcol[1], bflcol[2], x->x_on, x->x_nonzero); binbuf_addv(b, ";"); } @@ -311,10 +311,10 @@ static void toggle_properties(t_gobj *z, t_glist *owner) %d %d %d\n", x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_nonzero, 1.0,/*non_zero-schedule*/ - x->x_gui.x_isa.x_loadinit, -1, -1,/*no multi*/ + x->x_gui.x_loadinit, -1, -1,/*no multi*/ srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, - x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + x->x_gui.x_font_style, x->x_gui.x_fontsize, 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } @@ -325,7 +325,7 @@ static void toggle_bang(t_toggle *x) x->x_on = (x->x_on==0.0)?x->x_nonzero:0.0; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); } @@ -350,10 +350,10 @@ static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { toggle_draw_select(x, x->x_gui.x_glist); } @@ -389,10 +389,10 @@ static void toggle_set(t_toggle *x, t_floatarg f) static void toggle_float(t_toggle *x, t_floatarg f) { toggle_set(x, f); - if(x->x_gui.x_fsf.x_put_in2out) + if(x->x_gui.x_put_in2out) { outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); } } @@ -401,13 +401,13 @@ static void toggle_fout(t_toggle *x, t_floatarg f) { toggle_set(x, f); outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); } static void toggle_loadbang(t_toggle *x) { - if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) + if(!sys_noloadbang && x->x_gui.x_loadinit) toggle_fout(x, (t_float)x->x_on); } @@ -415,36 +415,12 @@ static void toggle_size(t_toggle *x, t_symbol *s, int ac, t_atom *av) { x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_h = x->x_gui.x_w; - iemgui_size((void *)x, &x->x_gui); + iemgui_size(&x->x_gui); } -static void toggle_delta(t_toggle *x, t_symbol *s, int ac, t_atom *av) -{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} - -static void toggle_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av) -{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} - -static void toggle_color(t_toggle *x, t_symbol *s, int ac, t_atom *av) -{iemgui_color((void *)x, &x->x_gui, s, ac, av);} - -static void toggle_send(t_toggle *x, t_symbol *s) -{iemgui_send(x, &x->x_gui, s);} - -static void toggle_receive(t_toggle *x, t_symbol *s) -{iemgui_receive(x, &x->x_gui, s);} - -static void toggle_label(t_toggle *x, t_symbol *s) -{iemgui_label((void *)x, &x->x_gui, s);} - -static void toggle_label_font(t_toggle *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} - -static void toggle_label_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} - static void toggle_init(t_toggle *x, t_floatarg f) { - x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; + x->x_gui.x_loadinit = (f==0.0)?0:1; } static void toggle_nonzero(t_toggle *x, t_floatarg f) @@ -462,8 +438,8 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv) int fs=10; t_float on=0.0, nonzero=1.0; - iem_inttosymargs(&x->x_gui.x_isa, 0); - iem_inttofstyle(&x->x_gui.x_fsf, 0); + iem_inttosymargs(&x->x_gui, 0); + iem_inttofstyle(&x->x_gui, 0); if(((argc == 13)||(argc == 14))&&IS_A_FLOAT(argv,0) &&IS_A_FLOAT(argv,1) @@ -475,11 +451,11 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv) &&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)) { a = (int)atom_getintarg(0, argc, argv); - iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(1, argc, argv)); + iem_inttosymargs(&x->x_gui, atom_getintarg(1, argc, argv)); iemgui_new_getnames(&x->x_gui, 2, argv); ldx = (int)atom_getintarg(5, argc, argv); ldy = (int)atom_getintarg(6, argc, argv); - iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(7, argc, argv)); + iem_inttofstyle(&x->x_gui, atom_getintarg(7, argc, argv)); fs = (int)atom_getintarg(8, argc, argv); bflcol[0] = (int)atom_getintarg(9, argc, argv); bflcol[1] = (int)atom_getintarg(10, argc, argv); @@ -491,28 +467,14 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv) nonzero = (t_float)atom_getfloatarg(13, argc, argv); x->x_gui.x_draw = (t_iemfunptr)toggle_draw; - x->x_gui.x_fsf.x_snd_able = 1; - x->x_gui.x_fsf.x_rcv_able = 1; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); - if (!strcmp(x->x_gui.x_snd->s_name, "empty")) - x->x_gui.x_fsf.x_snd_able = 0; - if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) - x->x_gui.x_fsf.x_rcv_able = 0; - if(x->x_gui.x_fsf.x_font_style == 1) - strcpy(x->x_gui.x_font, "helvetica"); - else - if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); - else - { - x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); - } + if (x->x_gui.x_font_style<0 || x->x_gui.x_font_style>2) x->x_gui.x_font_style=0; x->x_nonzero = (nonzero!=0.0)?nonzero:1.0; - if(x->x_gui.x_isa.x_loadinit) + if(x->x_gui.x_loadinit) x->x_on = (on!=0.0)?nonzero:0.0; else x->x_on = 0.0; - if (x->x_gui.x_fsf.x_rcv_able) + if (iemgui_has_rcv(&x->x_gui)) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; @@ -536,7 +498,7 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv) static void toggle_ff(t_toggle *x) { - if(x->x_gui.x_fsf.x_rcv_able) + if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -561,22 +523,7 @@ void g_toggle_setup(void) A_FLOAT, 0); class_addmethod(toggle_class, (t_method)toggle_size, gensym("size"), A_GIMME, 0); - class_addmethod(toggle_class, (t_method)toggle_delta, gensym("delta"), - A_GIMME, 0); - class_addmethod(toggle_class, (t_method)toggle_pos, gensym("pos"), - A_GIMME, 0); - class_addmethod(toggle_class, (t_method)toggle_color, gensym("color"), - A_GIMME, 0); - class_addmethod(toggle_class, (t_method)toggle_send, gensym("send"), - A_DEFSYM, 0); - class_addmethod(toggle_class, (t_method)toggle_receive, gensym("receive"), - A_DEFSYM, 0); - class_addmethod(toggle_class, (t_method)toggle_label, gensym("label"), - A_DEFSYM, 0); - class_addmethod(toggle_class, (t_method)toggle_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(toggle_class, (t_method)toggle_label_font, - gensym("label_font"), A_GIMME, 0); + iemgui_class_addmethods(toggle_class); class_addmethod(toggle_class, (t_method)toggle_init, gensym("init"), A_FLOAT, 0); class_addmethod(toggle_class, (t_method)toggle_nonzero, gensym("nonzero"), diff --git a/pd/src/g_vdial.c b/pd/src/g_vdial.c index ceb72f226..e79a51c7c 100644 --- a/pd/src/g_vdial.c +++ b/pd/src/g_vdial.c @@ -123,14 +123,14 @@ void vradio_draw_move(t_vradio *x, t_glist *glist) yy22 += dy; } iemgui_label_draw_move(&x->x_gui,canvas,xx11,yy11b); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxVRDO%so%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xx11, yy11-1, xx11 + IOWIDTH, yy11); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxVRDO%si%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1); /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) vradio_draw_select(x, x->x_gui.x_glist); } } @@ -162,7 +162,7 @@ void vradio_draw_config(t_vradio* x, t_glist* glist) void vradio_draw_select(t_vradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_fsf.x_selected) + if(x->x_gui.x_selected) { /* check if we are drawing inside a gop abstraction visible on parent canvas. If so, disable highlighting */ @@ -290,10 +290,10 @@ static void vradio_save(t_gobj *z, t_binbuf *b) (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class ? gensym("vdl") : gensym("vradio")), x->x_gui.x_w, - x->x_change, iem_symargstoint(&x->x_gui.x_isa), x->x_number, + x->x_change, iem_symargstoint(&x->x_gui), x->x_number, srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, - iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + iem_fstyletoint(&x->x_gui), x->x_gui.x_fontsize, bflcol[0], bflcol[1], bflcol[2], x->x_on); binbuf_addv(b, ";"); } @@ -318,10 +318,10 @@ static void vradio_properties(t_gobj *z, t_glist *owner) %d %d %d\n", x->x_gui.x_w, IEM_GUI_MINSIZE, 0,/*no_schedule*/ - hchange, x->x_gui.x_isa.x_loadinit, -1, x->x_number, + hchange, x->x_gui.x_loadinit, -1, x->x_number, srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, - x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + x->x_gui.x_font_style, x->x_gui.x_fontsize, 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); @@ -352,7 +352,7 @@ static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv) x->x_on_old = x->x_on; } //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_NEW); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_NEW); } else { @@ -360,11 +360,11 @@ static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); } /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { vradio_draw_select(x, x->x_gui.x_glist); } @@ -411,20 +411,20 @@ static void vradio_bang(t_vradio *x) SETFLOAT(x->x_at, (t_float)x->x_on_old); SETFLOAT(x->x_at+1, 0.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } x->x_on_old = x->x_on; SETFLOAT(x->x_at, (t_float)x->x_on); SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } else { outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); } } @@ -446,7 +446,7 @@ static void vradio_fout(t_vradio *x, t_floatarg f) SETFLOAT(x->x_at, (t_float)x->x_on_old); SETFLOAT(x->x_at+1, 0.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } if(x->x_on != x->x_on_old) @@ -457,7 +457,7 @@ static void vradio_fout(t_vradio *x, t_floatarg f) SETFLOAT(x->x_at, (t_float)x->x_on); SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } else @@ -467,7 +467,7 @@ static void vradio_fout(t_vradio *x, t_floatarg f) if (x->x_on != x->x_on_old) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); - if (x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if (iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); } } @@ -486,12 +486,12 @@ static void vradio_float(t_vradio *x, t_floatarg f) /* compatibility with earlier "vdial" behavior */ if((x->x_change)&&(i != x->x_on_old)) { - if(x->x_gui.x_fsf.x_put_in2out) + if(x->x_gui.x_put_in2out) { SETFLOAT(x->x_at, (t_float)x->x_on_old); SETFLOAT(x->x_at+1, 0.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } } @@ -500,12 +500,12 @@ static void vradio_float(t_vradio *x, t_floatarg f) x->x_on = i; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); x->x_on_old = x->x_on; - if(x->x_gui.x_fsf.x_put_in2out) + if(x->x_gui.x_put_in2out) { SETFLOAT(x->x_at, (t_float)x->x_on); SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } } @@ -515,10 +515,10 @@ static void vradio_float(t_vradio *x, t_floatarg f) x->x_on = i; if (x->x_on != x->x_on_old) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - if (x->x_gui.x_fsf.x_put_in2out) + if (x->x_gui.x_put_in2out) { outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); } } @@ -543,7 +543,7 @@ static int vradio_newclick(t_gobj *z, struct _glist *glist, static void vradio_loadbang(t_vradio *x) { - if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) + if(!sys_noloadbang && x->x_gui.x_loadinit) vradio_bang(x); } @@ -570,36 +570,12 @@ static void vradio_size(t_vradio *x, t_symbol *s, int ac, t_atom *av) { x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_h = x->x_gui.x_w; - iemgui_size((void *)x, &x->x_gui); + iemgui_size(&x->x_gui); } -static void vradio_delta(t_vradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} - -static void vradio_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} - -static void vradio_color(t_vradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_color((void *)x, &x->x_gui, s, ac, av);} - -static void vradio_send(t_vradio *x, t_symbol *s) -{iemgui_send(x, &x->x_gui, s);} - -static void vradio_receive(t_vradio *x, t_symbol *s) -{iemgui_receive(x, &x->x_gui, s);} - -static void vradio_label(t_vradio *x, t_symbol *s) -{iemgui_label((void *)x, &x->x_gui, s);} - -static void vradio_label_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} - -static void vradio_label_font(t_vradio *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} - static void vradio_init(t_vradio *x, t_floatarg f) { - x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; + x->x_gui.x_loadinit = (f==0.0)?0:1; } static void vradio_double_change(t_vradio *x) @@ -627,12 +603,12 @@ static void *vradio_donew(t_symbol *s, int argc, t_atom *argv, int old) { a = (int)atom_getintarg(0, argc, argv); chg = (int)atom_getintarg(1, argc, argv); - iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv)); + iem_inttosymargs(&x->x_gui, atom_getintarg(2, argc, argv)); num = (int)atom_getintarg(3, argc, argv); iemgui_new_getnames(&x->x_gui, 4, argv); ldx = (int)atom_getintarg(7, argc, argv); ldy = (int)atom_getintarg(8, argc, argv); - iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv)); + iem_inttofstyle(&x->x_gui, atom_getintarg(9, argc, argv)); fs = (int)atom_getintarg(10, argc, argv); bflcol[0] = (int)atom_getintarg(11, argc, argv); bflcol[1] = (int)atom_getintarg(12, argc, argv); @@ -641,17 +617,8 @@ static void *vradio_donew(t_symbol *s, int argc, t_atom *argv, int old) } else iemgui_new_getnames(&x->x_gui, 4, 0); x->x_gui.x_draw = (t_iemfunptr)vradio_draw; - x->x_gui.x_fsf.x_snd_able = 1; - x->x_gui.x_fsf.x_rcv_able = 1; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); - if (!strcmp(x->x_gui.x_snd->s_name, "empty")) - x->x_gui.x_fsf.x_snd_able = 0; - if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) - x->x_gui.x_fsf.x_rcv_able = 0; - if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); - else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); - else { x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); } + if (x->x_gui.x_font_style<0 || x->x_gui.x_font_style>2) x->x_gui.x_font_style=0; if(num < 1) num = 1; if(num > IEM_RADIO_MAX) @@ -661,13 +628,13 @@ static void *vradio_donew(t_symbol *s, int argc, t_atom *argv, int old) on = 0; if(on >= x->x_number) on = x->x_number - 1; - if(x->x_gui.x_isa.x_loadinit) + if(x->x_gui.x_loadinit) x->x_on = on; else x->x_on = 0; x->x_on_old = x->x_on; x->x_change = (chg==0)?0:1; - if (x->x_gui.x_fsf.x_rcv_able) + if (iemgui_has_rcv(&x->x_gui)) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; @@ -699,7 +666,7 @@ static void *vdial_new(t_symbol *s, int argc, t_atom *argv) static void vradio_ff(t_vradio *x) { - if(x->x_gui.x_fsf.x_rcv_able) + if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -723,22 +690,7 @@ void g_vradio_setup(void) gensym("set"), A_FLOAT, 0); class_addmethod(vradio_class, (t_method)vradio_size, gensym("size"), A_GIMME, 0); - class_addmethod(vradio_class, (t_method)vradio_delta, - gensym("delta"), A_GIMME, 0); - class_addmethod(vradio_class, (t_method)vradio_pos, - gensym("pos"), A_GIMME, 0); - class_addmethod(vradio_class, (t_method)vradio_color, - gensym("color"), A_GIMME, 0); - class_addmethod(vradio_class, (t_method)vradio_send, - gensym("send"), A_DEFSYM, 0); - class_addmethod(vradio_class, (t_method)vradio_receive, - gensym("receive"), A_DEFSYM, 0); - class_addmethod(vradio_class, (t_method)vradio_label, - gensym("label"), A_DEFSYM, 0); - class_addmethod(vradio_class, (t_method)vradio_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(vradio_class, (t_method)vradio_label_font, - gensym("label_font"), A_GIMME, 0); + iemgui_class_addmethods(vradio_class); class_addmethod(vradio_class, (t_method)vradio_init, gensym("init"), A_FLOAT, 0); class_addmethod(vradio_class, (t_method)vradio_number, @@ -776,22 +728,7 @@ void g_vradio_setup(void) gensym("set"), A_FLOAT, 0); class_addmethod(vradio_old_class, (t_method)vradio_size, gensym("size"), A_GIMME, 0); - class_addmethod(vradio_old_class, (t_method)vradio_delta, - gensym("delta"), A_GIMME, 0); - class_addmethod(vradio_old_class, (t_method)vradio_pos, - gensym("pos"), A_GIMME, 0); - class_addmethod(vradio_old_class, (t_method)vradio_color, - gensym("color"), A_GIMME, 0); - class_addmethod(vradio_old_class, (t_method)vradio_send, - gensym("send"), A_DEFSYM, 0); - class_addmethod(vradio_old_class, (t_method)vradio_receive, - gensym("receive"), A_DEFSYM, 0); - class_addmethod(vradio_old_class, (t_method)vradio_label, - gensym("label"), A_DEFSYM, 0); - class_addmethod(vradio_old_class, (t_method)vradio_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(vradio_old_class, (t_method)vradio_label_font, - gensym("label_font"), A_GIMME, 0); + iemgui_class_addmethods(vradio_old_class); class_addmethod(vradio_old_class, (t_method)vradio_init, gensym("init"), A_FLOAT, 0); class_addmethod(vradio_old_class, (t_method)vradio_number, diff --git a/pd/src/g_vslider.c b/pd/src/g_vslider.c index 9d924a06c..ae35292a0 100644 --- a/pd/src/g_vslider.c +++ b/pd/src/g_vslider.c @@ -124,18 +124,18 @@ static void vslider_draw_move(t_vslider *x, t_glist *glist) canvas, x, xpos+2, r, xpos + x->x_gui.x_w-2, r); iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxVSLDR%so%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xpos, ypos + x->x_gui.x_h+4, xpos+7, ypos + x->x_gui.x_h+5); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) sys_vgui(".x%lx.c coords %lxVSLDR%si%d %d %d %d %d\n", canvas, x, nlet_tag, 0, xpos, ypos, xpos+7, ypos+1); /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { vslider_draw_select(x, x->x_gui.x_glist); } @@ -156,7 +156,7 @@ static void vslider_draw_config(t_vslider* x,t_glist* glist) static void vslider_draw_select(t_vslider *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_fsf.x_selected) + if(x->x_gui.x_selected) { // check if we are drawing inside a gop abstraction // visible on parent canvas. If so, disable highlighting @@ -291,10 +291,10 @@ static void vslider_save(t_gobj *z, t_binbuf *b) (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix, gensym("vsl"), x->x_gui.x_w, x->x_gui.x_h, (t_float)x->x_min, (t_float)x->x_max, - x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa), + x->x_lin0_log1, iem_symargstoint(&x->x_gui), srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, - iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + iem_fstyletoint(&x->x_gui), x->x_gui.x_fontsize, bflcol[0], bflcol[1], bflcol[2], x->x_val, x->x_steady); binbuf_addv(b, ";"); @@ -337,9 +337,9 @@ void vslider_check_minmax(t_vslider *x, double min, double max) x->x_min = min; x->x_max = max; if(x->x_min > x->x_max) /* bugfix */ - x->x_gui.x_isa.x_reverse = 1; + x->x_gui.x_reverse = 1; else - x->x_gui.x_isa.x_reverse = 0; + x->x_gui.x_reverse = 0; if(x->x_lin0_log1) x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_h - 1); else @@ -364,10 +364,10 @@ static void vslider_properties(t_gobj *z, t_glist *owner) %d %d %d\n", x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_SL_MINSIZE, x->x_min, x->x_max, 0,/*no_schedule*/ - x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/ + x->x_lin0_log1, x->x_gui.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/ srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, - x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + x->x_gui.x_font_style, x->x_gui.x_fontsize, 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); @@ -389,7 +389,7 @@ static void vslider_bang(t_vslider *x) out = 0.0; outlet_float(x->x_gui.x_obj.ob_outlet, out); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + if(iemgui_has_snd(&x->x_gui) && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, out); } @@ -425,10 +425,10 @@ static void vslider_dialog(t_vslider *x, t_symbol *s, int argc, t_atom *argv) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { vslider_draw_select(x, x->x_gui.x_glist); } @@ -444,7 +444,7 @@ static void vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy) x->x_is_last_float = 0; int old = x->x_val; - if(x->x_gui.x_fsf.x_finemoved) + if(x->x_gui.x_finemoved) x->x_pos -= (int)dy; else x->x_pos -= 100*(int)dy; @@ -500,9 +500,9 @@ static int vslider_newclick(t_gobj *z, struct _glist *glist, vslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); if(shift) - x->x_gui.x_fsf.x_finemoved = 1; + x->x_gui.x_finemoved = 1; else - x->x_gui.x_fsf.x_finemoved = 0; + x->x_gui.x_finemoved = 0; } return (1); } @@ -511,7 +511,7 @@ static void vslider_set(t_vslider *x, t_floatarg f) { double g; - if(x->x_gui.x_isa.x_reverse) /* bugfix */ + if(x->x_gui.x_reverse) /* bugfix */ { if(f > x->x_min) f = x->x_min; @@ -543,7 +543,7 @@ static void vslider_float(t_vslider *x, t_floatarg f) x->x_is_last_float = 1; x->x_last = f; vslider_set(x, f); - if(x->x_gui.x_fsf.x_put_in2out) + if(x->x_gui.x_put_in2out) vslider_bang(x); } @@ -552,39 +552,15 @@ static void vslider_size(t_vslider *x, t_symbol *s, int ac, t_atom *av) x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); if(ac > 1) vslider_check_height(x, (int)atom_getintarg(1, ac, av)); - iemgui_size((void *)x, &x->x_gui); + iemgui_size(&x->x_gui); } -static void vslider_delta(t_vslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} - -static void vslider_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} - static void vslider_range(t_vslider *x, t_symbol *s, int ac, t_atom *av) { vslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av), (double)atom_getfloatarg(1, ac, av)); } -static void vslider_color(t_vslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_color((void *)x, &x->x_gui, s, ac, av);} - -static void vslider_send(t_vslider *x, t_symbol *s) -{iemgui_send(x, &x->x_gui, s);} - -static void vslider_receive(t_vslider *x, t_symbol *s) -{iemgui_receive(x, &x->x_gui, s);} - -static void vslider_label(t_vslider *x, t_symbol *s) -{iemgui_label((void *)x, &x->x_gui, s);} - -static void vslider_label_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} - -static void vslider_label_font(t_vslider *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} - static void vslider_log(t_vslider *x) { x->x_lin0_log1 = 1; @@ -599,7 +575,7 @@ static void vslider_lin(t_vslider *x) static void vslider_init(t_vslider *x, t_floatarg f) { - x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; + x->x_gui.x_loadinit = (f==0.0)?0:1; } static void vslider_steady(t_vslider *x, t_floatarg f) @@ -609,7 +585,7 @@ static void vslider_steady(t_vslider *x, t_floatarg f) static void vslider_loadbang(t_vslider *x) { - if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) + if(!sys_noloadbang && x->x_gui.x_loadinit) { (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); vslider_bang(x); @@ -625,8 +601,8 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) int fs=10, v=0, steady=1; double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1); - iem_inttosymargs(&x->x_gui.x_isa, 0); - iem_inttofstyle(&x->x_gui.x_fsf, 0); + iem_inttosymargs(&x->x_gui, 0); + iem_inttofstyle(&x->x_gui, 0); if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1) &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3) @@ -643,11 +619,11 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) min = (double)atom_getfloatarg(2, argc, argv); max = (double)atom_getfloatarg(3, argc, argv); lilo = (int)atom_getintarg(4, argc, argv); - iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv)); + iem_inttosymargs(&x->x_gui, atom_getintarg(5, argc, argv)); iemgui_new_getnames(&x->x_gui, 6, argv); ldx = (int)atom_getintarg(9, argc, argv); ldy = (int)atom_getintarg(10, argc, argv); - iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv)); + iem_inttofstyle(&x->x_gui, atom_getintarg(11, argc, argv)); fs = (int)atom_getintarg(12, argc, argv); bflcol[0] = (int)atom_getintarg(13, argc, argv); bflcol[1] = (int)atom_getintarg(14, argc, argv); @@ -658,12 +634,10 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) if((argc == 18)&&IS_A_FLOAT(argv,17)) steady = (int)atom_getintarg(17, argc, argv); x->x_gui.x_draw = (t_iemfunptr)vslider_draw; - x->x_gui.x_fsf.x_snd_able = 1; - x->x_gui.x_fsf.x_rcv_able = 1; x->x_is_last_float = 0; x->x_last = 0.0; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); - if(x->x_gui.x_isa.x_loadinit) + if(x->x_gui.x_loadinit) x->x_val = v; else x->x_val = 0; @@ -672,16 +646,8 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) x->x_lin0_log1 = lilo; if(steady != 0) steady = 1; x->x_steady = steady; - if(!strcmp(x->x_gui.x_snd->s_name, "empty")) x->x_gui.x_fsf.x_snd_able = 0; - if(!strcmp(x->x_gui.x_rcv->s_name, "empty")) x->x_gui.x_fsf.x_rcv_able = 0; - if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); - else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); - else - { - x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); - } - if(x->x_gui.x_fsf.x_rcv_able) + if (x->x_gui.x_font_style<0 || x->x_gui.x_font_style>2) x->x_gui.x_font_style=0; + if(iemgui_has_rcv(&x->x_gui)) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; @@ -706,7 +672,7 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) static void vslider_free(t_vslider *x) { - if(x->x_gui.x_fsf.x_rcv_able) + if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -733,24 +699,9 @@ void g_vslider_setup(void) gensym("set"), A_FLOAT, 0); class_addmethod(vslider_class, (t_method)vslider_size, gensym("size"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_delta, - gensym("delta"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_pos, - gensym("pos"), A_GIMME, 0); + iemgui_class_addmethods(vslider_class); class_addmethod(vslider_class, (t_method)vslider_range, gensym("range"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_color, - gensym("color"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_send, - gensym("send"), A_DEFSYM, 0); - class_addmethod(vslider_class, (t_method)vslider_receive, - gensym("receive"), A_DEFSYM, 0); - class_addmethod(vslider_class, (t_method)vslider_label, - gensym("label"), A_DEFSYM, 0); - class_addmethod(vslider_class, (t_method)vslider_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_label_font, - gensym("label_font"), A_GIMME, 0); class_addmethod(vslider_class, (t_method)vslider_log, gensym("log"), 0); class_addmethod(vslider_class, (t_method)vslider_lin, gensym("lin"), 0); class_addmethod(vslider_class, (t_method)vslider_init, diff --git a/pd/src/g_vumeter.c b/pd/src/g_vumeter.c index 5e3fb1304..abdfe1eae 100644 --- a/pd/src/g_vumeter.c +++ b/pd/src/g_vumeter.c @@ -134,7 +134,7 @@ static void vu_draw_new(t_vu *x, t_glist *glist) "-font {{%s} -%d %s} -fill #%6.6x " "-tags {%lxSCALE%d %lxVU %s text iemgui}\n", canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, + iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, i, x, nlet_tag); } if(x->x_scale) @@ -145,7 +145,7 @@ static void vu_draw_new(t_vu *x, t_glist *glist) "-font {{%s} -%d %s} -fill #%6.6x " "-tags {%lxSCALE%d %lxVU %s text iemgui}\n", canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, i, x, nlet_tag); } sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x " @@ -159,7 +159,7 @@ static void vu_draw_new(t_vu *x, t_glist *glist) canvas, mid+1, ypos+12, mid+1, ypos+12, x->x_led_size, x->x_gui.x_bcol, x, x, nlet_tag); iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag,"VU"); - if (!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + if (!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) { sys_vgui(".x%lx.c create prect %d %d %d %d " "-stroke $pd_colors(iemgui_nlet) " @@ -176,7 +176,7 @@ static void vu_draw_new(t_vu *x, t_glist *glist) xpos+x->x_gui.x_w+2, ypos + x->x_gui.x_h+4, x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); } - if (!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + if (!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) { sys_vgui(".x%lx.c create prect %d %d %d %d " "-stroke $pd_colors(iemgui_nlet) " @@ -238,7 +238,7 @@ static void vu_draw_move(t_vu *x, t_glist *glist) x->x_updaterms = x->x_updatepeak = 1; sys_queuegui(x, glist, vu_draw_update); iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) { sys_vgui(".x%lx.c coords %lxVU%so%d %d %d %d %d\n", canvas, x, nlet_tag, 0, @@ -249,7 +249,7 @@ static void vu_draw_move(t_vu *x, t_glist *glist) xpos+x->x_gui.x_w+2-IOWIDTH, ypos + x->x_gui.x_h+3, xpos+x->x_gui.x_w+2, ypos + x->x_gui.x_h+4); } - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) { sys_vgui(".x%lx.c coords %lxVU%si%d %d %d %d %d\n", canvas, x, nlet_tag, 0, @@ -261,7 +261,7 @@ static void vu_draw_move(t_vu *x, t_glist *glist) xpos+x->x_gui.x_w+2, ypos+1); } /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) vu_draw_select(x, x->x_gui.x_glist); } } @@ -275,30 +275,30 @@ static void vu_draw_config(t_vu* x, t_glist* glist) sys_vgui(".x%lx.c itemconfigure %lxRLED%d -strokewidth %d\n", canvas, x, i, x->x_led_size); if(((i + 2) & 3) && (x->x_scale)) - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " "-font {{%s} -%d %s} -fill $pd_colors(selection)\n", - canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, + canvas, x, i, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight); else sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " "-font {{%s} -%d %s} -fill #%6.6x\n", - canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, + canvas, x, i, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol); } if(x->x_scale) { i = IEM_VU_STEPS + 1; - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " "-font {{%s} -%d %s} -fill $pd_colors(selection)\n", - canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, + canvas, x, i, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight); else sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " "-font {{%s} -%d %s} -fill #%6.6x\n", - canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, + canvas, x, i, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol); } @@ -323,7 +323,7 @@ static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags) char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); if ((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && - !x->x_gui.x_fsf.x_snd_able) + !iemgui_has_snd(&x->x_gui)) { sys_vgui(".x%lx.c create prect %d %d %d %d " "-stroke $pd_colors(iemgui_nlet) " @@ -340,13 +340,13 @@ static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags) x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); } if (!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && - x->x_gui.x_fsf.x_snd_able) + iemgui_has_snd(&x->x_gui)) { sys_vgui(".x%lx.c delete %lxVU%so%d\n", canvas, x, nlet_tag, 0); sys_vgui(".x%lx.c delete %lxVU%so%d\n", canvas, x, nlet_tag, 1); } if ((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && - !x->x_gui.x_fsf.x_rcv_able) + !iemgui_has_rcv(&x->x_gui)) { sys_vgui(".x%lx.c create prect %d %d %d %d " "-tags {%lxVU%si%d %si%d %lxVU %s outlet}\n", @@ -362,7 +362,7 @@ static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags) x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); } if (!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && - x->x_gui.x_fsf.x_rcv_able) + iemgui_has_rcv(&x->x_gui)) { sys_vgui(".x%lx.c delete %lxVU%si%d\n", canvas, x, nlet_tag, 0); sys_vgui(".x%lx.c delete %lxVU%si%d\n", canvas, x, nlet_tag, 1); @@ -374,7 +374,7 @@ static void vu_draw_select(t_vu* x,t_glist* glist) { int i; t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_fsf.x_selected) + if(x->x_gui.x_selected) { // check if we are drawing inside a gop abstraction // visible on parent canvas. If so, disable highlighting @@ -521,7 +521,7 @@ static void vu_scale_getrect(t_iemgui x_gui, t_glist *x, int *xp1, int *yp1, { //fprintf(stderr,"vu_scale_getrect\n"); - switch(x_gui.x_fsf.x_font_style) + switch(x_gui.x_font_style) { case 1: width_multiplier = 0.83333; @@ -543,7 +543,7 @@ static void vu_scale_getrect(t_iemgui x_gui, t_glist *x, int *xp1, int *yp1, } actual_height = actual_fontsize; //exceptions - if (x_gui.x_fsf.x_font_style == 0 && + if (x_gui.x_font_style == 0 && (actual_fontsize == 8 || actual_fontsize == 13 || actual_fontsize % 10 == 1 || actual_fontsize % 10 == 6 || (actual_fontsize > 48 && actual_fontsize < 100 && @@ -551,14 +551,14 @@ static void vu_scale_getrect(t_iemgui x_gui, t_glist *x, int *xp1, int *yp1, { actual_fontsize += 1; } - else if (x_gui.x_fsf.x_font_style == 1 && + else if (x_gui.x_font_style == 1 && actual_fontsize >= 5 && actual_fontsize < 13 && actual_fontsize % 2 == 1) { actual_fontsize += 1; } - else if (x_gui.x_fsf.x_font_style == 2 && + else if (x_gui.x_font_style == 2 && actual_fontsize >= 5 && actual_fontsize % 2 == 1) { @@ -578,7 +578,7 @@ static void vu_scale_getrect(t_iemgui x_gui, t_glist *x, int *xp1, int *yp1, //DEBUG //fprintf(stderr,"%f %d %d\n", - // width_multiplier, scale_length, x_gui.x_fsf.x_font_style); + // width_multiplier, scale_length, x_gui.x_font_style); //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x); //sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags iemguiDEBUG\n", // x, scale_x1, scale_y1, scale_x2, scale_y2); @@ -633,27 +633,21 @@ static void vu_save(t_gobj *z, t_binbuf *b) gensym("vu"), x->x_gui.x_w, x->x_gui.x_h, srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, - iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + iem_fstyletoint(&x->x_gui), x->x_gui.x_fontsize, bflcol[0], bflcol[2], x->x_scale, - iem_symargstoint(&x->x_gui.x_isa)); + iem_symargstoint(&x->x_gui)); binbuf_addv(b, ";"); } void vu_check_height(t_vu *x, int h) { - int n; - - n = h / IEM_VU_STEPS; - if(n < IEM_VU_MINSIZE) - n = IEM_VU_MINSIZE; + int n = maxi(h / IEM_VU_STEPS, IEM_VU_MINSIZE); x->x_led_size = n-1; x->x_gui.x_h = IEM_VU_STEPS * n; } static void vu_scale(t_vu *x, t_floatarg fscale) { - //fprintf(stderr,"vu_scale\n"); - int i, scale = (int)fscale; if(scale != 0) scale = 1; @@ -692,7 +686,7 @@ static void vu_scale(t_vu *x, t_floatarg fscale) "-font {{%s} -%d %s} -fill #%6.6x " "-tags {%lxSCALE%d %lxVU %lx}\n", canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, + iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, i, x, x); } i = IEM_VU_STEPS + 1; @@ -701,7 +695,7 @@ static void vu_scale(t_vu *x, t_floatarg fscale) "-font {{%s} -%d %s} -fill #%6.6x " "-tags {%lxSCALE%d %lxVU %lx}\n", canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, + iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, i, x, x); } } @@ -728,7 +722,7 @@ static void vu_properties(t_gobj *z, t_glist *owner) x->x_scale, -1, -1, -1,/*no linlog, no init, no multi*/ "nosndno", srl[1]->s_name,/*no send*/ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, - x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + x->x_gui.x_font_style, x->x_gui.x_fontsize, 0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); @@ -744,10 +738,9 @@ static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv) int scale = (int)atom_getintarg(4, argc, argv); int sr_flags; - srl[0] = gensym("empty"); + srl[0] = s_empty; sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); - x->x_gui.x_fsf.x_snd_able = 0; - x->x_gui.x_isa.x_loadinit = 0; + x->x_gui.x_loadinit = 0; x->x_gui.x_w = iemgui_clip_size(w); vu_check_height(x, h); if(scale != 0) @@ -757,10 +750,10 @@ static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) + if (x->x_gui.x_selected) { vu_draw_select(x, x->x_gui.x_glist); } @@ -784,27 +777,6 @@ static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av) } } -static void vu_delta(t_vu *x, t_symbol *s, int ac, t_atom *av) -{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} - -static void vu_pos(t_vu *x, t_symbol *s, int ac, t_atom *av) -{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} - -static void vu_color(t_vu *x, t_symbol *s, int ac, t_atom *av) -{iemgui_color((void *)x, &x->x_gui, s, ac, av);} - -static void vu_receive(t_vu *x, t_symbol *s) -{iemgui_receive(x, &x->x_gui, s);} - -static void vu_label(t_vu *x, t_symbol *s) -{iemgui_label((void *)x, &x->x_gui, s);} - -static void vu_label_pos(t_vu *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} - -static void vu_label_font(t_vu *x, t_symbol *s, int ac, t_atom *av) -{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} - static void vu_float(t_vu *x, t_floatarg rms) { int i; @@ -862,8 +834,8 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) int w = IEM_GUI_DEFAULTSIZE, h = IEM_VU_STEPS*IEM_VU_DEFAULTSIZE; int ldx = -1, ldy = -8, fs = 10, scale = 1; - iem_inttosymargs(&x->x_gui.x_isa, 0); - iem_inttofstyle(&x->x_gui.x_fsf, 0); + iem_inttosymargs(&x->x_gui, 0); + iem_inttofstyle(&x->x_gui, 0); if((argc >= 11)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1) &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2)) @@ -877,7 +849,7 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) iemgui_new_getnames(&x->x_gui, 1, argv); ldx = (int)atom_getintarg(4, argc, argv); ldy = (int)atom_getintarg(5, argc, argv); - iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(6, argc, argv)); + iem_inttofstyle(&x->x_gui, atom_getintarg(6, argc, argv)); fs = (int)atom_getintarg(7, argc, argv); bflcol[0] = (int)atom_getintarg(8, argc, argv); bflcol[2] = (int)atom_getintarg(9, argc, argv); @@ -885,24 +857,12 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) } else iemgui_new_getnames(&x->x_gui, 1, 0); if((argc == 12)&&IS_A_FLOAT(argv,11)) - iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(11, argc, argv)); + iem_inttosymargs(&x->x_gui, atom_getintarg(11, argc, argv)); x->x_gui.x_draw = (t_iemfunptr)vu_draw; - x->x_gui.x_fsf.x_snd_able = 0; - x->x_gui.x_fsf.x_rcv_able = 1; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); - if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) - x->x_gui.x_fsf.x_rcv_able = 0; - if (x->x_gui.x_fsf.x_font_style == 1) - strcpy(x->x_gui.x_font, "helvetica"); - else if(x->x_gui.x_fsf.x_font_style == 2) - strcpy(x->x_gui.x_font, "times"); - else - { - x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); - } - if(x->x_gui.x_fsf.x_rcv_able) + if (x->x_gui.x_font_style<0 || x->x_gui.x_font_style>2) x->x_gui.x_font_style=0; + if(iemgui_has_rcv(&x->x_gui)) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; @@ -934,7 +894,7 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) static void vu_free(t_vu *x) { - if(x->x_gui.x_fsf.x_rcv_able) + if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -954,21 +914,7 @@ void g_vumeter_setup(void) class_addmethod(vu_class, (t_method)vu_size, gensym("size"), A_GIMME, 0); class_addmethod(vu_class, (t_method)vu_scale, gensym("scale"), A_DEFFLOAT, 0); - class_addmethod(vu_class, (t_method)vu_delta, - gensym("delta"), A_GIMME, 0); - class_addmethod(vu_class, (t_method)vu_pos, - gensym("pos"), A_GIMME, 0); - class_addmethod(vu_class, (t_method)vu_color, - gensym("color"), A_GIMME, 0); - class_addmethod(vu_class, (t_method)vu_receive, - gensym("receive"), A_DEFSYM, 0); - class_addmethod(vu_class, (t_method)vu_label, - gensym("label"), A_DEFSYM, 0); - class_addmethod(vu_class, (t_method)vu_label_pos, - gensym("label_pos"), A_GIMME, 0); - class_addmethod(vu_class, (t_method)vu_label_font, - gensym("label_font"), A_GIMME, 0); - + iemgui_class_addmethods(vu_class); scalehandle_class = class_new(gensym("_scalehandle"), 0, 0, sizeof(t_scalehandle), CLASS_PD, 0); class_addmethod(scalehandle_class, (t_method)vu__clickhook, diff --git a/pd/src/m_conf.c b/pd/src/m_conf.c index 3f87ce07f..c62e4f769 100644 --- a/pd/src/m_conf.c +++ b/pd/src/m_conf.c @@ -11,6 +11,7 @@ void g_array_setup(void); void g_canvas_setup(void); void g_guiconnect_setup(void); /* iemlib */ +void g_iemgui_setup(void); void g_bang_setup(void); void g_hradio_setup(void); void g_hslider_setup(void); @@ -61,6 +62,7 @@ void conf_init(void) g_canvas_setup(); g_guiconnect_setup(); /* iemlib */ + g_iemgui_setup(); g_bang_setup(); g_hradio_setup(); g_hslider_setup(); -- GitLab