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 332da569b0a..c634944c9fc 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -283,6 +283,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 f7b7265dc71..a801e70b5d4 100644 --- a/source/blender/editors/space_outliner/outliner_collections.cc +++ b/source/blender/editors/space_outliner/outliner_collections.cc @@ -184,6 +184,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; +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -269,7 +280,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 fcc210d7223..a3a7ae44eba 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 aaa86123dec..71f891608ee 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -288,7 +288,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"); } @@ -438,7 +438,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; @@ -590,7 +590,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; @@ -729,7 +729,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; @@ -990,7 +990,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; @@ -1047,7 +1047,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; @@ -1177,7 +1177,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 */ } @@ -1379,7 +1379,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; } /** \} */ @@ -1418,7 +1418,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"); @@ -1490,7 +1490,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 */ @@ -1583,7 +1583,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 f8ae176cb0c..352279326da 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -1900,7 +1900,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; @@ -2008,7 +2008,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 2176b0242bb..35ca7037e61 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -3806,7 +3806,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; } /** \} */