menu_classes.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from bpy.types import Panel, Menu
  2. def TellClasses():
  3. return [
  4. MantisActiveTreePanel,
  5. ]
  6. # Function to append submenu to context menu
  7. def node_context_menu_draw(self, context):
  8. layout = self.layout
  9. layout.separator() # Optional: Adds a separator before your submenu
  10. layout.operator_context = "INVOKE_DEFAULT"
  11. layout.operator("mantis.nodes_cleanup", text='Sort Selected Nodes')
  12. layout.operator("mantis.connect_nodes_to_input")
  13. layout.operator("mantis.select_nodes_of_type")
  14. layout.operator("mantis.import_from_component_library")
  15. # layout.menu('NODE_MT_context_menu_mantis')
  16. class MantisActiveTreePanel(Panel):
  17. """N-Panel menu for Mantis"""
  18. bl_label = "Active Tree"
  19. bl_idname = "MANTIS_PT_active_tree"
  20. bl_space_type = 'NODE_EDITOR'
  21. bl_region_type = 'UI'
  22. bl_category = "Mantis"
  23. bl_context = "scene"
  24. @classmethod
  25. def poll(cls, context):
  26. area = context.area
  27. if not area: return False
  28. if not area.spaces: return False
  29. spc = area.spaces[0]
  30. if spc.type != "NODE_EDITOR":
  31. return False
  32. if not spc.node_tree:
  33. return False
  34. if spc.node_tree.bl_idname != "MantisTree":
  35. return False
  36. return True
  37. def draw(self, context):
  38. area = context.area
  39. spc = area.spaces[0]
  40. nt = spc.node_tree
  41. layout = self.layout
  42. layout.label(text=f"Tree Hash: {nt.hash}")
  43. layout.prop(nt, "do_live_update", text='Live Updates',)
  44. layout.operator("mantis.invalidate_node_tree")
  45. layout.operator("mantis.execute_node_tree")
  46. layout.operator("mantis.force_display_update", text='Force Display Update')
  47. layout.operator("mantis.import_from_component_library")