made scripts pass the pep8 test (though not fully pep8 yet)
[blender.git] / release / scripts / ui / space_node.py
1 # This software is distributable under the terms of the GNU
2 # General Public License (GPL) v2, the text of which can be found at
3 # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise
4 # using this module constitutes acceptance of the terms of this License.
5
6 # <pep8 compliant>
7 import bpy
8
9
10 class NODE_HT_header(bpy.types.Header):
11     bl_space_type = 'NODE_EDITOR'
12
13     def draw(self, context):
14         layout = self.layout
15
16         snode = context.space_data
17
18         row = layout.row(align=True)
19         row.template_header()
20
21         if context.area.show_menus:
22             sub = row.row(align=True)
23             sub.itemM("NODE_MT_view")
24             sub.itemM("NODE_MT_select")
25             sub.itemM("NODE_MT_add")
26             sub.itemM("NODE_MT_node")
27
28         row = layout.row()
29         row.itemR(snode, "tree_type", text="", expand=True)
30
31         if snode.tree_type == 'MATERIAL':
32             ob = snode.id_from
33             id = snode.id
34             if ob:
35                 layout.template_ID(ob, "active_material", new="material.new")
36             if id:
37                 layout.itemR(id, "use_nodes")
38
39         elif snode.tree_type == 'TEXTURE':
40             row.itemR(snode, "texture_type", text="", expand=True)
41
42             id = snode.id
43             id_from = snode.id_from
44             if id_from:
45                 layout.template_ID(id_from, "active_texture", new="texture.new")
46             if id:
47                 layout.itemR(id, "use_nodes")
48
49         elif snode.tree_type == 'COMPOSITING':
50             id = snode.id
51
52             layout.itemR(id, "use_nodes")
53             layout.itemR(id.render_data, "free_unused_nodes", text="Free Unused")
54             layout.itemR(snode, "backdrop")
55
56
57 class NODE_MT_view(bpy.types.Menu):
58     bl_label = "View"
59
60     def draw(self, context):
61         layout = self.layout
62
63         # layout.itemO("grease_pencil..")
64         # layout.itemS()
65
66         layout.itemO("view2d.zoom_in")
67         layout.itemO("view2d.zoom_out")
68
69         layout.itemS()
70
71         layout.itemO("node.view_all")
72         layout.itemO("screen.screen_full_area")
73
74
75 class NODE_MT_select(bpy.types.Menu):
76     bl_label = "Select"
77
78     def draw(self, context):
79         layout = self.layout
80
81         layout.itemO("node.select_border")
82
83         layout.itemS()
84         layout.itemO("node.select_all")
85         layout.itemO("node.select_linked_from")
86         layout.itemO("node.select_linked_to")
87
88
89 class NODE_MT_node(bpy.types.Menu):
90     bl_label = "Node"
91
92     def draw(self, context):
93         layout = self.layout
94
95         layout.itemO("tfm.translate")
96         layout.itemO("tfm.resize")
97         layout.itemO("tfm.rotate")
98
99         layout.itemS()
100
101         layout.itemO("node.duplicate")
102         layout.itemO("node.delete")
103
104         # XXX
105         # layout.itemS()
106         # layout.itemO("node.make_link")
107         layout.itemS()
108         layout.itemO("node.group_edit")
109         layout.itemO("node.group_ungroup")
110         layout.itemO("node.group_make")
111
112         layout.itemS()
113
114         layout.itemO("node.visibility_toggle")
115
116         # XXX
117         # layout.itemO("node.rename")
118         # layout.itemS()
119         # layout.itemO("node.show_cyclic_dependencies")
120
121 bpy.types.register(NODE_HT_header)
122 bpy.types.register(NODE_MT_view)
123 bpy.types.register(NODE_MT_select)
124 bpy.types.register(NODE_MT_node)