From e4bbc590a44098f18dd2f828f4a8f43b1c26240f Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 21 Jun 2003 20:24:42 +0000 Subject: [PATCH] - added (old supposed) option for uiDefBut to define the amount of digits in NUM or NUMSLI buttons. It's the last but one argument... i really have to put the interface.c API doc back!!! :-) (get probably killed for the fact that i have it) --- source/blender/src/interface.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index f3f8f6aab26..7a2fee4c854 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -2250,7 +2250,13 @@ static int uiActAsTextBut(uiBut *but) value= ui_get_but_val(but); if( but->pointype==FLO ) { - sprintf(str, "%.3f", value); + if(but->a2) { /* amount of digits defined */ + if(but->a2==1) sprintf(str, "%.1f", value); + else if(but->a2==2) sprintf(str, "%.2f", value); + else if(but->a2==3) sprintf(str, "%.3f", value); + else sprintf(str, "%.4f", value); + } + else sprintf(str, "%.3f", value); } else { sprintf(str, "%d", (int)value); @@ -4008,8 +4014,16 @@ static void ui_check_but(uiBut *but) value= ui_get_but_val(but); if( but->pointype==FLO ) { - if(but->max<10.001) sprintf(but->drawstr, "%s%.3f", but->str, value); - else sprintf(but->drawstr, "%s%.2f", but->str, value); + if(but->a2) { /* amount of digits defined */ + if(but->a2==1) sprintf(but->drawstr, "%s%.1f", but->str, value); + else if(but->a2==2) sprintf(but->drawstr, "%s%.2f", but->str, value); + else if(but->a2==3) sprintf(but->drawstr, "%s%.3f", but->str, value); + else sprintf(but->drawstr, "%s%.4f", but->str, value); + } + else { + if(but->max<10.001) sprintf(but->drawstr, "%s%.3f", but->str, value); + else sprintf(but->drawstr, "%s%.2f", but->str, value); + } } else { sprintf(but->drawstr, "%s%d", but->str, (int)value);