Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / transform / transform_ops.c
index c9a97c8530cc9c4c386e36ccf44d3d6307a22b2d..5d930a8406bb4ef3486facc85522aa99be6a06e0 100644 (file)
@@ -507,6 +507,25 @@ static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event)
        }
 }
 
+static bool transform_poll_property(const bContext *UNUSED(C), wmOperator *op, const PropertyRNA *prop)
+{
+       const char *prop_id = RNA_property_identifier(prop);
+
+       /* Proportional Editing. */
+       {
+               PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "proportional");
+               if (prop_pet && (prop_pet != prop) &&
+                   (RNA_property_enum_get(op->ptr, prop_pet) == PROP_EDIT_OFF))
+               {
+                       if (STRPREFIX(prop_id, "proportional")) {
+                               return false;
+                       }
+               }
+       }
+
+       return true;
+}
+
 void Transform_Properties(struct wmOperatorType *ot, int flags)
 {
        PropertyRNA *prop;
@@ -615,6 +634,7 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_screenactive;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
 
@@ -640,6 +660,7 @@ static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_screenactive;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
 
@@ -673,6 +694,7 @@ static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = skin_resize_poll;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
 
@@ -695,6 +717,7 @@ static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_screenactive;
+       ot->poll_property = transform_poll_property;
 
        /* Maybe we could use float_vector_xyz here too? */
        RNA_def_float_rotation(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX);
@@ -718,6 +741,7 @@ static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_screenactive;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_rotation(ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
 
@@ -744,6 +768,7 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_editcurve_3d;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_rotation(ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
 
@@ -766,6 +791,7 @@ static void TRANSFORM_OT_bend(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_region_view3d_active;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
 
@@ -788,6 +814,7 @@ static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_screenactive;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
 
@@ -811,6 +838,7 @@ static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_screenactive;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX);
 
@@ -833,6 +861,7 @@ static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_editmesh;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
 
@@ -858,6 +887,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_screenactive;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1);
 
@@ -880,6 +910,7 @@ static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_screenactive;
+       ot->poll_property = transform_poll_property;
 
        Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_GPENCIL_EDIT | P_CENTER);
 }
@@ -900,6 +931,7 @@ static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_editmesh_region_view3d;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f);
 
@@ -932,6 +964,7 @@ static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_editmesh_region_view3d;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f);
        RNA_def_boolean(ot->srna, "use_even", false, "Even",
@@ -961,6 +994,7 @@ static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_editmesh;
+       ot->poll_property = transform_poll_property;
 
        RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
 
@@ -1050,6 +1084,7 @@ static void TRANSFORM_OT_transform(struct wmOperatorType *ot)
        ot->modal  = transform_modal;
        ot->cancel = transform_cancel;
        ot->poll   = ED_operator_screenactive;
+       ot->poll_property = transform_poll_property;
 
        prop = RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
        RNA_def_property_flag(prop, PROP_HIDDEN);