diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2019-07-31 22:14:29 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2019-07-31 22:17:33 +0300 |
commit | 77d7cc9ba7a9c23c269cb89e8f6da9c800558973 (patch) | |
tree | 8596abdc102a1b45990019f0bb9bb1a0e52c6d82 /source/blender/blenkernel/intern/unit.c | |
parent | a2f357edc2afb8f3ded60bc0e48c4015d6ad8f40 (diff) |
UI: Correct Spacing for Short Unit Names
This adds a space between a value and its short unit name except for foot, inch, degree, arcminute, arcsecond
Differential Revision: https://developer.blender.org/D5051
Reviewed by Brecht Van Lommel
Diffstat (limited to 'source/blender/blenkernel/intern/unit.c')
-rw-r--r-- | source/blender/blenkernel/intern/unit.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 7e7d5c82654..375721057c3 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -112,6 +112,8 @@ enum { B_UNIT_DEF_TENTH = 2, /** Short unit name is case sensitive, for example to distinguish mW and MW */ B_UNIT_DEF_CASE_SENSITIVE = 4, + /** Short unit name does not have space between it and preceding number */ + B_UNIT_DEF_NO_SPACE = 8, }; /* define a single unit */ @@ -161,8 +163,8 @@ static struct bUnitDef buImperialLenDef[] = { {"furlong", "furlongs", "fur", NULL, "Furlongs", "FURLONGS", UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, {"chain", "chains", "ch", NULL, "Chains", "CHAINS", UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, {"yard", "yards", "yd", NULL, "Yards", "YARDS", UN_SC_YD, 0.0, B_UNIT_DEF_SUPPRESS}, - {"foot", "feet", "'", "ft", "Feet", "FEET", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"inch", "inches", "\"", "in", "Inches", "INCHES", UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"foot", "feet", "'", "ft", "Feet", "FEET", UN_SC_FT, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_NO_SPACE}, /* base unit */ + {"inch", "inches", "\"", "in", "Inches", "INCHES", UN_SC_IN, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_NO_SPACE}, {"thou", "thou", "thou", "mil", "Thou", "THOU", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */ NULL_UNIT, }; @@ -289,10 +291,10 @@ static struct bUnitCollection buNaturalTimeCollection = {buNaturalTimeDef, 3, 0, static struct bUnitDef buNaturalRotDef[] = { - {"degree", "degrees", "°", "d", "Degrees", "DEGREES", M_PI / 180.0, 0.0, B_UNIT_DEF_NONE}, + {"degree", "degrees", "°", "d", "Degrees", "DEGREES", M_PI / 180.0, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_NO_SPACE}, /* arcminutes/arcseconds are used in Astronomy/Navigation areas... */ - {"arcminute", "arcminutes", "'", NULL, "Arcminutes", "ARCMINUTES", (M_PI / 180.0) / 60.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"arcsecond", "arcseconds", "\"", NULL, "Arcseconds", "ARCSECONDS", (M_PI / 180.0) / 3600.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"arcminute", "arcminutes", "'", NULL, "Arcminutes", "ARCMINUTES", (M_PI / 180.0) / 60.0, 0.0, B_UNIT_DEF_SUPPRESS | B_UNIT_DEF_NO_SPACE}, + {"arcsecond", "arcseconds", "\"", NULL, "Arcseconds", "ARCSECONDS", (M_PI / 180.0) / 3600.0, 0.0, B_UNIT_DEF_SUPPRESS | B_UNIT_DEF_NO_SPACE}, {"radian", "radians", "r", NULL, "Radians", "RADIANS", 1.0, 0.0, B_UNIT_DEF_NONE}, // {"turn", "turns", "t", NULL, "Turns", NULL, 1.0 / (M_PI * 2.0), 0.0, B_UNIT_DEF_NONE}, NULL_UNIT, @@ -451,6 +453,11 @@ static size_t unit_as_string(char *str, } } + /* Now add a space for all units except foot, inch, degree, arcminute, arcsecond */ + if (!(unit->flag & B_UNIT_DEF_NO_SPACE)) { + str[++i] = ' '; + } + /* Now add the suffix */ if (i < len_max) { int j = 0; |