Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Thu, 26 Jul 2018 04:49:52 +0000 (14:49 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 26 Jul 2018 04:49:52 +0000 (14:49 +1000)
1  2 
source/blender/editors/transform/transform_ops.c

index c9a97c8530cc9c4c386e36ccf44d3d6307a22b2d,f8e23c9744db418b375706b18b29d644f35b7ff9..5d930a8406bb4ef3486facc85522aa99be6a06e0
@@@ -45,7 -45,6 +45,7 @@@
  #include "RNA_enum_types.h"
  
  #include "WM_api.h"
 +#include "WM_message.h"
  #include "WM_types.h"
  
  #include "UI_interface.h"
@@@ -161,15 -160,11 +161,15 @@@ const EnumPropertyItem rna_enum_transfo
  
  static int select_orientation_exec(bContext *C, wmOperator *op)
  {
 +      Scene *scene = CTX_data_scene(C);
        int orientation = RNA_enum_get(op->ptr, "orientation");
  
 -      BIF_selectTransformOrientationValue(C, orientation);
 +      BIF_selectTransformOrientationValue(scene, orientation);
  
 -      WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
 +      WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
 +
 +      struct wmMsgBus *mbus = CTX_wm_message_bus(C);
 +      WM_msg_publish_rna_prop(mbus, &scene->id, scene, Scene, transform_orientation);
  
        return OPERATOR_FINISHED;
  }
@@@ -210,10 -205,13 +210,10 @@@ static void TRANSFORM_OT_select_orienta
  
  static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op))
  {
 -      View3D *v3d = CTX_wm_view3d(C);
 -      int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
 -
 -      BIF_removeTransformOrientationIndex(C, selected_index);
 +      Scene *scene = CTX_data_scene(C);
 +      BIF_removeTransformOrientationIndex(C, scene->orientation_index_custom);
  
 -      WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
 -      WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
 +      WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
  
        return OPERATOR_FINISHED;
  }
@@@ -225,12 -223,18 +225,12 @@@ static int delete_orientation_invoke(bC
  
  static bool delete_orientation_poll(bContext *C)
  {
 -      int selected_index = -1;
 -      View3D *v3d = CTX_wm_view3d(C);
 +      Scene *scene = CTX_data_scene(C);
  
        if (ED_operator_areaactive(C) == 0)
                return 0;
  
 -
 -      if (v3d) {
 -              selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
 -      }
 -
 -      return selected_index >= 0;
 +      return (scene->orientation_type >= V3D_MANIP_CUSTOM) && (scene->orientation_index_custom != -1);
  }
  
  static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot)
@@@ -285,9 -289,6 +285,9 @@@ static void TRANSFORM_OT_create_orienta
        RNA_def_string(ot->srna, "name", NULL, MAX_NAME, "Name", "Name of the new custom orientation");
        RNA_def_boolean(ot->srna, "use_view", false, "Use View",
                        "Use the current view instead of the active object to create the new orientation");
 +
 +      WM_operatortype_props_advanced_begin(ot);
 +
        RNA_def_boolean(ot->srna, "use", false, "Use after creation", "Select orientation after its creation");
        RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite previous",
                        "Overwrite previously created orientation with same name");
