1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import Header, Menu, Panel
24 class NODE_HT_header(Header):
25 bl_space_type = 'NODE_EDITOR'
27 def draw(self, context):
32 snode = context.space_data
34 id_from = snode.id_from
35 toolsettings = context.tool_settings
37 row = layout.row(align=True)
40 if context.area.show_menus:
41 row.menu("NODE_MT_view")
42 row.menu("NODE_MT_select")
43 row.menu("NODE_MT_add")
44 row.menu("NODE_MT_node")
46 layout.prop(snode, "tree_type", text="", expand=True)
48 if snode.tree_type == 'ShaderNodeTree':
49 if scene.render.use_shading_nodes:
50 layout.prop(snode, "shader_type", text="", expand=True)
52 if (not scene.render.use_shading_nodes or snode.shader_type == 'OBJECT') and ob:
53 # Show material.new when no active ID/slot exists
54 if not id_from and ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'METABALL'}:
55 layout.template_ID(ob, "active_material", new="material.new")
56 # Material ID, but not for Lamps
57 if id_from and ob.type != 'LAMP':
58 layout.template_ID(id_from, "active_material", new="material.new")
59 # Don't show "Use Nodes" Button when Engine is BI for Lamps
60 if snode_id and not (scene.render.use_shading_nodes == 0 and ob.type == 'LAMP'):
61 layout.prop(snode_id, "use_nodes")
63 if snode.shader_type == 'WORLD':
64 layout.template_ID(scene, "world", new="world.new")
66 layout.prop(snode_id, "use_nodes")
68 elif snode.tree_type == 'TextureNodeTree':
69 layout.prop(snode, "texture_type", text="", expand=True)
72 if snode.texture_type == 'BRUSH':
73 layout.template_ID(id_from, "texture", new="texture.new")
75 layout.template_ID(id_from, "active_texture", new="texture.new")
77 layout.prop(snode_id, "use_nodes")
79 elif snode.tree_type == 'CompositorNodeTree':
80 layout.prop(snode_id, "use_nodes")
81 layout.prop(snode_id.render, "use_free_unused_nodes", text="Free Unused")
82 layout.prop(snode, "show_backdrop")
83 if snode.show_backdrop:
84 row = layout.row(align=True)
85 row.prop(snode, "backdrop_channels", text="", expand=True)
86 layout.prop(snode, "use_auto_render")
89 # Custom node tree is edited as independent ID block
90 layout.template_ID(snode, "node_tree", new="node.new_node_tree")
92 layout.prop(snode, "pin", text="")
93 layout.operator("node.tree_path_parent", text="", icon='FILE_PARENT')
98 row = layout.row(align=True)
99 row.prop(toolsettings, "use_snap", text="")
100 row.prop(toolsettings, "snap_node_element", text="", icon_only=True)
101 if toolsettings.snap_node_element != 'INCREMENT':
102 row.prop(toolsettings, "snap_target", text="")
104 row = layout.row(align=True)
105 row.operator("node.clipboard_copy", text="", icon='COPYDOWN')
106 row.operator("node.clipboard_paste", text="", icon='PASTEDOWN')
108 layout.template_running_jobs()
111 class NODE_MT_view(Menu):
114 def draw(self, context):
117 layout.operator("node.properties", icon='MENU_PANEL')
120 layout.operator("view2d.zoom_in")
121 layout.operator("view2d.zoom_out")
125 layout.operator("node.view_selected")
126 layout.operator("node.view_all")
128 if context.space_data.show_backdrop:
131 layout.operator("node.backimage_move", text="Backdrop move")
132 layout.operator("node.backimage_zoom", text="Backdrop zoom in").factor = 1.2
133 layout.operator("node.backimage_zoom", text="Backdrop zoom out").factor = 0.833
137 layout.operator("screen.area_dupli")
138 layout.operator("screen.screen_full_area")
141 class NODE_MT_select(Menu):
144 def draw(self, context):
147 layout.operator("node.select_border")
150 layout.operator("node.select_all").action = 'TOGGLE'
151 layout.operator("node.select_all", text="Inverse").action = 'INVERT'
152 layout.operator("node.select_linked_from")
153 layout.operator("node.select_linked_to")
154 layout.operator("node.select_same_type")
155 layout.operator("node.select_same_type_step").prev = True
156 layout.operator("node.select_same_type_step").prev = False
159 class NODE_MT_node(Menu):
162 def draw(self, context):
165 layout.operator("transform.translate")
166 layout.operator("transform.rotate")
167 layout.operator("transform.resize")
171 layout.operator("node.duplicate_move")
172 layout.operator("node.delete")
173 layout.operator("node.delete_reconnect")
177 layout.operator("node.join", text="Join in new Frame")
178 layout.operator("node.detach", text="Remove from Frame")
182 layout.operator("node.link_make")
183 layout.operator("node.link_make", text="Make and Replace Links").replace = True
184 layout.operator("node.links_cut")
185 layout.operator("node.links_detach")
189 layout.operator("node.group_edit")
190 layout.operator("node.group_ungroup")
191 layout.operator("node.group_make")
192 layout.operator("node.group_insert")
196 layout.operator("node.hide_toggle")
197 layout.operator("node.mute_toggle")
198 layout.operator("node.preview_toggle")
199 layout.operator("node.hide_socket_toggle")
200 layout.operator("node.options_toggle")
201 layout.operator("node.collapse_hide_unused_toggle")
205 layout.operator("node.show_cyclic_dependencies")
206 layout.operator("node.read_renderlayers")
207 layout.operator("node.read_fullsamplelayers")
210 # Node Backdrop options
211 class NODE_PT_properties(Panel):
212 bl_space_type = 'NODE_EDITOR'
213 bl_region_type = 'UI'
214 bl_label = "Backdrop"
217 def poll(cls, context):
218 snode = context.space_data
219 return snode.tree_type == 'CompositorNodeTree'
221 def draw_header(self, context):
222 snode = context.space_data
223 self.layout.prop(snode, "show_backdrop", text="")
225 def draw(self, context):
228 snode = context.space_data
229 layout.active = snode.show_backdrop
230 layout.prop(snode, "backdrop_channels", text="")
231 layout.prop(snode, "backdrop_zoom", text="Zoom")
233 col = layout.column(align=True)
234 col.label(text="Offset:")
235 col.prop(snode, "backdrop_x", text="X")
236 col.prop(snode, "backdrop_y", text="Y")
237 col.operator("node.backimage_move", text="Move")
240 class NODE_PT_quality(bpy.types.Panel):
241 bl_space_type = 'NODE_EDITOR'
242 bl_region_type = 'UI'
243 bl_label = "Performance"
246 def poll(cls, context):
247 snode = context.space_data
248 return snode.tree_type == 'CompositorNodeTree' and snode.node_tree is not None
250 def draw(self, context):
253 snode = context.space_data
254 tree = snode.node_tree
256 col = layout.column()
257 col.prop(tree, "render_quality", text="Render")
258 col.prop(tree, "edit_quality", text="Edit")
259 col.prop(tree, "chunk_size")
261 col = layout.column()
262 col.prop(tree, "use_opencl")
263 col.prop(tree, "use_groupnode_buffer")
264 col.prop(tree, "two_pass")
265 col.prop(tree, "use_viewer_border")
266 col.prop(snode, "show_highlight")
267 col.prop(snode, "use_hidden_preview")
270 class NODE_MT_node_color_presets(Menu):
271 """Predefined node color"""
272 bl_label = "Color Presets"
273 preset_subdir = "node_color"
274 preset_operator = "script.execute_preset"
275 draw = Menu.draw_preset
278 class NODE_MT_node_color_specials(Menu):
279 bl_label = "Node Color Specials"
281 def draw(self, context):
284 layout.operator("node.node_copy_color", icon='COPY_ID')
287 class NODE_UL_interface_sockets(bpy.types.UIList):
288 def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
290 color = socket.draw_color(context)
292 if self.layout_type in {'DEFAULT', 'COMPACT'}:
293 row = layout.row(align=True)
295 # inputs get icon on the left
296 if socket.in_out == 'IN':
297 row.template_node_socket(color)
299 row.label(text=socket.name, icon_value=icon)
301 # outputs get icon on the right
302 if socket.in_out == 'OUT':
303 row.template_node_socket(color)
305 elif self.layout_type in {'GRID'}:
306 layout.alignment = 'CENTER'
307 layout.template_node_socket(color)
310 if __name__ == "__main__": # only for live edit.
311 bpy.utils.register_module(__name__)