[Bf-blender-cvs] [5b67f7a959e] blender2.8: Outliner: Implement Add (Ctrl) when moving objects inside collection

Dalai Felinto noreply at git.blender.org
Fri Jan 26 11:33:18 CET 2018


Commit: 5b67f7a959e4f01c95ed3576a3b4683bd63f67e8
Author: Dalai Felinto
Date:   Thu Jan 25 12:42:20 2018 -0200
Branches: blender2.8
https://developer.blender.org/rB5b67f7a959e4f01c95ed3576a3b4683bd63f67e8

Outliner: Implement Add (Ctrl) when moving objects inside collection

Note there is no "text" explaining to users what is going on.
I will address this shortly in an upcoming commit.

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

M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_ops.c
M	source/blender/editors/space_outliner/outliner_tree.c

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

diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 9bc24e65941..1be709415e8 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -48,6 +48,7 @@ struct ID;
 struct Object;
 struct bPoseChannel;
 struct EditBone;
+struct wmEvent;
 struct wmKeyConfig;
 
 
@@ -72,7 +73,9 @@ typedef enum TreeTraversalAction {
 typedef void (*TreeElementReinsertFunc)(struct Main *bmain,
                                         struct SpaceOops *soops,
                                         struct TreeElement *insert_element,
-                                        struct TreeElement *insert_handle, TreeElementInsertType action);
+                                        struct TreeElement *insert_handle,
+                                        TreeElementInsertType action,
+                                        const struct wmEvent *event);
 /**
  * Executed on (almost) each mouse move while dragging. It's supposed to give info
  * if reinserting insert_element before/after/into insert_handle would be allowed.
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 3dc6beec2b0..5f73f176e2e 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -164,7 +164,7 @@ static void outliner_item_drag_handle(
 	te_dragged->drag_data->insert_handle = te_insert_handle;
 }
 
-static bool outliner_item_drag_drop_apply(Main *bmain, SpaceOops *soops, TreeElement *dragged_te)
+static bool outliner_item_drag_drop_apply(Main *bmain, SpaceOops *soops, TreeElement *dragged_te, const wmEvent *event)
 {
 	TreeElement *insert_handle = dragged_te->drag_data->insert_handle;
 	TreeElementInsertType insert_type = dragged_te->drag_data->insert_type;
@@ -178,7 +178,7 @@ static bool outliner_item_drag_drop_apply(Main *bmain, SpaceOops *soops, TreeEle
 		/* call of assert above should not have changed insert_handle and insert_type at this point */
 		BLI_assert(dragged_te->drag_data->insert_handle == insert_handle &&
 		           dragged_te->drag_data->insert_type == insert_type);
-		dragged_te->reinsert(bmain, soops, dragged_te, insert_handle, insert_type);
+		dragged_te->reinsert(bmain, soops, dragged_te, insert_handle, insert_type, event);
 		return true;
 	}
 
@@ -198,7 +198,7 @@ static int outliner_item_drag_drop_modal(bContext *C, wmOperator *op, const wmEv
 	switch (event->type) {
 		case EVT_MODAL_MAP:
 			if (event->val == OUTLINER_ITEM_DRAG_CONFIRM) {
-				if (outliner_item_drag_drop_apply(bmain, soops, te_dragged)) {
+				if (outliner_item_drag_drop_apply(bmain, soops, te_dragged, event)) {
 					skip_rebuild = false;
 				}
 				retval = OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index be60312b110..06b3319935d 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -445,7 +445,8 @@ static TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void
 static void outliner_object_reorder(
         Main *bmain, SpaceOops *soops,
         TreeElement *insert_element,
-        TreeElement *insert_handle, TreeElementInsertType action)
+        TreeElement *insert_handle, TreeElementInsertType action,
+        const wmEvent *event)
 {
 	SceneCollection *sc = outliner_scene_collection_from_tree_element(insert_handle);
 	SceneCollection *sc_ob_parent = NULL;
@@ -458,12 +459,21 @@ static void outliner_object_reorder(
 		.objects_selected_array  = {NULL, NULL},
 	};
 
+	const bool is_append = event->ctrl;
+
 	/* Make sure we include the originally inserted element as well. */
 	TREESTORE(insert_element)->flag |= TSE_SELECTED;
 
 	outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_objects, &data);
 	BLI_LISTBASE_FOREACH (LinkData *, link, &data.objects_selected_array) {
 		TreeElement *ten_selected = (TreeElement *)link->data;
+		Object *ob = (Object *)TREESTORE(ten_selected)->id;
+
+		if (is_append) {
+			BKE_collection_object_add(id, sc, ob);
+			continue;
+		}
+
 		/* Find parent scene-collection of object. */
 		if (ten_selected->parent) {
 			for (TreeElement *te_ob_parent = ten_selected->parent; te_ob_parent; te_ob_parent = te_ob_parent->parent) {
@@ -476,7 +486,7 @@ static void outliner_object_reorder(
 		else {
 			sc_ob_parent = BKE_collection_master(id);
 		}
-		Object *ob = (Object *)TREESTORE(ten_selected)->id;
+
 		BKE_collection_object_move(id, sc, sc_ob_parent, ob);
 	}
 
@@ -1434,7 +1444,8 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
 static void outliner_layer_collections_reorder(
         Main *bmain,
         SpaceOops *UNUSED(soops),
-        TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action)
+        TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action,
+        const wmEvent *UNUSED(event))
 {
 	LayerCollection *lc_insert = insert_element->directdata;
 	LayerCollection *lc_handle = insert_handle->directdata;
@@ -1501,7 +1512,8 @@ static void outliner_add_view_layer(SpaceOops *soops, ListBase *tree, TreeElemen
 static void outliner_scene_collections_reorder(
         Main *bmain,
         SpaceOops *UNUSED(soops),
-        TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action)
+        TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action,
+        const wmEvent *UNUSED(event))
 {
 	SceneCollection *sc_insert = insert_element->directdata;
 	SceneCollection *sc_handle = insert_handle->directdata;



More information about the Bf-blender-cvs mailing list