Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-06-07 06:39:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-06-07 06:39:40 +0400
commit34b0c217f8ded33146d5098f4b8a6426852f4476 (patch)
tree9c614c8e021f9f57afd765c3064fd49becdbd8da /source/blender/editors/interface
parent474d9c0274fa617ca137febb6c84892acb2cae6e (diff)
Move UI float precission calculation into its own function.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index c431af9fd8e..e94b90d8a29 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -449,6 +449,14 @@ void uiCenteredBoundsBlock(uiBlock *block, int addval)
/* link line drawing is not part of buttons or theme.. so we stick with it here */
+static int ui_but_float_precision(uiBut *but, double UNUSED(value))
+{
+ int prec= (int)but->a2;
+ if(prec==0) prec= (but->hardmax < 10.001f) ? 3 : 2;
+ else CLAMP(prec, 1, 7);
+ return prec;
+}
+
static void ui_draw_linkline(uiLinkLine *line)
{
rcti rect;
@@ -1530,10 +1538,7 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen)
ui_get_but_string_unit(but, str, maxlen, value, 0);
}
else {
- int prec= (int)but->a2;
- if(prec==0) prec= 3;
- else CLAMP(prec, 1, 7);
-
+ const int prec= ui_but_float_precision(but, value);
BLI_snprintf(str, maxlen, "%.*f", prec, value);
}
}
@@ -2009,10 +2014,7 @@ void ui_check_but(uiBut *but)
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str);
}
else {
- int prec= (int)but->a2;
- if(prec==0) prec= (but->hardmax < 10.001f) ? 3 : 2;
- else CLAMP(prec, 1, 7);
-
+ const int prec= ui_but_float_precision(but, value);
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
}
}
@@ -2030,11 +2032,9 @@ void ui_check_but(uiBut *but)
case LABEL:
if(ui_is_but_float(but)) {
- int prec= (int)but->a2;
+ int prec;
value= ui_get_but_val(but);
- if(prec==0) prec= 3;
- else CLAMP(prec, 1, 7);
-
+ prec= ui_but_float_precision(but, value);
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
}
else {