Three node selection operators added, patch by Michał Ziułek, thanks!
[blender-staging.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                 
10                 snode = context.space_data
11
12                 row = layout.row(align=True)
13                 row.template_header()
14
15                 if context.area.show_menus:
16                         sub = row.row(align=True)
17                         sub.itemM("NODE_MT_view")
18                         sub.itemM("NODE_MT_select")
19                         sub.itemM("NODE_MT_add")
20                         sub.itemM("NODE_MT_node")
21
22                 row = layout.row()
23                 row.itemR(snode, "tree_type", text="", expand=True)
24
25                 if snode.tree_type == 'MATERIAL':
26                         ob = snode.id_from
27                         id = snode.id
28                         if ob:
29                                 layout.template_ID(ob, "active_material", new="material.new")
30                         if id:
31                                 layout.itemR(id, "use_nodes")
32
33                 elif snode.tree_type == 'TEXTURE':
34                         row.itemR(snode, "texture_type", text="", expand=True)
35
36                         id = snode.id
37                         id_from = snode.id_from
38                         if id_from:
39                                 layout.template_ID(id_from, "active_texture", new="texture.new")
40                         if id:
41                                 layout.itemR(id, "use_nodes")
42
43                 elif snode.tree_type == 'COMPOSITING':
44                         id = snode.id
45
46                         layout.itemR(id, "use_nodes")
47                         layout.itemR(id.render_data, "free_unused_nodes", text="Free Unused")
48                         layout.itemR(snode, "backdrop")
49
50 class NODE_MT_view(bpy.types.Menu):
51         __space_type__ = 'NODE_EDITOR'
52         __label__ = "View"
53
54         def draw(self, context):
55                 layout = self.layout
56
57                 # layout.itemO("grease_pencil..")
58                 # layout.itemS()
59
60                 layout.itemO("view2d.zoom_in")
61                 layout.itemO("view2d.zoom_out")
62
63                 layout.itemS()
64
65                 layout.itemO("node.view_all")
66                 layout.itemO("screen.screen_full_area")
67
68 class NODE_MT_select(bpy.types.Menu):
69         __space_type__ = 'NODE_EDITOR'
70         __label__ = "Select"
71
72         def draw(self, context):
73                 layout = self.layout
74
75                 layout.itemO("node.select_border")
76
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 bpy.types.register(NODE_HT_header)
117 bpy.types.register(NODE_MT_view)
118 bpy.types.register(NODE_MT_select)
119 bpy.types.register(NODE_MT_node)