From 7bb69869e09a82a6906fc8a3f7b48779dcc4fe09 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Jan 2006 22:07:41 +0000 Subject: [PATCH] Made numbuts use non linear rate of change when dragging. The further you drag the bigger the number gets (like gimp/photoshop brush size slider) Works for ranges: float buttons bigger then 11 and int buttons bigger then 129. --- source/blender/src/interface.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index 7ebaf09e60f..d51859b34f8 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -1987,7 +1987,7 @@ static int ui_do_but_NUM(uiBut *but) { double value; float deler, fstart, f, tempf; - int lvalue, temp; /* , firsttime=1; */ + int lvalue, temp, orig_x; /* , firsttime=1; */ short retval=0, qual, sx, mval[2], pos=0; but->flag |= UI_SELECT; @@ -1998,6 +1998,7 @@ static int ui_do_but_NUM(uiBut *but) value= ui_get_but_val(but); sx= mval[0]; + orig_x = sx; /* Store so we can scale the rate of change by the dist the mouse is from its original xlocation */ fstart= (value - but->min)/(but->max-but->min); f= fstart; @@ -2013,21 +2014,30 @@ static int ui_do_but_NUM(uiBut *but) while (get_mbut() & L_MOUSE) { qual= get_qual(); + uiGetMouse(mywinget(), mval); + deler= 500; if( but->pointype!=FLO ) { if( (but->max-but->min)<100 ) deler= 200.0; if( (but->max-but->min)<25 ) deler= 50.0; - } + if(qual & LR_SHIFTKEY) deler*= 10.0; if(qual & LR_ALTKEY) deler*= 20.0; - - uiGetMouse(mywinget(), mval); if(mval[0] != sx) { - - f+= ((float)(mval[0]-sx))/deler; + if( but->pointype==FLO && but->max-but->min > 11) { + /* non linear change in mouse input- good for high precicsion */ + f+= (((float)(mval[0]-sx))/deler) * (fabs(orig_x-mval[0])*0.002); + } else if ( but->pointype!=FLO && but->max-but->min > 129) { /* only scale large int buttons */ + /* non linear change in mouse input- good for high precicsionm ints need less fine tuning */ + f+= (((float)(mval[0]-sx))/deler) * (fabs(orig_x-mval[0])*0.004); + } else { + /*no scaling */ + f+= ((float)(mval[0]-sx))/deler ; + } + if(f>1.0) f= 1.0; if(f<0.0) f= 0.0; sx= mval[0];