def layout_draw_categories(layout, node_details): for node_info in node_details: if node_info[0] == 'separator': layout.separator() continue if not node_info: print(repr(node_info), 'is incomplete, or unparsable') continue bl_idname = node_info[0] # this is a node bl_idname that can be registered but shift+A can drop it from showing. if bl_idname == 'ScalarMathNode': continue node_ref = get_node_class_reference(bl_idname) if hasattr(node_ref, "bl_label"): layout_params = dict(text=node_ref.bl_label, **node_icon(node_ref)) elif bl_idname == 'NodeReroute': layout_params = dict(text='Reroute',icon_value=custom_icon('SV_REROUTE')) else: continue node_op = draw_add_node_operator(layout, bl_idname, params=layout_params)
def draw_add_node_operator(layout, nodetype, label=None, icon_name=None, params=None): """ Draw node adding operator button. This is to be used both in Shift-A menu and in T panel. """ default_context = bpy.app.translations.contexts.default node_class = get_node_class_reference(nodetype) if node_class is None: info("cannot locate node class: %s", nodetype) return node_rna = node_class.bl_rna if label is None: if hasattr(node_rna, 'bl_label'): label = node_rna.bl_label elif nodetype == "NodeReroute": label = "Reroute" else: label = node_rna.name if params is None: params = dict(text=label) params['text_ctxt'] = default_context if icon_name is not None: params.update(**icon(icon_name)) else: params.update(**node_icon(node_rna)) add = layout.operator("node.sv_add_" + get_node_idname_for_operator(nodetype), **params) add.type = nodetype add.use_transform = True return add
def layout_draw_categories(layout, node_details): for node_info in node_details: if node_info[0] == 'separator': layout.separator() continue if not node_info: print(repr(node_info), 'is incomplete, or unparsable') continue bl_idname = node_info[0] node_ref = get_node_class_reference(bl_idname) if hasattr(node_ref, "bl_label"): layout_params = dict(text=node_ref.bl_label, **node_icon(node_ref)) elif bl_idname == 'NodeReroute': layout_params = dict(text='Reroute') else: continue node_op = draw_add_node_operator(layout, bl_idname, params=layout_params)
def draw_add_node_operator(layout, nodetype, label=None, icon_name=None, params=None): """ Draw node adding operator button. This is to be used both in Shift-A menu and in T panel. """ default_context = bpy.app.translations.contexts.default node_rna = get_node_class_reference(nodetype).bl_rna if label is None: if hasattr(node_rna, 'bl_label'): label = node_rna.bl_label elif nodetype == "NodeReroute": label = "Reroute" else: label = node_rna.name if params is None: params = dict(text=label) params['text_ctxt'] = default_context if icon_name is not None: params.update(**icon(icon_name)) else: params.update(**node_icon(node_rna)) add = layout.operator("node.sv_add_" + get_node_idname_for_operator(nodetype), **params) add.type = nodetype add.use_transform = True return add
def layout_draw_categories(layout, node_details): for node_info in node_details: if node_info[0] == 'separator': layout.separator() continue if not node_info: print(repr(node_info), 'is incomplete, or unparsable') continue bl_idname = node_info[0] # this is a node bl_idname that can be registered but shift+A can drop it from showing. if bl_idname == 'ScalarMathNode': continue node_ref = get_node_class_reference(bl_idname) if hasattr(node_ref, "bl_label"): layout_params = dict(text=node_ref.bl_label, **node_icon(node_ref)) elif bl_idname == 'NodeReroute': layout_params = dict(text='Reroute') else: continue node_op = draw_add_node_operator(layout, bl_idname, params=layout_params)
def layout_draw_categories(layout, category_name, node_details): global menu_class_by_title for node_info in node_details: if node_info[0] == 'separator': layout.separator() continue if not node_info: print(repr(node_info), 'is incomplete, or unparsable') continue bl_idname = node_info[0] if is_submenu_call(bl_idname): submenu_title = get_submenu_call_name(bl_idname) menu_title = compose_submenu_name(category_name, bl_idname) menu_class = menu_class_by_title[menu_title] layout.menu(menu_class.__name__, text=submenu_title) continue # this is a node bl_idname that can be registered but shift+A can drop it from showing. if bl_idname == 'ScalarMathNode': continue node_ref = get_node_class_reference(bl_idname) if hasattr(node_ref, "bl_label"): layout_params = dict(text=node_ref.bl_label, **node_icon(node_ref)) elif bl_idname == 'NodeReroute': layout_params = dict(text='Reroute', icon_value=custom_icon('SV_REROUTE')) else: continue node_op = draw_add_node_operator(layout, bl_idname, params=layout_params)