Skip to content
Snippets Groups Projects
Commit 17d29368 authored by Bastien Montagne's avatar Bastien Montagne
Browse files

POV-Ray: add templates to text editor menu when addon is enabled.

parent 87b9e91c
No related branches found
No related tags found
No related merge requests found
......@@ -2175,6 +2175,7 @@ def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_add.prepend(ui.menu_func_add)
bpy.types.INFO_MT_file_import.append(ui.menu_func_import)
bpy.types.TEXT_MT_templates.append(ui.menu_func_templates)
#used for parametric objects:
addon_utils.enable("add_mesh_extra_objects", default_set=False, persistent=True)
......@@ -2203,6 +2204,7 @@ def unregister():
#bpy.types.TEXTURE_PT_context_texture.remove(TEXTURE_PT_povray_type)
addon_utils.disable("add_mesh_extra_objects", default_set=False)
bpy.types.TEXT_MT_templates.remove(ui.menu_func_templates)
bpy.types.INFO_MT_file_import.remove(ui.menu_func_import)
bpy.types.INFO_MT_add.remove(ui.menu_func_add)
bpy.utils.unregister_module(__name__)
......
......@@ -1755,3 +1755,25 @@ class TEXT_PT_povray_custom_code(TextButtonsPanel, bpy.types.Panel):
if text:
layout.prop(text.pov, "custom_code", text="Add as POV code")
###############################################"
# Text editor templates.
class TEXT_MT_templates_pov(bpy.types.Menu):
bl_label = "POV-Ray"
# We list templates on file evaluation, we can assume they are static data,
# and better avoid running this on every draw call.
import os
template_paths = [os.path.join(os.path.dirname(__file__), "templates_pov")]
def draw(self, context):
self.path_menu(
self.template_paths,
"text.open",
props_default={"internal": True},
)
def menu_func_templates(self, context):
# Do not depend on POV-Ray being active renderer here...
self.layout.menu("TEXT_MT_templates_pov")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment