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:
authorBastien Montagne <montagne29@wanadoo.fr>2014-01-08 20:04:10 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-01-08 20:05:05 +0400
commitd5c9b509ec0e06318186f25212ffb2ba12177692 (patch)
tree53df5a913b0e5d0c5f944bd9bd07ae752036b183 /source/blender/editors/util
parent8305fd8841440f4498758b6f218483cd6db363a9 (diff)
Fix issues with float precision in numinput, like 'R 123' who would show additional 'noise' digits.
Expose float precision helper in UI_interface.h API, so that numinput can use this helper as numbuttons already do. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D186
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r--source/blender/editors/util/numinput.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 2828973e91d..b9459d57f26 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -45,6 +45,7 @@
#endif
#include "ED_numinput.h"
+#include "UI_interface.h"
/* NumInput.val_flag[] */
@@ -80,13 +81,15 @@ void outputNumInput(NumInput *n, char *str)
{
short i, j;
const int ln = NUM_STR_REP_LEN;
- const int prec = 4; /* draw-only, and avoids too much issues with radian->degrees conversion. */
+ int prec = 2; /* draw-only, and avoids too much issues with radian->degrees conversion. */
for (j = 0; j <= n->idx_max; j++) {
/* if AFFECTALL and no number typed and cursor not on number, use first number */
i = (n->flag & NUM_AFFECT_ALL && n->idx != j && !(n->val_flag[j] & NUM_EDITED)) ? 0 : j;
if (n->val_flag[i] & NUM_EDITED) {
+ /* Get the best precision, allows us to draw '10.0001' as '10' instead! */
+ prec = uiFloatPrecisionCalc(prec, (double)n->val[i]);
if (i == n->idx) {
const char *heading_exp = "", *trailing_exp = "";
char before_cursor[NUM_STR_REP_LEN];