skip creating the draw-string for number buttons while editing the text (value was overwritten)

This commit is contained in:
Campbell Barton 2013-07-25 13:24:32 +00:00
parent 55640288d2
commit aed11512fc

@ -2426,35 +2426,37 @@ void ui_check_but(uiBut *but)
case NUM: case NUM:
case NUMSLI: case NUMSLI:
UI_GET_BUT_VALUE_INIT(but, value); if (!but->editstr) {
UI_GET_BUT_VALUE_INIT(but, value);
if (ui_is_but_float(but)) { if (ui_is_but_float(but)) {
if (value == (double) FLT_MAX) { if (value == (double) FLT_MAX) {
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str);
} }
else if (value == (double) -FLT_MAX) { else if (value == (double) -FLT_MAX) {
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str);
} }
/* support length type buttons */ /* support length type buttons */
else if (ui_is_but_unit(but)) { else if (ui_is_but_unit(but)) {
char new_str[sizeof(but->drawstr)]; char new_str[sizeof(but->drawstr)];
ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE, -1); ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE, -1);
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str);
}
else {
const int prec = ui_but_float_precision(but, value);
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
}
} }
else { else {
const int prec = ui_but_float_precision(but, value); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%d", but->str, (int)value);
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
} }
}
else {
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%d", but->str, (int)value);
}
if (but->rnaprop) { if (but->rnaprop) {
PropertySubType pstype = RNA_property_subtype(but->rnaprop); PropertySubType pstype = RNA_property_subtype(but->rnaprop);
if (pstype == PROP_PERCENTAGE) if (pstype == PROP_PERCENTAGE)
strcat(but->drawstr, "%"); strcat(but->drawstr, "%");
}
} }
break; break;