diff options
author | Julian Eisel <julian@blender.org> | 2022-09-09 14:52:51 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-09-09 15:04:27 +0300 |
commit | e254d8867d666846fa8455ac8415763127eb48b6 (patch) | |
tree | d14d70a18cafda805c0cf8e8d48a98935d2e8f44 | |
parent | 860c3dce1b7ff201eccf17ef39114be65df45a07 (diff) |
Outliner: Hide library overrdies context menu when no IDs are selected
The library overrides context menu operators only make sense when at
least one ID is selected in the Outliner. So don't show them unless
that's the case. This also means the menu items don't show up anymore
for things like RNA properties, or the overridden properties in the
Library Overrides Properties view.
Also see 7eda9d8dda59 and the previous commit.
-rw-r--r-- | release/scripts/startup/bl_ui/space_outliner.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index 4354f4fbf77..5c488748db8 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -323,17 +323,20 @@ class OUTLINER_MT_object(Menu): OUTLINER_MT_context_menu.draw_common_operators(layout) +def has_selected_ids_in_context(context): + if hasattr(context, "id"): + return True + if len(context.selected_ids) > 0: + return True + + return False + class OUTLINER_MT_asset(Menu): bl_label = "Assets" @classmethod def poll(cls, context): - if hasattr(context, "id"): - return True - if len(context.selected_ids) > 0: - return True - - return False + return has_selected_ids_in_context(context) def draw(self, _context): layout = self.layout @@ -346,6 +349,10 @@ class OUTLINER_MT_asset(Menu): class OUTLINER_MT_liboverride(Menu): bl_label = "Library Override" + @classmethod + def poll(cls, context): + return has_selected_ids_in_context(context) + def draw(self, _context): layout = self.layout |