Cleanup: match call signature for UI unit number evaluation
Also rename ui_but_string_set_eval_num to ui_but_string_eval_number as it doesn't set any of the buttons values.
This commit is contained in:
@@ -2800,25 +2800,33 @@ char *ui_but_string_get_dynamic(uiBut *but, int *r_str_size)
|
||||
return str;
|
||||
}
|
||||
|
||||
static bool ui_set_but_string_eval_num_unit(bContext *C,
|
||||
uiBut *but,
|
||||
const char *str,
|
||||
double *r_value)
|
||||
static bool ui_number_from_string_units(
|
||||
bContext *C, const char *str, const int unit_type, const UnitSettings *unit, double *r_value)
|
||||
{
|
||||
return user_string_to_number(C, str, unit, unit_type, r_value);
|
||||
}
|
||||
|
||||
static bool ui_number_from_string_units_with_but(bContext *C,
|
||||
const char *str,
|
||||
const uiBut *but,
|
||||
double *r_value)
|
||||
{
|
||||
const int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
|
||||
const UnitSettings *unit = but->block->unit;
|
||||
int type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
|
||||
return user_string_to_number(C, str, unit, type, r_value);
|
||||
return ui_number_from_string_units(C, str, unit_type, unit, r_value);
|
||||
}
|
||||
|
||||
static bool ui_number_from_string(bContext *C, const char *str, double *r_value)
|
||||
{
|
||||
bool ok;
|
||||
#ifdef WITH_PYTHON
|
||||
return BPY_execute_string_as_number(C, NULL, str, true, r_value);
|
||||
ok = BPY_execute_string_as_number(C, NULL, str, true, r_value);
|
||||
#else
|
||||
UNUSED_VARS(C);
|
||||
*r_value = atof(str);
|
||||
return true;
|
||||
ok = true;
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
|
||||
static bool ui_number_from_string_factor(bContext *C, const char *str, double *r_value)
|
||||
@@ -2852,7 +2860,7 @@ static bool ui_number_from_string_percentage(bContext *C, const char *str, doubl
|
||||
return ui_number_from_string(C, str, r_value);
|
||||
}
|
||||
|
||||
bool ui_but_string_set_eval_num(bContext *C, uiBut *but, const char *str, double *r_value)
|
||||
bool ui_but_string_eval_number(bContext *C, const uiBut *but, const char *str, double *r_value)
|
||||
{
|
||||
if (str[0] == '\0') {
|
||||
*r_value = 0.0;
|
||||
@@ -2866,7 +2874,7 @@ bool ui_but_string_set_eval_num(bContext *C, uiBut *but, const char *str, double
|
||||
|
||||
if (ui_but_is_float(but)) {
|
||||
if (ui_but_is_unit(but)) {
|
||||
return ui_set_but_string_eval_num_unit(C, but, str, r_value);
|
||||
return ui_number_from_string_units_with_but(C, str, but, r_value);
|
||||
}
|
||||
if (subtype == PROP_FACTOR) {
|
||||
return ui_number_from_string_factor(C, str, r_value);
|
||||
@@ -3006,7 +3014,7 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
|
||||
/* number editing */
|
||||
double value;
|
||||
|
||||
if (ui_but_string_set_eval_num(C, but, str, &value) == false) {
|
||||
if (ui_but_string_eval_number(C, but, str, &value) == false) {
|
||||
WM_report_banner_show();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2364,7 +2364,7 @@ static void ui_but_paste_numeric_value(bContext *C,
|
||||
{
|
||||
double value;
|
||||
|
||||
if (ui_but_string_set_eval_num(C, but, buf_paste, &value)) {
|
||||
if (ui_but_string_eval_number(C, but, buf_paste, &value)) {
|
||||
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
|
||||
data->value = value;
|
||||
ui_but_string_set(C, but, buf_paste);
|
||||
|
||||
@@ -517,10 +517,10 @@ extern void ui_but_string_get(uiBut *but, char *str, const size_t maxlen) ATTR_N
|
||||
extern char *ui_but_string_get_dynamic(uiBut *but, int *r_str_size);
|
||||
extern void ui_but_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen) ATTR_NONNULL();
|
||||
extern bool ui_but_string_set(struct bContext *C, uiBut *but, const char *str) ATTR_NONNULL();
|
||||
extern bool ui_but_string_set_eval_num(struct bContext *C,
|
||||
uiBut *but,
|
||||
const char *str,
|
||||
double *value) ATTR_NONNULL();
|
||||
extern bool ui_but_string_eval_number(struct bContext *C,
|
||||
const uiBut *but,
|
||||
const char *str,
|
||||
double *value) ATTR_NONNULL();
|
||||
extern int ui_but_string_get_max_length(uiBut *but);
|
||||
/* Clear & exit the active button's string. */
|
||||
extern void ui_but_active_string_clear_and_exit(struct bContext *C, uiBut *but) ATTR_NONNULL();
|
||||
|
||||
Reference in New Issue
Block a user