diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-22 15:23:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-22 15:23:05 +0400 |
commit | 3406bafc59220a592c2e0d68a1f6a6b348a2212e (patch) | |
tree | 91b426f68c12acfb2e7296e7fb625683ec9b12c3 /source/blender/makesrna | |
parent | e11d22a6b751c750c40226cb027e7805adb7d4e4 (diff) |
comments for RNA_def_property_ui_range() and clamp some out-of-range values.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 24 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer.c | 8 |
4 files changed, 31 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index ac307139860..4e6c3748230 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1210,6 +1210,15 @@ void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive) prop->flag |= PROP_ICONS_CONSECUTIVE; } +/** + * The values hare are a little confusing: + * + * \param step For floats this is (step / 100), why /100? - nobody knows. + * for int's, whole values are used. + * + * \param precision The number of zeros to show + * (as a whole number - common range is 1 - 6), see PRECISION_FLOAT_MAX + */ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision) { StructRNA *srna = DefRNA.laststruct; @@ -1230,6 +1239,21 @@ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double fprop->softmax = (float)max; fprop->step = (float)step; fprop->precision = (int)precision; +#if 0 /* handy but annoying */ + if (DefRNA.preprocess) { + /* check we're not over PRECISION_FLOAT_MAX */ + if (fprop->precision > 6) { + fprintf(stderr, "%s: \"%s.%s\", precision value over maximum.\n", + __func__, srna->identifier, prop->identifier); + DefRNA.error = 1; + } + else if (fprop->precision < 1) { + fprintf(stderr, "%s: \"%s.%s\", precision value under minimum.\n", + __func__, srna->identifier, prop->identifier); + DefRNA.error = 1; + } + } +#endif break; } default: diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 0d88cbf2f27..825cd1ff19a 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1852,14 +1852,14 @@ static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna) prop = RNA_def_property(srna, "lambda_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "lambda"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); - RNA_def_property_ui_range(prop, -1000.0, 1000.0, 0.0000001, 8); + RNA_def_property_ui_range(prop, -1000.0, 1000.0, 0.0000001, 6); RNA_def_property_ui_text(prop, "Lambda Factor", "Smooth factor effect"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "lambda_border", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "lambda_border"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); - RNA_def_property_ui_range(prop, -1000.0, 1000.0, 0.0000001, 8); + RNA_def_property_ui_range(prop, -1000.0, 1000.0, 0.0000001, 6); RNA_def_property_ui_text(prop, "Lambda Border", "Lambda factor in border"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 0b3fa569d4a..bbacc4487c3 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3709,7 +3709,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "blurfac"); - RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 0); + RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 1); RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index a41551fc8da..c408b917347 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -2058,13 +2058,13 @@ static void rna_def_transform(StructRNA *srna) prop = RNA_def_property(srna, "scale_start_x", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScalexIni"); RNA_def_property_ui_text(prop, "Scale X", ""); - RNA_def_property_ui_range(prop, 0, 10, 3, 10); + RNA_def_property_ui_range(prop, 0, 10, 3, 6); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "scale_start_y", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScaleyIni"); RNA_def_property_ui_text(prop, "Scale Y", ""); - RNA_def_property_ui_range(prop, 0, 10, 3, 10); + RNA_def_property_ui_range(prop, 0, 10, 3, 6); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_uniform_scale", PROP_BOOLEAN, PROP_NONE); @@ -2075,13 +2075,13 @@ static void rna_def_transform(StructRNA *srna) prop = RNA_def_property(srna, "translate_start_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xIni"); RNA_def_property_ui_text(prop, "Translate X", ""); - RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); + RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 6); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "translate_start_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yIni"); RNA_def_property_ui_text(prop, "Translate Y", ""); - RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); + RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 6); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "rotation_start", PROP_FLOAT, PROP_NONE); |