menu_classes.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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.menu('NODE_MT_context_menu_mantis')
  15. class MantisActiveTreePanel(Panel):
  16. """N-Panel menu for Mantis"""
  17. bl_label = "Active Tree"
  18. bl_idname = "MANTIS_PT_active_tree"
  19. bl_space_type = 'NODE_EDITOR'
  20. bl_region_type = 'UI'
  21. bl_category = "Mantis"
  22. bl_context = "scene"
  23. @classmethod
  24. def poll(cls, context):
  25. area = context.area
  26. if not area: return False
  27. if not area.spaces: return False
  28. spc = area.spaces[0]
  29. if spc.type != "NODE_EDITOR":
  30. return False
  31. if spc.node_tree.bl_idname != "MantisTree":
  32. return False
  33. return True
  34. def draw(self, context):
  35. area = context.area
  36. spc = area.spaces[0]
  37. nt = spc.node_tree
  38. layout = self.layout
  39. layout.label(text=f"Tree Hash: {nt.hash}")
  40. layout.prop(nt, "do_live_update", text='Live Updates',)
  41. layout.operator("mantis.invalidate_node_tree")
  42. layout.operator("mantis.execute_node_tree")
  43. layout.operator("mantis.force_display_update", text='Force Display Update')