Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/interface/interface.c45
-rw-r--r--source/blender/makesrna/intern/rna_action.c4
-rw-r--r--source/blender/makesrna/intern/rna_rna.c6
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c2
-rw-r--r--source/blender/python/intern/bpy_props.c4
5 files changed, 54 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index a275a59a4e7..3c701cc403b 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -661,8 +661,43 @@ static float ui_but_get_float_precision(uiBut *but)
return but->a2;
}
+static float ui_but_get_float_step_size(uiBut *but)
+{
+ if (but->type == UI_BTYPE_NUM) {
+ return ((uiButNumber *)but)->step_size;
+ }
+
+ return but->a1;
+}
+
+static bool ui_but_hide_fraction(uiBut *but, double value)
+{
+ /* Hide the fraction if both the value and the step are exact integers. */
+ if (floor(value) == value) {
+ const float step = ui_but_get_float_step_size(but) * UI_PRECISION_FLOAT_SCALE;
+
+ if (floorf(step) == step) {
+ /* Don't hide if it has any unit except frame count. */
+ switch (UI_but_unit_type_get(but)) {
+ case PROP_UNIT_NONE:
+ case PROP_UNIT_TIME:
+ return true;
+
+ default:
+ return false;
+ }
+ }
+ }
+
+ return false;
+}
+
static int ui_but_calc_float_precision(uiBut *but, double value)
{
+ if (ui_but_hide_fraction(but, value)) {
+ return 0;
+ }
+
int prec = (int)ui_but_get_float_precision(but);
/* first check for various special cases:
@@ -2813,8 +2848,14 @@ void ui_but_string_get_ex(uiBut *but,
}
if (ui_but_is_float(but)) {
- int prec = (float_precision == -1) ? ui_but_calc_float_precision(but, value) :
- float_precision;
+ int prec = float_precision;
+
+ if (float_precision == -1) {
+ prec = ui_but_calc_float_precision(but, value);
+ }
+ else if (!use_exp_float && ui_but_hide_fraction(but, value)) {
+ prec = 0;
+ }
if (ui_but_is_unit(but)) {
ui_get_but_string_unit(but, str, maxlen, value, false, prec);
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index 96e37dfebbb..6b134977c5a 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -907,7 +907,7 @@ static void rna_def_action(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_float_sdna(prop, NULL, "frame_start");
RNA_def_property_float_funcs(prop, NULL, "rna_Action_start_frame_set", NULL);
- RNA_def_property_ui_range(prop, MINFRAME, MAXFRAME, 100, 0);
+ RNA_def_property_ui_range(prop, MINFRAME, MAXFRAME, 100, 2);
RNA_def_property_ui_text(
prop, "Start Frame", "The start frame of the manually set intended playback range");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
@@ -916,7 +916,7 @@ static void rna_def_action(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_float_sdna(prop, NULL, "frame_end");
RNA_def_property_float_funcs(prop, NULL, "rna_Action_end_frame_set", NULL);
- RNA_def_property_ui_range(prop, MINFRAME, MAXFRAME, 100, 0);
+ RNA_def_property_ui_range(prop, MINFRAME, MAXFRAME, 100, 2);
RNA_def_property_ui_text(
prop, "End Frame", "The end frame of the manually set intended playback range");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 285f6365ea1..37e7e5e6bed 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -3117,7 +3117,11 @@ static void rna_def_number_property(StructRNA *srna, PropertyType type)
prop = RNA_def_property(srna, "precision", PROP_INT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_FloatProperty_precision_get", NULL, NULL);
- RNA_def_property_ui_text(prop, "Precision", "Number of digits after the dot used by buttons");
+ RNA_def_property_ui_text(prop,
+ "Precision",
+ "Number of digits after the dot used by buttons. Fraction is "
+ "automatically hidden for exact integer values of fields with unit "
+ "'NONE' or 'TIME' (frame count) and step divisible by 100.");
}
}
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index a2db1536f55..2358d236c4d 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -672,7 +672,7 @@ static void rna_def_paint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Cavity Mask", "Mask painting according to mesh geometry cavity");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
- prop = RNA_def_property(srna, "tile_offset", PROP_FLOAT, PROP_XYZ);
+ prop = RNA_def_property(srna, "tile_offset", PROP_FLOAT, PROP_XYZ_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "tile_offset");
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.01, FLT_MAX);
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index ed9547ee13f..fe7183441d1 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -2609,7 +2609,9 @@ static int bpy_prop_arg_parse_tag_defines(PyObject *o, void *p)
" :type step: int\n"
#define BPY_PROPDEF_FLOAT_PREC_DOC \
- " :arg precision: Maximum number of decimal digits to display, in [0, 6].\n" \
+ " :arg precision: Maximum number of decimal digits to display, in [0, 6]. Fraction is " \
+ "automatically hidden for exact integer values of fields with unit 'NONE' or 'TIME' (frame " \
+ "count) and step divisible by 100.\n" \
" :type precision: int\n"
#define BPY_PROPDEF_UPDATE_DOC \