properties_data_empty.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8 compliant>
  19. from bpy.types import Panel
  20. class DataButtonsPanel:
  21. bl_space_type = 'PROPERTIES'
  22. bl_region_type = 'WINDOW'
  23. bl_context = "data"
  24. @classmethod
  25. def poll(cls, context):
  26. ob = context.object
  27. return (ob and ob.type == 'EMPTY')
  28. class DATA_PT_empty(DataButtonsPanel, Panel):
  29. bl_label = "Empty"
  30. def draw(self, context):
  31. layout = self.layout
  32. layout.use_property_split = True
  33. layout.use_property_decorate = False
  34. ob = context.object
  35. layout.prop(ob, "empty_display_type", text="Display As")
  36. layout.prop(ob, "empty_display_size", text="Size")
  37. if ob.empty_display_type == 'IMAGE':
  38. layout.prop(ob, "use_empty_image_alpha")
  39. col = layout.column()
  40. col.active = ob.use_empty_image_alpha
  41. col.prop(ob, "color", text="Transparency", index=3, slider=True)
  42. col = layout.column(align=True)
  43. col.prop(ob, "empty_image_offset", text="Offset X", index=0)
  44. col.prop(ob, "empty_image_offset", text="Y", index=1)
  45. col = layout.column()
  46. col.row().prop(ob, "empty_image_depth", text="Depth", expand=True)
  47. col.row().prop(ob, "empty_image_side", text="Side", expand=True)
  48. col.prop(ob, "show_empty_image_orthographic", text="Display Orthographic")
  49. col.prop(ob, "show_empty_image_perspective", text="Display Perspective")
  50. class DATA_PT_empty_image(DataButtonsPanel, Panel):
  51. bl_label = "Image"
  52. @classmethod
  53. def poll(cls, context):
  54. ob = context.object
  55. return (ob and ob.type == 'EMPTY' and ob.empty_display_type == 'IMAGE')
  56. def draw(self, context):
  57. layout = self.layout
  58. ob = context.object
  59. layout.template_ID(ob, "data", open="image.open", unlink="object.unlink_data")
  60. layout.separator()
  61. layout.template_image(ob, "data", ob.image_user, compact=True)
  62. classes = (
  63. DATA_PT_empty,
  64. DATA_PT_empty_image,
  65. )
  66. if __name__ == "__main__": # only for live edit.
  67. from bpy.utils import register_class
  68. for cls in classes:
  69. register_class(cls)