diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-06-15 10:59:10 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-06-15 10:59:10 +0300 |
commit | 17d293687324e86b2e94e6ca3574e294f3da3667 (patch) | |
tree | c0add73eb6670530923ab02b543ec5e5a735b6d5 | |
parent | 87b9e91c0c8843429ef6712f9c96f423b29d7457 (diff) |
POV-Ray: add templates to text editor menu when addon is enabled.
-rw-r--r-- | render_povray/__init__.py | 2 | ||||
-rw-r--r-- | render_povray/ui.py | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py index e66e44c2..b95103b9 100644 --- a/render_povray/__init__.py +++ b/render_povray/__init__.py @@ -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__) diff --git a/render_povray/ui.py b/render_povray/ui.py index ba763871..0feecec9 100644 --- a/render_povray/ui.py +++ b/render_povray/ui.py @@ -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") |