Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / interface / interface.c
index 1ce5b08c522ea1b87d0c86989890a86509254f97..10668c9ea2257522d3bed51fef9c31c0eb121dc8 100644 (file)
@@ -1936,13 +1936,14 @@ void ui_but_value_set(uiBut *but, double value)
        else {
                /* first do rounding */
                if (but->pointype == UI_BUT_POIN_CHAR) {
-                       value = (char)floor(value + 0.5);
+                       value = round_db_to_uchar_clamp(value);
                }
                else if (but->pointype == UI_BUT_POIN_SHORT) {
-                       value = (short)floor(value + 0.5);
+                       value = round_db_to_short_clamp(value);
+               }
+               else if (but->pointype == UI_BUT_POIN_INT) {
+                       value = round_db_to_int_clamp(value);
                }
-               else if (but->pointype == UI_BUT_POIN_INT)
-                       value = (int)floor(value + 0.5);
                else if (but->pointype == UI_BUT_POIN_FLOAT) {
                        float fval = (float)value;
                        if (fval >= -0.00001f && fval <= 0.00001f) fval = 0.0f;  /* prevent negative zero */