[Bf-blender-cvs] [e269f4bfca5] soc-2020-outliner: Outliner: Only allow object drop over name or icon

Nathan Craddock noreply at git.blender.org
Fri Jul 10 04:08:40 CEST 2020


Commit: e269f4bfca5e040219622b89d130b6cb443cf294
Author: Nathan Craddock
Date:   Thu Jul 9 17:25:37 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rBe269f4bfca5e040219622b89d130b6cb443cf294

Outliner: Only allow object drop over name or icon

When doing object drop, allow collection drop when dropping outside the
name or icon, and parent drop when over name or icon.

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

M	source/blender/editors/space_outliner/outliner_dragdrop.c

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

diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 9d70cc13286..9031967047a 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -260,8 +260,22 @@ static TreeElement *outliner_drop_insert_collection_find(bContext *C,
 
 /* ******************** Parent Drop Operator *********************** */
 
-static bool parent_drop_allowed(TreeElement *te, Object *potential_child)
+static bool parent_drop_allowed(bContext *C,
+                                const wmEvent *event,
+                                TreeElement *te,
+                                Object *potential_child)
 {
+  ARegion *region = CTX_wm_region(C);
+  float view_mval[2];
+
+  UI_view2d_region_to_view(
+      &region->v2d, event->mval[0], event->mval[1], &view_mval[0], &view_mval[1]);
+
+  /* Check if over name. */
+  if ((view_mval[0] < te->xs + UI_UNIT_X) || (view_mval[0] > te->xend)) {
+    return false;
+  }
+
   TreeStoreElem *tselem = TREESTORE(te);
   if (te->idcode != ID_OB || tselem->type != 0) {
     return false;
@@ -324,7 +338,7 @@ static bool parent_drop_poll(bContext *C,
     insert_type = TE_INSERT_INTO;
   }
 
-  if (!parent_drop_allowed(te, potential_child)) {
+  if (!parent_drop_allowed(C, event, te, potential_child)) {
     return false;
   }



More information about the Bf-blender-cvs mailing list