Add ctrl-click rename to most lists in Blender UI and templates/examples.
[blender.git] / release / scripts / startup / bl_ui / properties_render_layer.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 from bpy.types import Menu, Panel, UIList
22
23
24 class RenderLayerButtonsPanel():
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "render_layer"
28     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
29
30     @classmethod
31     def poll(cls, context):
32         scene = context.scene
33         return scene and (scene.render.engine in cls.COMPAT_ENGINES)
34
35
36 class RENDERLAYER_UL_renderlayers(UIList):
37     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
38         # assert(isinstance(item, bpy.types.SceneRenderLayer)
39         layer = item
40         if self.layout_type in {'DEFAULT', 'COMPACT'}:
41             layout.prop(layer, "name", text="", icon_value=icon, emboss=False)
42             layout.prop(layer, "use", text="", index=index)
43         elif self.layout_type in {'GRID'}:
44             layout.alignment = 'CENTER'
45             layout.label("", icon_value=icon)
46
47
48 class RENDERLAYER_PT_layers(RenderLayerButtonsPanel, Panel):
49     bl_label = "Layer List"
50     bl_options = {'HIDE_HEADER'}
51     COMPAT_ENGINES = {'BLENDER_RENDER'}
52
53     def draw(self, context):
54         layout = self.layout
55
56         scene = context.scene
57         rd = scene.render
58
59         row = layout.row()
60         col = row.column()
61         col.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=1)
62
63         col = row.column(align=True)
64         col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
65         col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
66
67         row = layout.row()
68         rl = rd.layers.active
69         if rl:
70             row.prop(rl, "name")
71         row.prop(rd, "use_single_layer", text="", icon_only=True)
72
73
74 class RENDERLAYER_PT_layer_options(RenderLayerButtonsPanel, Panel):
75     bl_label = "Layer"
76     COMPAT_ENGINES = {'BLENDER_RENDER'}
77
78     def draw(self, context):
79         layout = self.layout
80
81         scene = context.scene
82         rd = scene.render
83         rl = rd.layers.active
84
85         split = layout.split()
86
87         col = split.column()
88         col.prop(scene, "layers", text="Scene")
89         col.label(text="")
90         col.prop(rl, "light_override", text="Light")
91         col.prop(rl, "material_override", text="Material")
92
93         col = split.column()
94         col.prop(rl, "layers", text="Layer")
95         col.prop(rl, "layers_zmask", text="Mask Layer")
96
97         layout.separator()
98         layout.label(text="Include:")
99
100         split = layout.split()
101
102         col = split.column()
103         col.prop(rl, "use_zmask")
104         row = col.row()
105         row.prop(rl, "invert_zmask", text="Negate")
106         row.active = rl.use_zmask
107         col.prop(rl, "use_all_z")
108
109         col = split.column()
110         col.prop(rl, "use_solid")
111         col.prop(rl, "use_halo")
112         col.prop(rl, "use_ztransp")
113
114         col = split.column()
115         col.prop(rl, "use_sky")
116         col.prop(rl, "use_strand")
117         if bpy.app.build_options.freestyle:
118             row = col.row()
119             row.prop(rl, "use_freestyle")
120             row.active = rd.use_freestyle
121
122
123 class RENDERLAYER_PT_layer_passes(RenderLayerButtonsPanel, Panel):
124     bl_label = "Passes"
125     bl_options = {'DEFAULT_CLOSED'}
126     COMPAT_ENGINES = {'BLENDER_RENDER'}
127
128     def draw_pass_type_buttons(self, box, rl, pass_type):
129         # property names
130         use_pass_type = "use_pass_" + pass_type
131         exclude_pass_type = "exclude_" + pass_type
132         # draw pass type buttons
133         row = box.row()
134         row.prop(rl, use_pass_type)
135         row.prop(rl, exclude_pass_type, text="")
136
137     def draw(self, context):
138         layout = self.layout
139
140         scene = context.scene
141         rd = scene.render
142         rl = rd.layers.active
143
144         split = layout.split()
145
146         col = split.column()
147         col.prop(rl, "use_pass_combined")
148         col.prop(rl, "use_pass_z")
149         col.prop(rl, "use_pass_vector")
150         col.prop(rl, "use_pass_normal")
151         col.prop(rl, "use_pass_uv")
152         col.prop(rl, "use_pass_mist")
153         col.prop(rl, "use_pass_object_index")
154         col.prop(rl, "use_pass_material_index")
155         col.prop(rl, "use_pass_color")
156
157         col = split.column()
158         col.prop(rl, "use_pass_diffuse")
159         self.draw_pass_type_buttons(col, rl, "specular")
160         self.draw_pass_type_buttons(col, rl, "shadow")
161         self.draw_pass_type_buttons(col, rl, "emit")
162         self.draw_pass_type_buttons(col, rl, "ambient_occlusion")
163         self.draw_pass_type_buttons(col, rl, "environment")
164         self.draw_pass_type_buttons(col, rl, "indirect")
165         self.draw_pass_type_buttons(col, rl, "reflection")
166         self.draw_pass_type_buttons(col, rl, "refraction")
167
168
169 if __name__ == "__main__":  # only for live edit.
170     bpy.utils.register_module(__name__)