[Bf-blender-cvs] [7eda9d8dda5] master: Outliner: Hide "data operations" context menu entries unless supported

Julian Eisel noreply at git.blender.org
Thu Sep 8 16:36:08 CEST 2022


Commit: 7eda9d8dda59cd2bfebe665114447adc0a5ce778
Author: Julian Eisel
Date:   Thu Sep 8 16:31:54 2022 +0200
Branches: master
https://developer.blender.org/rB7eda9d8dda59cd2bfebe665114447adc0a5ce778

Outliner: Hide "data operations" context menu entries unless supported

The context menu would always show a section with "Select", "Deselect",
"Hide", "Unhide" and "Select Linked" if there were no more specific
operators to show (e.g. modifier operations). For many tree elements
they did not make sense and simply would do nothing. Only show the
section for supported types.

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

M	source/blender/editors/space_outliner/outliner_tools.cc

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

diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc
index c93622b7cfb..bab5b945d43 100644
--- a/source/blender/editors/space_outliner/outliner_tools.cc
+++ b/source/blender/editors/space_outliner/outliner_tools.cc
@@ -3185,6 +3185,24 @@ void OUTLINER_OT_modifier_operation(wmOperatorType *ot)
 /** \name Data Menu Operator
  * \{ */
 
+static bool outliner_data_operation_poll(bContext *C)
+{
+  if (!ED_operator_outliner_active(C)) {
+    return false;
+  }
+  const SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+  const TreeElement *te = get_target_element(space_outliner);
+  int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
+  get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel);
+  return ELEM(datalevel,
+              TSE_POSE_CHANNEL,
+              TSE_BONE,
+              TSE_EBONE,
+              TSE_SEQUENCE,
+              TSE_GP_LAYER,
+              TSE_RNA_STRUCT);
+}
+
 static int outliner_data_operation_exec(bContext *C, wmOperator *op)
 {
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
@@ -3295,7 +3313,7 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
   /* callbacks */
   ot->invoke = WM_menu_invoke;
   ot->exec = outliner_data_operation_exec;
-  ot->poll = outliner_operation_tree_element_poll;
+  ot->poll = outliner_data_operation_poll;
 
   ot->flag = 0;
 
@@ -3317,9 +3335,12 @@ static int outliner_operator_menu(bContext *C, const char *opname)
 
   /* set this so the default execution context is the same as submenus */
   uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
-  uiItemsEnumO(layout, ot->idname, RNA_property_identifier(ot->prop));
 
-  uiItemS(layout);
+  if (WM_operator_poll(C, ot)) {
+    uiItemsEnumO(layout, ot->idname, RNA_property_identifier(ot->prop));
+
+    uiItemS(layout);
+  }
 
   uiItemMContents(layout, "OUTLINER_MT_context_menu");



More information about the Bf-blender-cvs mailing list