diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-08-12 11:23:10 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-08-12 11:23:10 +0400 |
commit | 63b276efbfa814e813692b1a8d6cb0ddda08bf93 (patch) | |
tree | 1794d2ae484d8508203ff557f1c5f60814fff6be /source/blender/editors/interface/interface.c | |
parent | d1085715a3b52bc31176a6accfa0b4838d99c2ab (diff) |
- was displaying 1cm as 10mm because of double precission problem.
- typing in numbers without any units will use the units displayed before editing the value.
- fixed some errors
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r-- | source/blender/editors/interface/interface.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 0451cd69dff..878f1bef5cf 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1327,14 +1327,14 @@ static double ui_get_but_scale_unit(uiBut *but, double value) static void ui_get_but_string_unit(uiBut *but, char *str, double value, int pad) { int do_split= U.unit_flag & USER_UNIT_OPT_SPLIT ? 1:0; - int unit_system= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); int precission= but->a2; /* Sanity checks */ if(precission>4) precission= 4; else if(precission==0) precission= 2; - bUnit_AsString(str, ui_get_but_scale_unit(but, value), precission, U.unit_system, unit_system, do_split, pad); + bUnit_AsString(str, ui_get_but_scale_unit(but, value), precission, U.unit_system, unit_type, do_split, pad); } @@ -1473,9 +1473,11 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) #ifndef DISABLE_PYTHON { char str_unit_convert[256]; - int change= -1; - if(U.unit_system != USER_UNIT_NONE) { - bUnit_ReplaceString(str_unit_convert, str, ui_get_but_scale_unit(but, 1.0), U.unit_system, RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop))); + int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + + if(U.unit_system != USER_UNIT_NONE && unit_type) { + /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ + bUnit_ReplaceString(str_unit_convert, str, but->drawstr, ui_get_but_scale_unit(but, 1.0), U.unit_system, unit_type); } else { strcpy(str_unit_convert, str); |