Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mixin #4035

Merged
merged 2 commits into from
Apr 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions ui/nodeview_space_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ def draw(self, context):
layout_draw_categories(self.layout, self.bl_label, node_cats[self.bl_label])
# prop_menu_enum(data, property, text="", text_ctxt="", icon='NONE')


class SV_NodeTree_Poll():
"""
mixin to detect if the current nodetree is a Sverchok type nodetree, if not poll returns False
"""
@classmethod
def poll(cls, context):
tree_type = context.space_data.tree_type
if tree_type in sv_tree_types:
return True


# quick class factory.
def make_class(name, bl_label):
global menu_class_by_title
Expand All @@ -151,16 +163,9 @@ def make_class(name, bl_label):
menu_class_by_title[bl_label] = clazz
return clazz

class NODEVIEW_MT_Dynamic_Menu(bpy.types.Menu):
bl_label = "Sverchok Nodes"

@classmethod
def poll(cls, context):
tree_type = context.space_data.tree_type
if tree_type in sv_tree_types:
#menu_prefs['show_icons'] = get_icon_switch()
# print('showing', menu_prefs['show_icons'])
return True
class NODEVIEW_MT_Dynamic_Menu(bpy.types.Menu, SV_NodeTree_Poll):
bl_label = "Sverchok Nodes"

def draw(self, context):

Expand Down Expand Up @@ -200,9 +205,10 @@ def draw(self, context):
layout.menu("NODEVIEW_MT_EX_" + category.identifier)


class NodePatialMenuTemplate(bpy.types.Menu):
class NodePatialMenuTemplate(bpy.types.Menu, SV_NodeTree_Poll):
bl_label = ""
items = []

def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
Expand Down