Fix: Node Wrangler: new reroutes offset when output hidden
[blender-addons.git] / amaranth / node_editor / templates / __init__.py
blob33af8ddede3e47c9c43708ba64591295c6541dce
1 # SPDX-License-Identifier: GPL-2.0-or-later
2 """
3 Node Templates - Vignette, Vector Blur
5 Add a set of nodes with one click, in this version I added a "Vignette"
6 as first example.
8 There is no official way to make a vignette, this is just my approach at
9 it. Templates: On the Compositor's header, "Template" pulldown. Or hit W.
10 Vignette: Adjust the size and position of the vignette with the Ellipse
11 Mask's X/Y and width, height values.
12 """
14 import bpy
15 from amaranth.node_editor.templates.vectorblur import AMTH_NODE_OT_AddTemplateVectorBlur
16 from amaranth.node_editor.templates.vignette import AMTH_NODE_OT_AddTemplateVignette
19 KEYMAPS = list()
22 # Node Templates Menu
23 class AMTH_NODE_MT_amaranth_templates(bpy.types.Menu):
24 bl_idname = 'AMTH_NODE_MT_amaranth_templates'
25 bl_space_type = 'NODE_EDITOR'
26 bl_label = "Templates"
27 bl_description = "List of Amaranth Templates"
29 def draw(self, context):
30 layout = self.layout
31 layout.operator(
32 AMTH_NODE_OT_AddTemplateVectorBlur.bl_idname,
33 text="Vector Blur",
34 icon='FORCE_HARMONIC')
35 layout.operator(
36 AMTH_NODE_OT_AddTemplateVignette.bl_idname,
37 text="Vignette",
38 icon='COLOR')
41 def node_templates_pulldown(self, context):
42 if context.space_data.tree_type == 'CompositorNodeTree':
43 layout = self.layout
44 row = layout.row(align=True)
45 row.scale_x = 1.3
46 row.menu("AMTH_NODE_MT_amaranth_templates",
47 icon="NODETREE")
50 def register():
51 bpy.utils.register_class(AMTH_NODE_MT_amaranth_templates)
52 bpy.utils.register_class(AMTH_NODE_OT_AddTemplateVignette)
53 bpy.utils.register_class(AMTH_NODE_OT_AddTemplateVectorBlur)
54 bpy.types.NODE_HT_header.append(node_templates_pulldown)
55 kc = bpy.context.window_manager.keyconfigs.addon
56 km = kc.keymaps.new(name="Node Editor", space_type="NODE_EDITOR")
57 kmi = km.keymap_items.new("wm.call_menu", "W", "PRESS")
58 kmi.properties.name = "AMTH_NODE_MT_amaranth_templates"
59 KEYMAPS.append((km, kmi))
62 def unregister():
63 bpy.utils.unregister_class(AMTH_NODE_MT_amaranth_templates)
64 bpy.utils.unregister_class(AMTH_NODE_OT_AddTemplateVignette)
65 bpy.utils.unregister_class(AMTH_NODE_OT_AddTemplateVectorBlur)
66 bpy.types.NODE_HT_header.remove(node_templates_pulldown)
67 for km, kmi in KEYMAPS:
68 km.keymap_items.remove(kmi)
69 KEYMAPS.clear()