Skip to content
Snippets Groups Projects
Commit e55d41dc authored by Ivica Ico Bukvic's avatar Ivica Ico Bukvic
Browse files

added ability for hslider to pass through uncorrupted values (if entered...

added ability for hslider to pass through uncorrupted values (if entered externally via inlet) and to resize its knob properly when resizing via clickhook
parent 7d80d3c3
No related branches found
No related tags found
Loading
...@@ -33,6 +33,9 @@ static void hslider_draw_select(t_hslider* x,t_glist* glist); ...@@ -33,6 +33,9 @@ static void hslider_draw_select(t_hslider* x,t_glist* glist);
t_widgetbehavior hslider_widgetbehavior; t_widgetbehavior hslider_widgetbehavior;
static t_class *hslider_class; static t_class *hslider_class;
static double last;
static int is_last_float = 0;
/* widget helper functions */ /* widget helper functions */
static void hslider_draw_update(t_gobj *client, t_glist *glist) static void hslider_draw_update(t_gobj *client, t_glist *glist)
...@@ -350,6 +353,9 @@ static void hslider__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, ...@@ -350,6 +353,9 @@ static void hslider__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx,
if (sh->h_dragx || sh->h_dragy) { if (sh->h_dragx || sh->h_dragy) {
double width_change_ratio = (double)(x->x_gui.x_w + sh->h_dragx - x->x_gui.scale_offset_x)/(double)x->x_gui.x_w;
x->x_val = x->x_val * width_change_ratio;
x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - x->x_gui.scale_offset_x; x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - x->x_gui.scale_offset_x;
if (x->x_gui.x_w < SCALE_HSLD_MINWIDTH) if (x->x_gui.x_w < SCALE_HSLD_MINWIDTH)
x->x_gui.x_w = SCALE_HSLD_MINWIDTH; x->x_gui.x_w = SCALE_HSLD_MINWIDTH;
...@@ -671,8 +677,12 @@ static void hslider_bang(t_hslider *x) ...@@ -671,8 +677,12 @@ static void hslider_bang(t_hslider *x)
if(x->x_lin0_log1) if(x->x_lin0_log1)
out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01); out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
else else {
out = (double)(x->x_val)*0.01*x->x_k + x->x_min; if (is_last_float && last <= x->x_max && last >= x->x_min)
out = last;
else
out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
}
if((out < 1.0e-10)&&(out > -1.0e-10)) if((out < 1.0e-10)&&(out > -1.0e-10))
out = 0.0; out = 0.0;
outlet_float(x->x_gui.x_obj.ob_outlet, out); outlet_float(x->x_gui.x_obj.ob_outlet, out);
...@@ -720,6 +730,7 @@ static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv) ...@@ -720,6 +730,7 @@ static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv)
static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy) static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy)
{ {
is_last_float = 0;
int old = x->x_val; int old = x->x_val;
if(x->x_gui.x_fsf.x_finemoved) if(x->x_gui.x_fsf.x_finemoved)
...@@ -842,12 +853,18 @@ static void hslider_steady(t_hslider *x, t_floatarg f) ...@@ -842,12 +853,18 @@ static void hslider_steady(t_hslider *x, t_floatarg f)
static void hslider_float(t_hslider *x, t_floatarg f) static void hslider_float(t_hslider *x, t_floatarg f)
{ {
double out; double out;
is_last_float = 1;
last = f;
hslider_set(x, f); hslider_set(x, f);
if(x->x_lin0_log1) if(x->x_lin0_log1)
out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01); out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
else else
out = (double)(x->x_val)*0.01*x->x_k + x->x_min; if (f <= x->x_max && f >= x->x_min) {
out = f;
//x->x_val = f;
} else
out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
if((out < 1.0e-10)&&(out > -1.0e-10)) if((out < 1.0e-10)&&(out > -1.0e-10))
out = 0.0; out = 0.0;
if(x->x_gui.x_fsf.x_put_in2out) if(x->x_gui.x_fsf.x_put_in2out)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment