Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13506
Modified Files: Tag: desiredata desire.c Log Message: slider val is outputted correctly, and now it's a float instead of an int, to support fractions of centipixels.
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.127 retrieving revision 1.1.2.217.2.128 diff -C2 -d -r1.1.2.217.2.127 -r1.1.2.217.2.128 *** desire.c 11 Jan 2007 22:01:43 -0000 1.1.2.217.2.127 --- desire.c 13 Jan 2007 18:24:47 -0000 1.1.2.217.2.128 *************** *** 5668,5674 ****
struct t_slider : t_iemgui { ! int val; ! double min,max; ! double k; int steady; int is_log; --- 5668,5673 ----
struct t_slider : t_iemgui { ! t_float val; ! t_float min,max; int steady; int is_log; *************** *** 6768,6776 **** double l = (double)(x->orient ? x->h : x->w)-1; int m = (int)(l*100); - double span = x->is_log ? log(x->max/x->min) : (x->max - x->min); if(w < IEM_SL_MINSIZE) w = IEM_SL_MINSIZE; if (x->orient) SET(h,w); else SET(w,w); if(x->val > m) SET(val,m); - SET(k,span/l); }
--- 6767,6773 ---- *************** *** 6784,6789 **** SET(min,min); SET(max,max); ! double diff = x->is_log ? log(x->max/x->min) : (x->max-x->min); ! SET(k,diff / (double)(x->orient ? (x->h-1) : (x->w-1))); }
--- 6781,6790 ---- SET(min,min); SET(max,max); ! } ! ! // the value/centipixel ratio ! static double slider_ratio (t_slider *x) { ! double diff = x->is_log ? log(x->max/x->min) : (x->max-x->min); ! return diff / (double)(x->orient ? (x->h-1) : (x->w-1)); }
*************** *** 6791,6805 **** if(x->min > x->max) CLAMP(f,x->max,x->min); else CLAMP(f,x->min,x->max); ! double g = (x->is_log ? log(f/x->min) : (f-x->min)) / x->k; ! SET(val,(int)(100.0*g + 0.49999)); ! //SET(val,(int)f); }
static void slider_bang(t_slider *x) { ! double t = (double)(x->val)*x->k*0.01; double out = x->is_log ? x->min*exp(t) : x->min+t; if (fabs(out) < 1.0e-10) out = 0.0; ! //outlet_float(x->ob_outlet, out); ! outlet_float(x->ob_outlet, x->val); if(x->snd && x->snd->s_thing) pd_float(x->snd->s_thing, out); } --- 6792,6803 ---- if(x->min > x->max) CLAMP(f,x->max,x->min); else CLAMP(f,x->min,x->max); ! SET(val,floor(100.0 * (x->is_log ? log(f/x->min) : (f-x->min)) / slider_ratio(x) + 0.5)); }
static void slider_bang(t_slider *x) { ! double t = (double)x->val * slider_ratio(x) * 0.01; double out = x->is_log ? x->min*exp(t) : x->min+t; if (fabs(out) < 1.0e-10) out = 0.0; ! outlet_float(x->ob_outlet, out); if(x->snd && x->snd->s_thing) pd_float(x->snd->s_thing, out); } *************** *** 6827,6831 ****
static int slider_pickle(t_slider *x, t_foo *foo) { ! return pd_pickle(foo, "iiddbiaaaiiiiccci;b", &x->w,&x->h,&x->min,&x->max,&x->is_log,&x->isa,&x->snd,&x->rcv,&x->lab, &x->ldx,&x->ldy,&x->font_style,&x->fontsize,&x->bcol,&x->fcol,&x->lcol,&x->val,&x->steady); --- 6825,6829 ----
static int slider_pickle(t_slider *x, t_foo *foo) { ! return pd_pickle(foo, "iiffbiaaaiiiicccf;b", &x->w,&x->h,&x->min,&x->max,&x->is_log,&x->isa,&x->snd,&x->rcv,&x->lab, &x->ldx,&x->ldy,&x->font_style,&x->fontsize,&x->bcol,&x->fcol,&x->lcol,&x->val,&x->steady);