Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Context not available. | |||||
| block->bounds_type = UI_BLOCK_BOUNDS_NONE; | block->bounds_type = UI_BLOCK_BOUNDS_NONE; | ||||
| } | } | ||||
| static int ui_but_float_precision(uiBut *but, double value) | int ui_but_float_precision(uiBut *but, double value) | ||||
| { | { | ||||
| int prec = (int)but->a2; | int prec = (int)but->a2; | ||||
| Context not available. | |||||
| int tot_missing = 0; | int tot_missing = 0; | ||||
| /* only do it before bounding */ | /* only do it before bounding */ | ||||
| if (block->rect.xmin != block->rect.xmax) | if (block->rect.xmin != block->rect.xmax || block->flag & UI_BLOCK_VLADDER) | ||||
| return; | return; | ||||
| for (pass = 0; pass < 2; pass++) { | for (pass = 0; pass < 2; pass++) { | ||||
| Context not available. | |||||
| /** | /** | ||||
| * \param float_precision Override the button precision. | * \param float_precision Override the button precision. | ||||
| */ | */ | ||||
| static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, bool pad, int float_precision) | void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, bool pad, int float_precision) | ||||
| { | { | ||||
| UnitSettings *unit = but->block->unit; | UnitSettings *unit = but->block->unit; | ||||
| const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0; | const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0; | ||||
| Context not available. | |||||
| ui_get_but_string_ex(but, str, maxlen, -1); | ui_get_but_string_ex(but, str, maxlen, -1); | ||||
| } | } | ||||
| /** | |||||
| * Same as ui_get_but_string_ex, but returns \a str including its suffix (if available). | |||||
| */ | |||||
| void ui_get_but_string_suffixed_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision) | |||||
| { | |||||
| ui_get_but_string_ex(but, str, maxlen, float_precision); | |||||
| if (but->rnaprop) { | |||||
| PropertySubType pstype = RNA_property_subtype(but->rnaprop); | |||||
| const char *suffix = NULL; | |||||
| if (pstype == PROP_PERCENTAGE) | |||||
| suffix = "%"; | |||||
| else if (pstype == PROP_PIXEL) | |||||
| suffix = " px"; | |||||
| if (suffix) | |||||
| sprintf(str, "%s%s", str, suffix); | |||||
| } | |||||
| } | |||||
| void ui_get_but_string_suffixed(uiBut *but, char *str, const size_t maxlen) | |||||
| { | |||||
| ui_get_but_string_suffixed_ex(but, str, maxlen, -1); | |||||
| } | |||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| static bool ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *str, double *value) | static bool ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *str, double *value) | ||||
| Context not available. | |||||