[Bf-blender-cvs] [36b55bee424] master: Fix T74649: Outliner: Cannot set/clear parent with 'Keep Transforms'

Philipp Oeser noreply at git.blender.org
Fri Mar 20 13:28:45 CET 2020


Commit: 36b55bee4247565b3e5a7237672bbdc2237447f0
Author: Philipp Oeser
Date:   Thu Mar 12 10:51:49 2020 +0100
Branches: master
https://developer.blender.org/rB36b55bee4247565b3e5a7237672bbdc2237447f0

Fix T74649: Outliner: Cannot set/clear parent with 'Keep Transforms'

Parenting in the outliner via drang and drop would always happen without
the 'Keep Transforms' option. Since this is often desired, this adds the
ability to hold Alt for doing this to the drop action.

Adding the hint to hold Alt to the operator name is not nice, but since
the operator name is used for the UI, there doesnt seem to be a nicer
way of doing this.

If modifier keys are needed back for other actions, spawning a menu
instead could be an alternative for the future.

Maniphest Tasks: T74649

Differential Revision: https://developer.blender.org/D7120

===================================================================

M	source/blender/editors/include/ED_object.h
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/space_outliner/outliner_dragdrop.c

===================================================================

diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index f532d7c1f14..3b38969d6bf 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -146,6 +146,12 @@ typedef enum eObjectSelect_Mode {
   BA_INVERT = 2,
 } eObjectSelect_Mode;
 
+typedef enum eObClearParentTypes {
+  CLEAR_PARENT_ALL = 0,
+  CLEAR_PARENT_KEEP_TRANSFORM,
+  CLEAR_PARENT_INVERSE,
+} eObClearParentTypes;
+
 #ifdef __RNA_TYPES_H__
 extern struct EnumPropertyItem prop_clear_parent_types[];
 extern struct EnumPropertyItem prop_make_parent_types[];
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 234cc119d6f..7c8a9750b36 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -487,12 +487,6 @@ void OBJECT_OT_proxy_make(wmOperatorType *ot)
 
 /********************** Clear Parent Operator ******************* */
 
-typedef enum eObClearParentTypes {
-  CLEAR_PARENT_ALL = 0,
-  CLEAR_PARENT_KEEP_TRANSFORM,
-  CLEAR_PARENT_INVERSE,
-} eObClearParentTypes;
-
 EnumPropertyItem prop_clear_parent_types[] = {
     {CLEAR_PARENT_ALL,
      "CLEAR",
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 32ead9e8c3f..8aeeef277f7 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -325,8 +325,12 @@ static bool parent_drop_poll(bContext *C,
   return false;
 }
 
-static void parent_drop_set_parents(
-    bContext *C, ReportList *reports, wmDragID *drag, Object *parent, short parent_type)
+static void parent_drop_set_parents(bContext *C,
+                                    ReportList *reports,
+                                    wmDragID *drag,
+                                    Object *parent,
+                                    short parent_type,
+                                    const bool keep_transform)
 {
   Main *bmain = CTX_data_main(C);
   SpaceOutliner *soops = CTX_wm_space_outliner(C);
@@ -357,7 +361,7 @@ static void parent_drop_set_parents(
       }
 
       if (ED_object_parent_set(
-              reports, C, scene, object, parent, parent_type, false, false, NULL)) {
+              reports, C, scene, object, parent, parent_type, false, keep_transform, NULL)) {
         parent_set = true;
       }
     }
@@ -400,7 +404,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
   ListBase *lb = event->customdata;
   wmDrag *drag = lb->first;
 
-  parent_drop_set_parents(C, op->reports, drag->ids.first, par, PAR_OBJECT);
+  parent_drop_set_parents(C, op->reports, drag->ids.first, par, PAR_OBJECT, event->alt);
 
   return OPERATOR_FINISHED;
 }
@@ -408,7 +412,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 void OUTLINER_OT_parent_drop(wmOperatorType *ot)
 {
   /* identifiers */
-  ot->name = "Drop to Set Parent";
+  ot->name = "Drop to Set Parent [+Alt keeps transforms]";
   ot->description = "Drag to parent in Outliner";
   ot->idname = "OUTLINER_OT_parent_drop";
 
@@ -481,7 +485,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
     if (GS(drag_id->id->name) == ID_OB) {
       Object *object = (Object *)drag_id->id;
 
-      ED_object_parent_clear(object, 0);
+      ED_object_parent_clear(object, event->alt ? CLEAR_PARENT_KEEP_TRANSFORM : CLEAR_PARENT_ALL);
     }
   }
 
@@ -494,7 +498,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
 void OUTLINER_OT_parent_clear(wmOperatorType *ot)
 {
   /* identifiers */
-  ot->name = "Drop to Clear Parent";
+  ot->name = "Drop to Clear Parent [+Alt keeps transforms]";
   ot->description = "Drag to clear parent in Outliner";
   ot->idname = "OUTLINER_OT_parent_clear";



More information about the Bf-blender-cvs mailing list