Fix: Node Editor: Hide compoitor-specific menu items

Previews and the "Read Viewlayers" operator are specific to the
compositor and shouldn't show in other node editor types.
This commit is contained in:
Hans Goudey 2022-12-02 14:30:54 -06:00
parent 2155bdd500
commit ce16fa0f4c
2 changed files with 10 additions and 5 deletions

View File

@ -307,8 +307,10 @@ class NODE_MT_select(Menu):
class NODE_MT_node(Menu):
bl_label = "Node"
def draw(self, _context):
def draw(self, context):
layout = self.layout
snode = context.space_data
is_compositor = snode.tree_type == 'CompositorNodeTree'
layout.operator("transform.translate")
layout.operator("transform.rotate")
@ -346,14 +348,17 @@ class NODE_MT_node(Menu):
layout.operator("node.hide_toggle")
layout.operator("node.mute_toggle")
layout.operator("node.preview_toggle")
if is_compositor:
layout.operator("node.preview_toggle")
layout.operator("node.hide_socket_toggle")
layout.operator("node.options_toggle")
layout.operator("node.collapse_hide_unused_toggle")
layout.separator()
layout.operator("node.read_viewlayers")
if is_compositor:
layout.separator()
layout.operator("node.read_viewlayers")
class NODE_MT_view_pie(Menu):

View File

@ -1709,7 +1709,7 @@ void NODE_OT_preview_toggle(wmOperatorType *ot)
/* callbacks */
ot->exec = node_preview_toggle_exec;
ot->poll = ED_operator_node_active;
ot->poll = composite_node_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;