ops_ui.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # gonna start putting the UI operators in here so
  2. # that the nodegroup operators file is more focused
  3. import bpy
  4. from bpy.types import Operator
  5. from .utilities import (prRed, prGreen, prPurple, prWhite,
  6. prOrange,
  7. wrapRed, wrapGreen, wrapPurple, wrapWhite,
  8. wrapOrange,)
  9. def TellClasses():
  10. return [
  11. ColorPalleteAddSocket,
  12. ColorPalleteRemoveSocket,
  13. ]
  14. class ColorPalleteAddSocket(Operator):
  15. """Add a Color Set socket to the node"""
  16. bl_idname = "mantis.color_pallete_socket_add"
  17. bl_label = "Add Color Set"
  18. bl_options = {'REGISTER', 'UNDO'}
  19. tree_invoked : bpy.props.StringProperty(options ={'HIDDEN'})
  20. node_invoked : bpy.props.StringProperty(options ={'HIDDEN'})
  21. @classmethod
  22. def poll(cls, context):
  23. return True
  24. def execute(self, context):
  25. n = bpy.data.node_groups[self.tree_invoked].nodes[self.node_invoked]
  26. # the name doesn't matter, will probably be Color Set.001 or something instead
  27. n.outputs.new("ColorSetSocket", "Color Set")
  28. return {'FINISHED'}
  29. class ColorPalleteRemoveSocket(Operator):
  30. """Remove a Color Set socket from the node"""
  31. bl_idname = "mantis.color_pallete_socket_remove"
  32. bl_label = "X"
  33. bl_options = {'REGISTER', 'UNDO'}
  34. tree_invoked : bpy.props.StringProperty(options = {'HIDDEN'})
  35. node_invoked : bpy.props.StringProperty(options = {'HIDDEN'})
  36. socket_invoked : bpy.props.StringProperty(options = {'HIDDEN'})
  37. @classmethod
  38. def poll(cls, context):
  39. return True
  40. def execute(self, context):
  41. n = bpy.data.node_groups[self.tree_invoked].nodes[self.node_invoked]
  42. # the name doesn't matter, will probably be Color Set.001 or something instead
  43. for s in n.outputs:
  44. if s.identifier == self.socket_invoked:
  45. break
  46. n.outputs.remove(s)
  47. return {'FINISHED'}