Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / release / ui / space_node.py
1
2 import bpy
3
4 class NODE_HT_header(bpy.types.Header):
5         __space_type__ = "NODE_EDITOR"
6
7         def draw(self, context):
8                 layout = self.layout
9                 snode = context.space_data
10
11                 row = layout.row(align=True)
12                 row.template_header()
13
14                 if context.area.show_menus:
15                         sub = row.row(align=True)
16                         sub.itemM("NODE_MT_view")
17                         sub.itemM("NODE_MT_select")
18                         sub.itemM("NODE_MT_add")
19                         sub.itemM("NODE_MT_node")
20
21                 row = layout.row()
22                 row.itemR(snode, "tree_type", text="", expand=True)
23
24                 if snode.tree_type == 'MATERIAL':
25                         ob = snode.id_from
26                         id = snode.id
27                         if ob:
28                                 layout.template_ID(ob, "active_material", new="material.new")
29                         if id:
30                                 layout.itemR(id, "use_nodes", toggle=True)
31
32                 elif snode.tree_type == 'TEXTURE':
33                         row.itemR(snode, "texture_type", text="", expand=True)
34
35                         id = snode.id
36                         id_from = snode.id_from
37                         if id_from:
38                                 layout.template_ID(id_from, "active_texture", new="texture.new")
39                         if id:
40                                 layout.itemR(id, "use_nodes", toggle=True)
41
42                 elif snode.tree_type == 'COMPOSITING':
43                         id = snode.id
44
45                         layout.itemR(id, "use_nodes", toggle=True)
46                         layout.itemR(id.render_data, "free_unused_nodes", text="Free Unused", toggle=True)
47                         layout.itemR(snode, "backdrop", toggle=True)
48
49 class NODE_MT_view(bpy.types.Menu):
50         __space_type__ = "NODE_EDITOR"
51         __label__ = "View"
52
53         def draw(self, context):
54                 layout = self.layout
55
56                 # layout.itemO("grease_pencil..")
57                 # layout.itemS()
58
59                 layout.itemO("view2d.zoom_in")
60                 layout.itemO("view2d.zoom_out")
61
62                 layout.itemS()
63
64                 layout.itemO("node.view_all")
65                 layout.itemO("screen.screen_full_area")
66
67 class NODE_MT_select(bpy.types.Menu):
68         __space_type__ = "NODE_EDITOR"
69         __label__ = "Select"
70
71         def draw(self, context):
72                 layout = self.layout
73
74                 layout.itemO("node.select_border")
75
76                 # XXX
77                 # layout.itemS()
78                 # layout.itemO("node.select_all")
79                 # layout.itemO("node.select_linked_from")
80                 # layout.itemO("node.select_linked_to")
81
82 class NODE_MT_node(bpy.types.Menu):
83         __space_type__ = "NODE_EDITOR"
84         __label__ = "Node"
85
86         def draw(self, context):
87                 layout = self.layout
88
89                 layout.itemO("tfm.translate")
90                 layout.itemO("tfm.resize")
91                 layout.itemO("tfm.rotate")
92
93                 layout.itemS()
94
95                 layout.itemO("node.duplicate")
96                 layout.itemO("node.delete")
97
98                 # XXX
99                 # layout.itemS()
100                 # layout.itemO("node.make_link")
101                 # layout.itemS()
102                 # layout.itemO("node.edit_group")
103                 # layout.itemO("node.ungroup")
104                 # layout.itemO("node.group")
105                 # layout.itemO("node.make_link")
106
107                 layout.itemS()
108
109                 layout.itemO("node.visibility_toggle")
110
111                 # XXX
112                 # layout.itemO("node.rename")
113                 # layout.itemS()
114                 # layout.itemO("node.show_cyclic_dependencies")
115
116
117 bpy.types.register(NODE_HT_header)
118 bpy.types.register(NODE_MT_view)
119 bpy.types.register(NODE_MT_select)
120 bpy.types.register(NODE_MT_node)
121