diff --git a/source/blender/editors/include/ED_screen.hh b/source/blender/editors/include/ED_screen.hh index c9ae31c1c17..ce24abfc4f7 100644 --- a/source/blender/editors/include/ED_screen.hh +++ b/source/blender/editors/include/ED_screen.hh @@ -508,6 +508,7 @@ bool ED_operator_region_gizmo_active(bContext *C); */ bool ED_operator_animview_active(bContext *C); bool ED_operator_outliner_active(bContext *C); +bool ED_operator_region_outliner_active(bContext *C); bool ED_operator_outliner_active_no_editobject(bContext *C); /** * \note Will return true for file spaces in either file or asset browsing mode! See diff --git a/source/blender/editors/screen/screen_ops.cc b/source/blender/editors/screen/screen_ops.cc index 96bd0d7a9c4..76d7a122ea5 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -278,6 +278,20 @@ bool ED_operator_outliner_active(bContext *C) return ed_spacetype_test(C, SPACE_OUTLINER); } +bool ED_operator_region_outliner_active(bContext *C) +{ + if (!ED_operator_outliner_active(C)) { + CTX_wm_operator_poll_msg_set(C, "Expected an active Outliner"); + return false; + } + const ARegion *region = CTX_wm_region(C); + if (!(region && region->regiontype == RGN_TYPE_WINDOW)) { + CTX_wm_operator_poll_msg_set(C, "Expected an Outliner region"); + return false; + } + return true; +} + bool ED_operator_outliner_active_no_editobject(bContext *C) { if (ed_spacetype_test(C, SPACE_OUTLINER)) { diff --git a/source/blender/editors/space_outliner/outliner_collections.cc b/source/blender/editors/space_outliner/outliner_collections.cc index c8cb339381c..e74fd65dc4a 100644 --- a/source/blender/editors/space_outliner/outliner_collections.cc +++ b/source/blender/editors/space_outliner/outliner_collections.cc @@ -183,6 +183,17 @@ static bool collection_edit_in_active_scene_poll(bContext *C) return true; } +static bool collection_new_poll(bContext *C) +{ + if (!ED_operator_region_outliner_active(C)) { + return false; + } + if (!collection_edit_in_active_scene_poll(C)) { + return false; + } + return true; +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -268,7 +279,7 @@ void OUTLINER_OT_collection_new(wmOperatorType *ot) /* api callbacks */ ot->exec = collection_new_exec; - ot->poll = collection_edit_in_active_scene_poll; + ot->poll = collection_new_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc index c01f96c6224..91742e2dd94 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.cc +++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc @@ -451,7 +451,7 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) /* api callbacks */ ot->invoke = parent_drop_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -609,7 +609,7 @@ void OUTLINER_OT_scene_drop(wmOperatorType *ot) /* api callbacks */ ot->invoke = scene_drop_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -662,7 +662,7 @@ void OUTLINER_OT_material_drop(wmOperatorType *ot) /* api callbacks */ ot->invoke = material_drop_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 15c2f8d15fa..d85f8d82447 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -296,7 +296,7 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) ot->invoke = outliner_item_openclose_invoke; ot->modal = outliner_item_openclose_modal; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; RNA_def_boolean(ot->srna, "all", false, "All", "Close or open all items"); } @@ -445,7 +445,7 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot) ot->invoke = outliner_item_rename_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -596,7 +596,7 @@ void OUTLINER_OT_id_delete(wmOperatorType *ot) ot->description = "Delete the ID under cursor"; ot->invoke = outliner_id_delete_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -735,7 +735,7 @@ void OUTLINER_OT_id_remap(wmOperatorType *ot) /* callbacks */ ot->invoke = outliner_id_remap_invoke; ot->exec = outliner_id_remap_exec; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -995,7 +995,7 @@ void OUTLINER_OT_lib_relocate(wmOperatorType *ot) ot->description = "Relocate the library under cursor"; ot->invoke = outliner_lib_relocate_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1051,7 +1051,7 @@ void OUTLINER_OT_lib_reload(wmOperatorType *ot) ot->description = "Reload the library under cursor"; ot->invoke = outliner_lib_reload_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1180,7 +1180,7 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) /* callbacks */ ot->exec = outliner_toggle_expanded_exec; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* no undo or registry, UI option */ } @@ -1382,7 +1382,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot) /* callbacks */ ot->exec = outliner_show_active_exec; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; } /** \} */ @@ -1421,7 +1421,7 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot) /* callbacks */ ot->exec = outliner_scroll_page_exec; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* properties */ prop = RNA_def_boolean(ot->srna, "up", false, "Up", "Scroll up one page"); @@ -1493,7 +1493,7 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot) /* callbacks */ ot->exec = outliner_one_level_exec; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* no undo or registry, UI option */ @@ -1586,7 +1586,8 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) /* callbacks */ ot->exec = outliner_show_hierarchy_exec; - ot->poll = ED_operator_outliner_active; /* TODO: shouldn't be allowed in RNA views... */ + /* TODO: shouldn't be allowed in RNA views... */ + ot->poll = ED_operator_region_outliner_active; /* no undo or registry, UI option */ } diff --git a/source/blender/editors/space_outliner/outliner_select.cc b/source/blender/editors/space_outliner/outliner_select.cc index 06f6b402f9b..2cd56408bd9 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -1897,7 +1897,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) ot->invoke = outliner_item_activate_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -2005,7 +2005,7 @@ void OUTLINER_OT_select_box(wmOperatorType *ot) ot->modal = WM_gesture_box_modal; ot->cancel = WM_gesture_box_cancel; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index fe478f83318..28f027c3698 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -3743,7 +3743,7 @@ void OUTLINER_OT_operation(wmOperatorType *ot) ot->invoke = outliner_operation_invoke; - ot->poll = ED_operator_outliner_active; + ot->poll = ED_operator_region_outliner_active; } /** \} */