[Bf-blender-cvs] [847d355cab4] master: File/Asset Browser: Don't deselect other items when dragging

Julian Eisel noreply at git.blender.org
Mon Sep 27 18:52:41 CEST 2021


Commit: 847d355cab47bca3a2afa1c516dcd712c321b856
Author: Julian Eisel
Date:   Mon Sep 27 18:45:49 2021 +0200
Branches: master
https://developer.blender.org/rB847d355cab47bca3a2afa1c516dcd712c321b856

File/Asset Browser: Don't deselect other items when dragging

Basically this enables the select-tweaking behavior as per the
guidelines:
https://wiki.blender.org/wiki/Human_Interface_Guidelines/Selection#Select-tweaking.

We use this in most other other editors that allow selecting and
dragging multiple items. But besides the consistency improvement, this
is important if we want to support dragging multiple assets (or files)
in future. We want to support this at least for dragging multiple assets
into an asset catalog for the upcoming asset catalog UI.

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

M	source/blender/editors/space_file/file_ops.c

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

diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 2f1acd2ca4d..d0f2a4fdc4c 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -536,7 +536,7 @@ static rcti file_select_mval_to_select_rect(const int mval[2])
   return rect;
 }
 
-static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int file_select_exec(bContext *C, wmOperator *op)
 {
   ARegion *region = CTX_wm_region(C);
   SpaceFile *sfile = CTX_wm_space_file(C);
@@ -549,17 +549,27 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
   const bool only_activate_if_selected = RNA_boolean_get(op->ptr, "only_activate_if_selected");
   /* Used so right mouse clicks can do both, activate and spawn the context menu. */
   const bool pass_through = RNA_boolean_get(op->ptr, "pass_through");
+  bool wait_to_deselect_others = RNA_boolean_get(op->ptr, "wait_to_deselect_others");
 
   if (region->regiontype != RGN_TYPE_WINDOW) {
     return OPERATOR_CANCELLED;
   }
 
-  rect = file_select_mval_to_select_rect(event->mval);
+  int mval[2];
+  mval[0] = RNA_int_get(op->ptr, "mouse_x");
+  mval[1] = RNA_int_get(op->ptr, "mouse_y");
+  rect = file_select_mval_to_select_rect(mval);
 
   if (!ED_fileselect_layout_is_inside_pt(sfile->layout, &region->v2d, rect.xmin, rect.ymin)) {
     return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
   }
 
+  if (extend || fill) {
+    wait_to_deselect_others = false;
+  }
+
+  int ret_val = OPERATOR_FINISHED;
+
   const FileSelectParams *params = ED_fileselect_get_active_params(sfile);
   if (sfile && params) {
     int idx = params->highlight_file;
@@ -571,6 +581,9 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
       if (only_activate_if_selected && is_selected) {
         /* Don't deselect other items. */
       }
+      else if (wait_to_deselect_others && is_selected) {
+        ret_val = OPERATOR_RUNNING_MODAL;
+      }
       /* single select, deselect all selected first */
       else if (!extend) {
         file_select_deselect_all(sfile, FILE_SEL_SELECTED);
@@ -601,7 +614,10 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
   WM_event_add_mousemove(CTX_wm_window(C)); /* for directory changes */
   WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
 
-  return pass_through ? (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH) : OPERATOR_FINISHED;
+  if ((ret_val == OPERATOR_FINISHED) && pass_through) {
+    ret_val |= OPERATOR_PASS_THROUGH;
+  }
+  return ret_val;
 }
 
 void FILE_OT_select(wmOperatorType *ot)
@@ -614,11 +630,14 @@ void FILE_OT_select(wmOperatorType *ot)
   ot->description = "Handle mouse clicks to select and activate items";
 
   /* api callbacks */
-  ot->invoke = file_select_invoke;
+  ot->invoke = WM_generic_select_invoke;
+  ot->exec = file_select_exec;
+  ot->modal = WM_generic_select_modal;
   /* Operator works for file or asset browsing */
   ot->poll = ED_operator_file_active;
 
   /* properties */
+  WM_operator_properties_generic_select(ot);
   prop = RNA_def_boolean(ot->srna,
                          "extend",
                          false,



More information about the Bf-blender-cvs mailing list