pep8 warnings
[blender.git] / release / scripts / ui / space_node.py
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
19 # <pep8 compliant>
20 import bpy
21
22
23 class NODE_HT_header(bpy.types.Header):
24     bl_space_type = 'NODE_EDITOR'
25
26     def draw(self, context):
27         layout = self.layout
28
29         snode = context.space_data
30
31         row = layout.row(align=True)
32         row.template_header()
33
34         if context.area.show_menus:
35             sub = row.row(align=True)
36             sub.menu("NODE_MT_view")
37             sub.menu("NODE_MT_select")
38             sub.menu("NODE_MT_add")
39             sub.menu("NODE_MT_node")
40
41         row = layout.row()
42         row.prop(snode, "tree_type", text="", expand=True)
43
44         if snode.tree_type == 'MATERIAL':
45             ob = snode.id_from
46             snode_id = snode.id
47             if ob:
48                 layout.template_ID(ob, "active_material", new="material.new")
49             if snode_id:
50                 layout.prop(snode_id, "use_nodes")
51
52         elif snode.tree_type == 'TEXTURE':
53             row.prop(snode, "texture_type", text="", expand=True)
54
55             snode_id = snode.id
56             id_from = snode.id_from
57             if id_from:
58                 layout.template_ID(id_from, "active_texture", new="texture.new")
59             if snode_id:
60                 layout.prop(snode_id, "use_nodes")
61
62         elif snode.tree_type == 'COMPOSITING':
63             scene = snode.id
64
65             layout.prop(scene, "use_nodes")
66             layout.prop(scene.render, "free_unused_nodes", text="Free Unused")
67             layout.prop(snode, "backdrop")
68
69
70 class NODE_MT_view(bpy.types.Menu):
71     bl_label = "View"
72
73     def draw(self, context):
74         layout = self.layout
75
76         layout.operator("node.properties", icon='MENU_PANEL')
77         layout.separator()
78
79         layout.operator("view2d.zoom_in")
80         layout.operator("view2d.zoom_out")
81
82         layout.separator()
83
84         layout.operator("node.view_all")
85
86         layout.separator()
87
88         layout.operator("screen.area_dupli")
89         layout.operator("screen.screen_full_area")
90
91
92 class NODE_MT_select(bpy.types.Menu):
93     bl_label = "Select"
94
95     def draw(self, context):
96         layout = self.layout
97
98         layout.operator("node.select_border")
99
100         layout.separator()
101         layout.operator("node.select_all")
102         layout.operator("node.select_linked_from")
103         layout.operator("node.select_linked_to")
104
105
106 class NODE_MT_node(bpy.types.Menu):
107     bl_label = "Node"
108
109     def draw(self, context):
110         layout = self.layout
111
112         layout.operator("transform.translate")
113         layout.operator("transform.rotate")
114         layout.operator("transform.resize")
115
116         layout.separator()
117
118         layout.operator("node.duplicate_move")
119         layout.operator("node.delete")
120
121         layout.separator()
122         layout.operator("node.link_make")
123         layout.operator("node.link_make", text="Make and Replace Links").replace = True
124
125         layout.separator()
126         layout.operator("node.group_edit")
127         layout.operator("node.group_ungroup")
128         layout.operator("node.group_make")
129
130         layout.separator()
131
132         layout.operator("node.hide")
133         layout.operator("node.mute")
134
135         # XXX
136         # layout.operator("node.rename")
137
138         layout.separator()
139
140         layout.operator("node.show_cyclic_dependencies")
141
142
143 classes = [
144     NODE_HT_header,
145     NODE_MT_view,
146     NODE_MT_select,
147     NODE_MT_node]
148
149
150 def register():
151     register = bpy.types.register
152     for cls in classes:
153         register(cls)
154
155
156 def unregister():
157     unregister = bpy.types.unregister
158     for cls in classes:
159         unregister(cls)
160
161 if __name__ == "__main__":
162     register()