Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30109
Modified Files:
Tag: impd_0_37
g_mycanvas.c g_numbox.c
Log Message:
[nbx] [cnv] bugfix
Index: g_mycanvas.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_mycanvas.c,v
retrieving revision 1.1.1.3.2.2.2.18
retrieving revision 1.1.1.3.2.2.2.19
diff -C2 -d -r1.1.1.3.2.2.2.18 -r1.1.1.3.2.2.2.19
*** g_mycanvas.c 13 May 2004 14:37:20 -0000 1.1.1.3.2.2.2.18
--- g_mycanvas.c 13 Aug 2004 16:41:47 -0000 1.1.1.3.2.2.2.19
***************
*** 15,25 ****
#include <math.h>
! static t_class *my_canvas_class;
/* ------------------------ cnv widgetbehaviour----------------------------- */
! static void my_canvas_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
{
! t_my_canvas *x = (t_my_canvas *)z;
*xp1 = text_xpix(&x->x_gui.x_obj, glist);
*yp1 = text_ypix(&x->x_gui.x_obj, glist);
--- 15,25 ----
#include <math.h>
! static t_class *cnv_class;
/* ------------------------ cnv widgetbehaviour----------------------------- */
! static void cnv_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
{
! t_cnv *x = (t_cnv *)z;
*xp1 = text_xpix(&x->x_gui.x_obj, glist);
*yp1 = text_ypix(&x->x_gui.x_obj, glist);
***************
*** 28,32 ****
}
! static void my_canvas_get_pos(t_my_canvas *x)
{
t_iemgui *y = (t_iemgui *)x;
--- 28,32 ----
}
! static void cnv_get_pos(t_cnv *x)
{
t_iemgui *y = (t_iemgui *)x;
***************
*** 38,45 ****
}
! static void my_canvas_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
{x->x_gui.x_w = x->x_gui.x_h = MAX(1,atom_getintarg(0, ac, av)); iemgui_size((t_iemgui *)x);}
! static void my_canvas_vis_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
{
x->x_vis_h = x->x_vis_w = MAX(1,(int)atom_getintarg(0, ac, av));
--- 38,45 ----
}
! static void cnv_size(t_cnv *x, t_symbol *s, int ac, t_atom *av)
{x->x_gui.x_w = x->x_gui.x_h = MAX(1,atom_getintarg(0, ac, av)); iemgui_size((t_iemgui *)x);}
! static void cnv_vis_size(t_cnv *x, t_symbol *s, int ac, t_atom *av)
{
x->x_vis_h = x->x_vis_w = MAX(1,(int)atom_getintarg(0, ac, av));
***************
*** 48,52 ****
}
! static void my_canvas_reload(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv)
{
t_iemgui *y = (t_iemgui *)x;
--- 48,61 ----
}
! static void cnv_save(t_cnv *x, t_binbuf *b) {
! t_iemgui *y = (t_iemgui *)x;
! pd_savehead(b, y, "cnv");
! pd_saveargs(b,"iiiaaaiiiicc;i",&y->x_w,&x->x_vis_w,&x->x_vis_h,
! &y->x_snd,&y->x_rcv,&y->x_lab,&y->x_ldx,&y->x_ldy,
! &y->x_font_style,&y->x_fontsize,&y->x_bcol,&y->x_lcol,&y->x_isa);
! binbuf_print(b);
! }
!
! static void cnv_reload(t_cnv *x, t_symbol *s, int argc, t_atom *argv)
{
t_iemgui *y = (t_iemgui *)x;
***************
*** 64,71 ****
}
! static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv)
{
! t_iemgui *y = iemgui_new(my_canvas_class);
! t_my_canvas *x = (t_my_canvas *)y;
y->x_bcol = 0xe0e0e0;
y->x_fcol = 0x000000;
--- 73,80 ----
}
! static void *cnv_new(t_symbol *s, int argc, t_atom *argv)
{
! t_iemgui *y = iemgui_new(cnv_class);
! t_cnv *x = (t_cnv *)y;
y->x_bcol = 0xe0e0e0;
y->x_fcol = 0x000000;
***************
*** 73,81 ****
y->x_w=100;
y->x_h=60;
! my_canvas_reload(x,0,argc,argv);
return x;
}
! static void my_canvas_ff(t_my_canvas *x)
{
if(x->x_gui.x_rcv) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
--- 82,90 ----
y->x_w=100;
y->x_h=60;
! cnv_reload(x,0,argc,argv);
return x;
}
! static void cnv_ff(t_cnv *x)
{
if(x->x_gui.x_rcv) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
***************
*** 86,98 ****
void g_mycanvas_setup(void)
{
! t_class *c = my_canvas_class = class_new(gensym("cnv"), (t_newmethod)my_canvas_new,
! (t_method)my_canvas_ff, sizeof(t_my_canvas), CLASS_NOINLET, A_GIMME, 0);
! class_addcreator((t_newmethod)my_canvas_new, gensym("my_canvas"), A_GIMME, 0);
! class_addmethod(c, (t_method)my_canvas_reload, gensym("reload"), A_GIMME, 0);
! class_addmethod(c, (t_method)my_canvas_size, gensym("size"), A_GIMME, 0);
! class_addmethod(c, (t_method)my_canvas_vis_size, gensym("vis_size"), A_GIMME, 0);
! class_addmethod(c, (t_method)my_canvas_get_pos, gensym("get_pos"), 0);
iemgui_subclass(c);
! wb.w_getrectfn = my_canvas_getrect;
wb.w_displacefn = iemgui_displace;
wb.w_selectfn = iemgui_select;
--- 95,107 ----
void g_mycanvas_setup(void)
{
! t_class *c = cnv_class = class_new(gensym("cnv"), (t_newmethod)cnv_new,
! (t_method)cnv_ff, sizeof(t_cnv), CLASS_NOINLET, A_GIMME, 0);
! class_addcreator((t_newmethod)cnv_new, gensym("cnv"), A_GIMME, 0);
! class_addmethod(c, (t_method)cnv_reload, gensym("reload"), A_GIMME, 0);
! class_addmethod(c, (t_method)cnv_size, gensym("size"), A_GIMME, 0);
! class_addmethod(c, (t_method)cnv_vis_size, gensym("vis_size"), A_GIMME, 0);
! class_addmethod(c, (t_method)cnv_get_pos, gensym("get_pos"), 0);
iemgui_subclass(c);
! wb.w_getrectfn = cnv_getrect;
wb.w_displacefn = iemgui_displace;
wb.w_selectfn = iemgui_select;
***************
*** 102,105 ****
wb.w_clickfn = NULL;
class_setwidget(c, &wb);
! class_sethelpsymbol(c, gensym("my_canvas"));
}
--- 111,115 ----
wb.w_clickfn = NULL;
class_setwidget(c, &wb);
! class_setsavefn(c,cnv_save);
! class_sethelpsymbol(c, gensym("cnv"));
}
Index: g_numbox.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_numbox.c,v
retrieving revision 1.1.1.4.2.2.2.27
retrieving revision 1.1.1.4.2.2.2.28
diff -C2 -d -r1.1.1.4.2.2.2.27 -r1.1.1.4.2.2.2.28
*** g_numbox.c 13 May 2004 14:37:20 -0000 1.1.1.4.2.2.2.27
--- g_numbox.c 13 Aug 2004 16:41:49 -0000 1.1.1.4.2.2.2.28
***************
*** 3,7 ****
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
! /* my_numbox.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
#include <stdlib.h>
--- 3,7 ----
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
! /* nbx.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
#include <stdlib.h>
***************
*** 16,24 ****
#define CH
! static t_class *my_numbox_class;
/* widget helper functions */
! static void my_numbox_tick_reset(t_my_numbox *x)
{
if(!x->x_change) return;
--- 16,24 ----
#define CH
! static t_class *nbx_class;
/* widget helper functions */
! static void nbx_tick_reset(t_nbx *x)
{
if(!x->x_change) return;
***************
*** 28,35 ****
}
! static void my_numbox_tick_wait(t_my_numbox *x) {pd_changed(x);}
! void my_numbox_clip(t_my_numbox *x) {CLAMP(x->x_val,x->x_min,x->x_max);}
! void my_numbox_calc_fontwidth(t_my_numbox *x)
{
int f = x->x_gui.x_font_style==1 ? 27 : x->x_gui.x_font_style==2 ? 25 : 31;
--- 28,35 ----
}
! static void nbx_tick_wait(t_nbx *x) {pd_changed(x);}
! void nbx_clip(t_nbx *x) {CLAMP(x->x_val,x->x_min,x->x_max);}
! void nbx_calc_fontwidth(t_nbx *x)
{
int f = x->x_gui.x_font_style==1 ? 27 : x->x_gui.x_font_style==2 ? 25 : 31;
***************
*** 40,47 ****
/* ------------------------ nbx widgetbehaviour----------------------------- */
! static void my_numbox_getrect(t_gobj *z, t_glist *glist,
int *xp1, int *yp1, int *xp2, int *yp2)
{
! t_my_numbox* x = (t_my_numbox*)z;
*xp1 = text_xpix((t_text *)x, glist);
*yp1 = text_ypix((t_text *)x, glist);
--- 40,47 ----
/* ------------------------ nbx widgetbehaviour----------------------------- */
! static void nbx_getrect(t_gobj *z, t_glist *glist,
int *xp1, int *yp1, int *xp2, int *yp2)
{
! t_nbx* x = (t_nbx*)z;
*xp1 = text_xpix((t_text *)x, glist);
*yp1 = text_ypix((t_text *)x, glist);
***************
*** 50,54 ****
}
! int my_numbox_check_minmax(t_my_numbox *x)
{
double min=x->x_min, max=x->x_max;
--- 50,54 ----
}
! int nbx_check_minmax(t_nbx *x)
{
double min=x->x_min, max=x->x_max;
***************
*** 66,70 ****
}
! static void my_numbox_bang(t_my_numbox *x)
{
outlet_float(x->x_gui.x_obj.ob_outlet, x->x_val);
--- 66,70 ----
}
! static void nbx_bang(t_nbx *x)
{
outlet_float(x->x_gui.x_obj.ob_outlet, x->x_val);
***************
*** 73,90 ****
}
! static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy)
{
double k2= x->x_finemoved ? 0.01 : 1.0;
if(x->x_is_log) x->x_val *= pow(x->x_k, -k2*dy); else x->x_val -= k2*dy;
! my_numbox_clip(x);
pd_changed(x);
! my_numbox_bang(x);
clock_unset(x->x_clock_reset);
}
! static void my_numbox_set(t_my_numbox *x, t_floatarg f)
! {x->x_val=f; my_numbox_clip(x); pd_changed(x);}
! static void my_numbox_log_height(t_my_numbox *x, t_floatarg lh)
{
x->x_log_height = MAX(10.0,(int)lh);
--- 73,90 ----
}
! static void nbx_motion(t_nbx *x, t_floatarg dx, t_floatarg dy)
{
double k2= x->x_finemoved ? 0.01 : 1.0;
if(x->x_is_log) x->x_val *= pow(x->x_k, -k2*dy); else x->x_val -= k2*dy;
! nbx_clip(x);
pd_changed(x);
! nbx_bang(x);
clock_unset(x->x_clock_reset);
}
! static void nbx_set(t_nbx *x, t_floatarg f)
! {x->x_val=f; nbx_clip(x); pd_changed(x);}
! static void nbx_log_height(t_nbx *x, t_floatarg lh)
{
x->x_log_height = MAX(10.0,(int)lh);
***************
*** 92,125 ****
}
! static void my_numbox_float(t_my_numbox *x, t_floatarg f)
! {my_numbox_set(x, f); if(iemgui_forward(x)) my_numbox_bang(x);}
! static void my_numbox_size(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
{
x->x_gui.x_w = MAX(1,(int)atom_getintarg(0, ac, av));
if(ac > 1) x->x_gui.x_h = MAX(8,(int)atom_getintarg(1, ac, av));
! my_numbox_calc_fontwidth(x);
iemgui_size((t_iemgui *)x);
}
! static void my_numbox_range(t_my_numbox *x, t_float min, t_float max)
{x->x_min=min; x->x_max=max;
! if(my_numbox_check_minmax(x)) pd_changed(x);}
! static void my_numbox_lin(t_my_numbox *x) {x->x_is_log=0;}
! static void my_numbox_log(t_my_numbox *x) {x->x_is_log=1;
! if(my_numbox_check_minmax(x)) pd_changed(x);}
! static void my_numbox_loadbang(t_my_numbox *x)
! {if(iemgui_loadbang(x)) my_numbox_bang(x);}
! static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
{
if (!IS_A_FLOAT(av,0)) return;
! my_numbox_set(x, atom_getfloatarg(0, ac, av));
! my_numbox_bang(x);
}
! static void my_numbox_reload(t_my_numbox *x, t_symbol *s, int argc, t_atom *argv)
{
t_iemgui *y = (t_iemgui *)x;
--- 92,136 ----
}
! static void nbx_float(t_nbx *x, t_floatarg f)
! {nbx_set(x, f); if(iemgui_forward(x)) nbx_bang(x);}
! static void nbx_size(t_nbx *x, t_symbol *s, int ac, t_atom *av)
{
x->x_gui.x_w = MAX(1,(int)atom_getintarg(0, ac, av));
if(ac > 1) x->x_gui.x_h = MAX(8,(int)atom_getintarg(1, ac, av));
! nbx_calc_fontwidth(x);
iemgui_size((t_iemgui *)x);
}
! static void nbx_range(t_nbx *x, t_float min, t_float max)
{x->x_min=min; x->x_max=max;
! if(nbx_check_minmax(x)) pd_changed(x);}
! static void nbx_lin(t_nbx *x) {x->x_is_log=0;}
! static void nbx_log(t_nbx *x) {x->x_is_log=1;
! if(nbx_check_minmax(x)) pd_changed(x);}
! static void nbx_loadbang(t_nbx *x)
! {if(iemgui_loadbang(x)) nbx_bang(x);}
! static void nbx_list(t_nbx *x, t_symbol *s, int ac, t_atom *av)
{
if (!IS_A_FLOAT(av,0)) return;
! nbx_set(x, atom_getfloatarg(0, ac, av));
! nbx_bang(x);
}
! static void nbx_save(t_nbx *x, t_binbuf *b) {
! t_iemgui *y = (t_iemgui *)x;
! if (!b) return;
! binbuf_clear(b);
! pd_savehead(b, y, "nbx");
! pd_saveargs(b,"iiddbiaaaiiiicccd;i",
! &y->x_w,&y->x_h,&x->x_min,&x->x_max,&x->x_is_log,&y->x_isa,&y->x_snd,&y->x_rcv,&y->x_lab,
! &y->x_ldx,&y->x_ldy,&y->x_font_style,&y->x_fontsize,
! &y->x_bcol,&y->x_fcol,&y->x_lcol,&x->x_val,&x->x_log_height);
! }
!
! static void nbx_reload(t_nbx *x, t_symbol *s, int argc, t_atom *argv)
{
t_iemgui *y = (t_iemgui *)x;
***************
*** 134,139 ****
iemgui_constrain(y);
y->x_w=MAX(w,1);
! my_numbox_calc_fontwidth(x);
! my_numbox_check_minmax(x);
y->x_w = MAX(y->x_w,1);
if (y->x_rcv) pd_bind((t_pd *)x, y->x_rcv);
--- 145,150 ----
iemgui_constrain(y);
y->x_w=MAX(w,1);
! nbx_calc_fontwidth(x);
! nbx_check_minmax(x);
y->x_w = MAX(y->x_w,1);
if (y->x_rcv) pd_bind((t_pd *)x, y->x_rcv);
***************
*** 141,148 ****
}
! static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv)
{
! t_iemgui *y = iemgui_new(my_numbox_class);
! t_my_numbox *x = (t_my_numbox *)y;
x->x_log_height = 256;
x->x_is_log = 0;
--- 152,159 ----
}
! static void *nbx_new(t_symbol *s, int argc, t_atom *argv)
{
! t_iemgui *y = iemgui_new(nbx_class);
! t_nbx *x = (t_nbx *)y;
x->x_log_height = 256;
x->x_is_log = 0;
***************
*** 152,164 ****
x->x_max=1.0e+37;
x->x_buf[0]=0;
! 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_change = 0; CH
outlet_new((t_text *)x, &s_float);
! my_numbox_reload(x,0,argc,argv);
return x;
}
! static void my_numbox_free(t_my_numbox *x)
{
if(x->x_gui.x_rcv) pd_unbind((t_pd *)x, x->x_gui.x_rcv);
--- 163,175 ----
x->x_max=1.0e+37;
x->x_buf[0]=0;
! x->x_clock_reset = clock_new(x, (t_method)nbx_tick_reset);
! x->x_clock_wait = clock_new(x, (t_method)nbx_tick_wait);
x->x_change = 0; CH
outlet_new((t_text *)x, &s_float);
! nbx_reload(x,0,argc,argv);
return x;
}
! static void nbx_free(t_nbx *x)
{
if(x->x_gui.x_rcv) pd_unbind((t_pd *)x, x->x_gui.x_rcv);
***************
*** 171,193 ****
void g_numbox_setup(void)
{
! t_class *c = my_numbox_class = class_new(gensym("nbx"), (t_newmethod)my_numbox_new,
! (t_method)my_numbox_free, sizeof(t_my_numbox), 0, A_GIMME, 0);
! class_addcreator((t_newmethod)my_numbox_new, gensym("my_numbox"), A_GIMME, 0);
iemgui_subclass(c);
! class_addbang(c,my_numbox_bang);
! class_addfloat(c,my_numbox_float);
! class_addlist(c, my_numbox_list);
! //class_addmethod(c, (t_method)my_numbox_motion, gensym("motion"), A_FLOAT, A_FLOAT, 0);
! class_addmethod(c, (t_method)my_numbox_reload, gensym("reload"), A_GIMME, 0);
! class_addmethod(c, (t_method)my_numbox_loadbang, gensym("loadbang"), 0);
! class_addmethod(c, (t_method)my_numbox_set, gensym("set"), A_FLOAT, 0);
! class_addmethod(c, (t_method)my_numbox_size, gensym("size"), A_GIMME, 0);
! class_addmethod(c, (t_method)my_numbox_range, gensym("range"), A_GIMME, 0);
/* !@#$ actually overrode label_font to do stuff related to width */
! class_addmethod(c, (t_method)my_numbox_log, gensym("log"), 0);
! class_addmethod(c, (t_method)my_numbox_lin, gensym("lin"), 0);
class_addmethod(c, (t_method)iemgui_init, gensym("init"), A_FLOAT, 0);
! class_addmethod(c, (t_method)my_numbox_log_height, gensym("log_height"), A_FLOAT, 0);
! wb.w_getrectfn = my_numbox_getrect;
wb.w_displacefn = iemgui_displace;
wb.w_selectfn = iemgui_select;
--- 182,204 ----
void g_numbox_setup(void)
{
! t_class *c = nbx_class = class_new(gensym("nbx"), (t_newmethod)nbx_new,
! (t_method)nbx_free, sizeof(t_nbx), 0, A_GIMME, 0);
! class_addcreator((t_newmethod)nbx_new, gensym("nbx"), A_GIMME, 0);
iemgui_subclass(c);
! class_addbang(c,nbx_bang);
! class_addfloat(c,nbx_float);
! class_addlist(c, nbx_list);
! //class_addmethod(c, (t_method)nbx_motion, gensym("motion"), A_FLOAT, A_FLOAT, 0);
! class_addmethod(c, (t_method)nbx_reload, gensym("reload"), A_GIMME, 0);
! class_addmethod(c, (t_method)nbx_loadbang, gensym("loadbang"), 0);
! class_addmethod(c, (t_method)nbx_set, gensym("set"), A_FLOAT, 0);
! class_addmethod(c, (t_method)nbx_size, gensym("size"), A_GIMME, 0);
! class_addmethod(c, (t_method)nbx_range, gensym("range"), A_GIMME, 0);
/* !@#$ actually overrode label_font to do stuff related to width */
! class_addmethod(c, (t_method)nbx_log, gensym("log"), 0);
! class_addmethod(c, (t_method)nbx_lin, gensym("lin"), 0);
class_addmethod(c, (t_method)iemgui_init, gensym("init"), A_FLOAT, 0);
! class_addmethod(c, (t_method)nbx_log_height, gensym("log_height"), A_FLOAT, 0);
! wb.w_getrectfn = nbx_getrect;
wb.w_displacefn = iemgui_displace;
wb.w_selectfn = iemgui_select;
***************
*** 197,200 ****
--- 208,212 ----
wb.w_clickfn = NULL;
class_setwidget(c, &wb);
+ class_setsavefn(c,nbx_save);
class_sethelpsymbol(c, gensym("numbox2"));
}