diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-06-05 05:23:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-06-05 05:23:56 +0400 |
commit | ce202f75405208e906f0744c376b27d944a8fb22 (patch) | |
tree | 61ddced8626ccd24bee9bc6102ffd694a90970e9 /source/blender/python/api2_2x/Draw.c | |
parent | 233348197ef8ade459fd6b35fad5fd889d7e88cd (diff) |
Clicking on the arrows of a python float button did not change the value :/ - (Click step was zero) Fixed in Draw.c
Added a comment to interface.c on how a1 and a2 are used with float buttons.
Added an example to Draw.py epydocs of a script using a float button.
Diffstat (limited to 'source/blender/python/api2_2x/Draw.c')
-rw-r--r-- | source/blender/python/api2_2x/Draw.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index 661d1b805f9..28fefb204a8 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -1137,19 +1137,28 @@ static PyObject *Method_Number( PyObject * self, PyObject * args ) but = newbutton( ); if( PyFloat_Check( inio ) ) { - float ini, min, max; + float ini, min, max, range, precission=0; ini = (float)PyFloat_AsDouble( inio ); min = (float)PyFloat_AsDouble( mino ); max = (float)PyFloat_AsDouble( maxo ); - + + range= fabs(max-min); /* Click step will be a 10th of the range. */ + if (!range) range= 1.0f; /* avoid any odd errors */ + + /* set the precission to display*/ + if (range>=100.0f) precission=1.0f; + else if (range>=10.0f) precission=2.0f; + else if (range>1.0f) precission=3.0f; + else precission=4.0f; + but->type = BFLOAT_TYPE; but->val.asfloat = ini; block = Get_uiBlock( ); if( block ) uiDefButF( block, NUM, event, name, (short)x, (short)y, (short)w, (short)h, - &but->val.asfloat, min, max, 0, 0, tip ); + &but->val.asfloat, min, max, 10*range, precission, tip ); } else { int ini, min, max; |