diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-04-24 19:17:55 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-04-24 19:31:14 +0400 |
commit | d12ceec40146f98b6d584a6ea276ab77834d816e (patch) | |
tree | 6633f13763cf5bc099326a5b3c733163278ca6f6 /source/blender/editors/interface | |
parent | adf1834ede0f234c60ee990daaa32f40e32f3b41 (diff) |
Fix T39861: UI destroys float precision.
Note this is only a workaround in fact, adding some precision in radians case.
Validating the field will still generate a precision loss (doing otherwise is
doable-ish, but likely to backfire and/or add too much complexity in an already
complex area).
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2cf2a46529e..6e1398549a6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -98,6 +98,19 @@ bool ui_block_is_menu(const uiBlock *block) ((block->flag & UI_BLOCK_KEEP_OPEN) == 0)); } +static bool ui_is_but_unit_radians_ex(UnitSettings *unit, const int unit_type) +{ + return (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION); +} + +static bool ui_is_but_unit_radians(const uiBut *but) +{ + UnitSettings *unit = but->block->unit; + const int unit_type = uiButGetUnitType(but); + + return ui_is_but_unit_radians_ex(unit, unit_type); +} + /* ************* window matrix ************** */ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y) @@ -429,10 +442,15 @@ void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int max static int ui_but_float_precision(uiBut *but, double value) { - int prec; + int prec = (int)but->a2; - /* first check if prec is 0 and fallback to a simple default */ - if ((prec = (int)but->a2) == -1) { + /* first check for various special cases: + * * If button is radians, we want additional precision (see T39861). + * * If prec is not set, we fallback to a simple default */ + if (ui_is_but_unit_radians(but) && prec < 5) { + prec = 5; + } + else if (prec == -1) { prec = (but->hardmax < 10.001f) ? 3 : 2; } @@ -1611,7 +1629,7 @@ bool ui_is_but_unit(const uiBut *but) return false; #if 1 /* removed so angle buttons get correct snapping */ - if (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) + if (ui_is_but_unit_radians_ex(unit, unit_type)) return false; #endif |