UI: Fix incorrect RNA percentage property definitions

In two cases the percentage property was actually used incorrectly, as
pointed out in T82070. The range was [0, 1], but the properties were still
displayed as percentages.

There is a preference to control whether to display factors or
percentages, so it usually doesn't make sense to manually define
properties as percentages.

Resolves T82070

Differential Revision: https://developer.blender.org/D9344
This commit is contained in:
Hans Goudey 2021-01-27 11:19:54 -06:00
parent 0e39c526d8
commit c71a8e8376
Notes: blender-bot 2023-02-14 03:31:57 +01:00
Referenced by issue #89027, After applying the Pose Breakdowner, the Factor in the popup menu does not work.
Referenced by issue #82070, Ratio displayed with a % sign in the Decimate Keyframes Adjust Last Operation panel.
10 changed files with 34 additions and 34 deletions

View File

@ -1246,15 +1246,15 @@ static void pose_slide_opdef_properties(wmOperatorType *ot)
{
PropertyRNA *prop;
prop = RNA_def_float_percentage(ot->srna,
"percentage",
0.5f,
0.0f,
1.0f,
"Percentage",
"Weighting factor for which keyframe is favored more",
0.0,
1.0);
prop = RNA_def_float_factor(ot->srna,
"factor",
0.5f,
0.0f,
1.0f,
"Factor",
"Weighting factor for which keyframe is favored more",
0.0,
1.0);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_int(ot->srna,

View File

@ -1242,7 +1242,7 @@ static void curve_select_random(ListBase *editnurb, float randfac, int seed, boo
static int curve_select_random_exec(bContext *C, wmOperator *op)
{
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const float randfac = RNA_float_get(op->ptr, "ratio");
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
ViewLayer *view_layer = CTX_data_view_layer(C);

View File

@ -734,7 +734,7 @@ void GPENCIL_OT_interpolate(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
/* properties */
RNA_def_float_percentage(
RNA_def_float_factor(
ot->srna,
"shift",
0.0f,

View File

@ -108,7 +108,7 @@ bool ED_lattice_deselect_all_multi(struct bContext *C)
static int lattice_select_random_exec(bContext *C, wmOperator *op)
{
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const float randfac = RNA_float_get(op->ptr, "ratio");
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);

View File

@ -4573,7 +4573,7 @@ void MESH_OT_select_non_manifold(wmOperatorType *ot)
static int edbm_select_random_exec(bContext *C, wmOperator *op)
{
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const float randfac = RNA_float_get(op->ptr, "ratio");
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
ViewLayer *view_layer = CTX_data_view_layer(C);

View File

@ -483,7 +483,7 @@ void MBALL_OT_select_similar(wmOperatorType *ot)
static int select_random_metaelems_exec(bContext *C, wmOperator *op)
{
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const float randfac = RNA_float_get(op->ptr, "ratio");
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
ViewLayer *view_layer = CTX_data_view_layer(C);

View File

@ -1453,7 +1453,7 @@ void OBJECT_OT_select_less(wmOperatorType *ot)
static int object_select_random_exec(bContext *C, wmOperator *op)
{
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const float randfac = RNA_float_get(op->ptr, "ratio");
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);

View File

@ -1999,7 +1999,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
int p;
int k;
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const float randfac = RNA_float_get(op->ptr, "ratio");
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
RNG *rng;

View File

@ -505,15 +505,15 @@ void GRAPH_OT_decimate(wmOperatorType *ot)
"Mode",
"Which mode to use for decimation");
RNA_def_float_percentage(ot->srna,
"remove_ratio",
1.0f / 3.0f,
0.0f,
1.0f,
"Remove",
"The percentage of keyframes to remove",
0.0f,
1.0f);
RNA_def_float_factor(ot->srna,
"remove_ratio",
1.0f / 3.0f,
0.0f,
1.0f,
"Remove",
"The ratio of remaining keyframes after the operation",
0.0f,
1.0f);
RNA_def_float(ot->srna,
"remove_error_margin",
0.0f,

View File

@ -284,15 +284,15 @@ void WM_operator_properties_select_action_simple(wmOperatorType *ot,
*/
void WM_operator_properties_select_random(wmOperatorType *ot)
{
RNA_def_float_percentage(ot->srna,
"percent",
50.0f,
0.0f,
100.0f,
"Percent",
"Percentage of objects to select randomly",
0.0f,
100.0f);
RNA_def_float_factor(ot->srna,
"ratio",
0.5f,
0.0f,
1.0f,
"Ratio",
"Portion of items to select randomly",
0.f,
1.0f);
RNA_def_int(ot->srna,
"seed",
0,