@@@ -318,8 -319,7 +318,8 @@@ static void transformops_loopsel_hack(b
  
                                /* still switch if we were originally in face select mode */
                                if ((ts->selectmode != selectmode_orig) && (selectmode_orig != SCE_SELECT_FACE)) {
 -                                      BMEditMesh *em = BKE_editmesh_from_object(scene->obedit);
 +                                      Object *obedit = CTX_data_edit_object(C);
 +                                      BMEditMesh *em = BKE_editmesh_from_object(obedit);
                                        em->selectmode = ts->selectmode = selectmode_orig;
                                        EDBM_selectmode_set(em);
                                }
@@@ -483,30 -483,37 +483,49 @@@ static int transform_invoke(bContext *C
                return OPERATOR_CANCELLED;
        }
  
 -      if (RNA_struct_property_is_set(op->ptr, "value")) {
 +      /* When modal, allow 'value' to set initial offset. */
 +      if ((event == NULL) &&
 +          RNA_struct_property_is_set(op->ptr, "value"))
 +      {
                return transform_exec(C, op);
        }
        else {
                /* add temp handler */
                WM_event_add_modal_handler(C, op);
  
 -              op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the manipulator only?
 +              op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the gizmo only?
 +
 +              /* Use when modal input has some transformation to begin with. */
 +              {
 +                      TransInfo *t = op->customdata;
 +                      if (UNLIKELY(!is_zero_v4(t->values_modal_offset))) {
 +                              transformApply(C, t);
 +                      }
 +              }
 +
                return OPERATOR_RUNNING_MODAL;
        }
  }
  
+ 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;
        if (flags & P_PROPORTIONAL) {
                RNA_def_enum(ot->srna, "proportional", rna_enum_proportional_editing_items, 0, "Proportional Editing", "");
                prop = RNA_def_enum(ot->srna, "proportional_edit_falloff", rna_enum_proportional_falloff_items, 0,
 -                                  "Proportional Editing Falloff", "Falloff type for proportional editing mode");
 +                                  "Proportional Falloff", "Falloff type for proportional editing mode");
                RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
                RNA_def_float(ot->srna, "proportional_size", 1, T_PROP_SIZE_MIN, T_PROP_SIZE_MAX,
                              "Proportional Size", "", 0.001f, 100.0f);
        }
  
        if (flags & P_GPENCIL_EDIT) {
 -              RNA_def_boolean(ot->srna, "gpencil_strokes", 0, "Edit Grease Pencil", "Edit selected Grease Pencil strokes");
 +              prop = RNA_def_boolean(ot->srna, "gpencil_strokes", 0, "Edit Grease Pencil", "Edit selected Grease Pencil strokes");
 +              RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
 +      }
 +
 +      if (flags & P_CURSOR_EDIT) {
 +              prop = RNA_def_boolean(ot->srna, "cursor_transform", 0, "Transform Cursor", "");
 +              RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
        }
  
        if ((flags & P_OPTIONS) && !(flags & P_NO_TEXSPACE)) {
 -              RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
 +              prop = RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
 +              RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
                prop = RNA_def_boolean(ot->srna, "remove_on_cancel", 0, "Remove on Cancel", "Remove elements on cancel");
 -              RNA_def_property_flag(prop, PROP_HIDDEN);
 +              RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
        }
  
        if (flags & P_CORRECT_UV) {
 -              RNA_def_boolean(ot->srna, "correct_uv", 0, "Correct UVs", "Correct UV coordinates when transforming");
 +              RNA_def_boolean(ot->srna, "correct_uv", true, "Correct UVs", "Correct UV coordinates when transforming");
        }
  
        if (flags & P_CENTER) {
 -              /* For manipulators that define their own center. */
 +              /* For gizmos that define their own center. */
                prop = RNA_def_property(ot->srna, "center_override", PROP_FLOAT, PROP_XYZ);
                RNA_def_property_array(prop, 3);
                RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
@@@ -615,15 -615,11 +634,16 @@@ static void TRANSFORM_OT_translate(stru
        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);
  
 -      Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS | P_GPENCIL_EDIT);
 +      WM_operatortype_props_advanced_begin(ot);
 +
 +      Transform_Properties(
 +              ot,
 +              P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS |
 +              P_GPENCIL_EDIT | P_CURSOR_EDIT);
  }
  
  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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(
                ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS | P_GPENCIL_EDIT | P_CENTER);
  }
@@@ -673,11 -668,10 +694,12 @@@ static void TRANSFORM_OT_skin_resize(st
        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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS | P_NO_TEXSPACE);
  }
  
@@@ -695,12 -689,11 +717,13 @@@ static void TRANSFORM_OT_trackball(stru
        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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
  }
  
@@@ -718,11 -711,10 +741,12 @@@ static void TRANSFORM_OT_rotate(struct 
        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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(
                ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_GPENCIL_EDIT | P_CENTER);
  }
@@@ -744,11 -736,10 +768,12 @@@ static void TRANSFORM_OT_tilt(struct wm
        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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
  }
  
