[Bf-blender-cvs] [dcf67a3b9c6] temp-soc-2019-outliner-sync: Outliner: Use F2 to rename active outliner item

Nathan Craddock noreply at git.blender.org
Sat Aug 10 05:04:02 CEST 2019


Commit: dcf67a3b9c67e14ea3acb2692ec2fbff68222a53
Author: Nathan Craddock
Date:   Fri Aug 9 13:27:40 2019 -0600
Branches: temp-soc-2019-outliner-sync
https://developer.blender.org/rBdcf67a3b9c67e14ea3acb2692ec2fbff68222a53

Outliner: Use F2 to rename active outliner item

Previously with F2 mapped to the global rename active object
operator, it was not posible to use the conventional F2 to rename any
outliner element like collections or object data. This adds F2 to the
outliner keymap to call the outliner rename operator rather than the
popup rename object operator.

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	source/blender/editors/space_outliner/outliner_edit.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index f70c4cc9175..32a3e5abb89 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -700,6 +700,7 @@ def km_outliner(params):
     items.extend([
         ("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None),
         ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
+        ("outliner.item_rename", {"type": 'F2', "value": 'PRESS'}, None),
         ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK'},
          {"properties": [("extend", False), ("recursive", False), ("deselect_all", not params.legacy)]}),
         ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index e0c57fabc73..15d6e2587e5 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -398,10 +398,10 @@ void item_rename_cb(bContext *C,
   do_item_rename(ar, te, tselem, reports);
 }
 
-static int do_outliner_item_rename(ReportList *reports,
-                                   ARegion *ar,
-                                   TreeElement *te,
-                                   const float mval[2])
+static void do_outliner_item_rename(ReportList *reports,
+                                    ARegion *ar,
+                                    TreeElement *te,
+                                    const float mval[2])
 {
   if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
     TreeStoreElem *tselem = TREESTORE(te);
@@ -409,17 +409,12 @@ static int do_outliner_item_rename(ReportList *reports,
     /* click on name */
     if (mval[0] > te->xs + UI_UNIT_X * 2 && mval[0] < te->xend) {
       do_item_rename(ar, te, tselem, reports);
-      return 1;
     }
-    return 0;
   }
 
   for (te = te->subtree.first; te; te = te->next) {
-    if (do_outliner_item_rename(reports, ar, te, mval)) {
-      return 1;
-    }
+    do_outliner_item_rename(reports, ar, te, mval);
   }
-  return 0;
 }
 
 static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *event)
@@ -428,25 +423,34 @@ static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *even
   SpaceOutliner *soops = CTX_wm_space_outliner(C);
   TreeElement *te;
   float fmval[2];
-  bool changed = false;
 
-  UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
+  /* Rename active element if key pressed, otherwise rename element at cursor coordinates */
+  if (event->val == KM_PRESS) {
+    TreeElement *active_element = outliner_find_element_with_flag(&soops->tree, TSE_ACTIVE);
 
-  for (te = soops->tree.first; te; te = te->next) {
-    if (do_outliner_item_rename(op->reports, ar, te, fmval)) {
-      changed = true;
-      break;
+    if (active_element) {
+      do_item_rename(ar, active_element, TREESTORE(active_element), op->reports);
+    }
+    else {
+      BKE_report(op->reports, RPT_WARNING, "No active item to rename");
     }
   }
+  else {
+    UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
 
-  return changed ? OPERATOR_FINISHED : OPERATOR_PASS_THROUGH;
+    for (te = soops->tree.first; te; te = te->next) {
+      do_outliner_item_rename(op->reports, ar, te, fmval);
+    }
+  }
+
+  return OPERATOR_FINISHED;
 }
 
 void OUTLINER_OT_item_rename(wmOperatorType *ot)
 {
   ot->name = "Rename";
   ot->idname = "OUTLINER_OT_item_rename";
-  ot->description = "Rename item under cursor";
+  ot->description = "Rename the active element";
 
   ot->invoke = outliner_item_rename;



More information about the Bf-blender-cvs mailing list