@@@ -766,11 -757,10 +791,12 @@@ static void TRANSFORM_OT_bend(struct wm
        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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
  }
  
@@@ -788,11 -778,10 +814,12 @@@ static void TRANSFORM_OT_shear(struct w
        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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT);
        // XXX Shear axis?
  }
@@@ -811,11 -800,10 +838,12 @@@ static void TRANSFORM_OT_push_pull(stru
        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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_CENTER);
  }
  
@@@ -833,13 -821,12 +861,14 @@@ static void TRANSFORM_OT_shrink_fatten(
        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);
  
        RNA_def_boolean(ot->srna, "use_even_offset", true, "Offset Even", "Scale the offset to give more even thickness");
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
  }
  
@@@ -858,11 -845,10 +887,12 @@@ static void TRANSFORM_OT_tosphere(struc
        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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
  }
  
@@@ -880,6 -866,7 +910,7 @@@ static void TRANSFORM_OT_mirror(struct 
        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 -887,7 +931,7 @@@ static void TRANSFORM_OT_edge_slide(str
        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_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
        RNA_def_boolean(ot->srna, "use_even", false, "Even",
                        "Make the edge loop match the shape of the adjacent edge loop");
 +
 +      WM_operatortype_props_advanced_begin(ot);
 +
        RNA_def_boolean(ot->srna, "flipped", false, "Flipped",
                        "When Even mode is active, flips between the two adjacent edge loops");
        RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp",
@@@ -932,13 -917,11 +964,14 @@@ static void TRANSFORM_OT_vert_slide(str
        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",
                        "Make the edge loop match the shape of the adjacent edge loop");
 +
 +      WM_operatortype_props_advanced_begin(ot);
 +
        RNA_def_boolean(ot->srna, "flipped", false, "Flipped",
                        "When Even mode is active, flips between the two adjacent edge loops");
        RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp",
@@@ -961,11 -944,10 +994,12 @@@ static void TRANSFORM_OT_edge_crease(st
        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);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_SNAP);
  }
  
@@@ -1007,8 -989,6 +1041,8 @@@ static void TRANSFORM_OT_edge_bevelweig
  
        RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_SNAP);
  }
  
@@@ -1029,8 -1009,6 +1063,8 @@@ static void TRANSFORM_OT_seq_slide(stru
  
        RNA_def_float_vector_xyz(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(ot, P_SNAP);
  }
  
@@@ -1050,14 -1028,13 +1084,15 @@@ static void TRANSFORM_OT_transform(stru
        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);
  
        RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
  
 +      WM_operatortype_props_advanced_begin(ot);
 +
        Transform_Properties(
                ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_GPENCIL_EDIT | P_CENTER);
  }
@@@ -1113,28 -1090,23 +1148,28 @@@ void transform_keymap_for_space(wmKeyCo
  
                        WM_keymap_add_item(keymap, "TRANSFORM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0);
  
 +#ifdef USE_WM_KEYMAP_27X
                        kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
                        RNA_boolean_set(kmi->ptr, "use", true);
 +#endif
  
                        WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0);
  
                        kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
                        RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
  
 -                      kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
 -                      RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_element");
 +                      WM_keymap_add_panel(keymap, "VIEW3D_PT_snapping", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
  
 +                      /* Will fall-through to texture-space transform. */
 +                      kmi = WM_keymap_add_item(keymap, "OBJECT_OT_transform_axis_target", TKEY, KM_PRESS, KM_SHIFT, 0);
  
 +#ifdef USE_WM_KEYMAP_27X
                        kmi = WM_keymap_add_item(keymap, OP_TRANSLATION, TKEY, KM_PRESS, KM_SHIFT, 0);
                        RNA_boolean_set(kmi->ptr, "texture_space", true);
  
                        kmi = WM_keymap_add_item(keymap, OP_RESIZE, TKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
                        RNA_boolean_set(kmi->ptr, "texture_space", true);
 +#endif
  
                        WM_keymap_add_item(keymap, OP_SKIN_RESIZE, AKEY, KM_PRESS, KM_CTRL, 0);