832f1cee6455380304c25fd0aeb41a7ac7ee2d44
[blender.git] / release / scripts / ui / properties_scene.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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from rna_prop_ui import PropertyPanel
22
23 narrowui = 180
24
25
26 class SceneButtonsPanel(bpy.types.Panel):
27     bl_space_type = 'PROPERTIES'
28     bl_region_type = 'WINDOW'
29     bl_context = "scene"
30
31     def poll(self, context):
32         return context.scene
33
34
35 class SCENE_PT_scene(SceneButtonsPanel):
36     bl_label = "Scene"
37     COMPAT_ENGINES = {'BLENDER_RENDER'}
38
39     def draw(self, context):
40         layout = self.layout
41         wide_ui = context.region.width > narrowui
42         scene = context.scene
43
44         if wide_ui:
45             layout.prop(scene, "camera")
46             layout.prop(scene, "set", text="Background")
47         else:
48             layout.prop(scene, "camera", text="")
49             layout.prop(scene, "set", text="")
50
51
52 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel):
53     _context_path = "scene"
54
55
56 class SCENE_PT_unit(SceneButtonsPanel):
57     bl_label = "Units"
58     COMPAT_ENGINES = {'BLENDER_RENDER'}
59
60     def draw(self, context):
61         layout = self.layout
62         wide_ui = context.region.width > narrowui
63         unit = context.scene.unit_settings
64
65         col = layout.column()
66         col.row().prop(unit, "system", expand=True)
67
68         split = layout.split()
69         split.active = (unit.system != 'NONE')
70
71         col = split.column()
72         col.prop(unit, "scale_length", text="Scale")
73
74         if wide_ui:
75             col = split.column()
76         col.prop(unit, "use_separate")
77
78         layout.column().prop(unit, "rotation_units")
79
80
81 class SCENE_PT_keying_sets(SceneButtonsPanel):
82     bl_label = "Keying Sets"
83
84     def draw(self, context):
85         layout = self.layout
86
87         scene = context.scene
88         wide_ui = context.region.width > narrowui
89         row = layout.row()
90
91         col = row.column()
92         col.template_list(scene, "keying_sets", scene, "active_keying_set_index", rows=2)
93
94         col = row.column(align=True)
95         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
96         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
97
98         ks = scene.active_keying_set
99         if ks:
100             row = layout.row()
101
102             col = row.column()
103             col.prop(ks, "name")
104             col.prop(ks, "absolute")
105
106             if wide_ui:
107                 col = row.column()
108             col.label(text="Keyframing Settings:")
109             col.prop(ks, "insertkey_needed", text="Needed")
110             col.prop(ks, "insertkey_visual", text="Visual")
111             col.prop(ks, "insertkey_xyz_to_rgb", text="XYZ to RGB")
112
113
114 class SCENE_PT_keying_set_paths(SceneButtonsPanel):
115     bl_label = "Active Keying Set"
116
117     def poll(self, context):
118         return (context.scene.active_keying_set is not None)
119
120     def draw(self, context):
121         layout = self.layout
122
123         scene = context.scene
124         ks = scene.active_keying_set
125         wide_ui = context.region.width > narrowui
126
127         row = layout.row()
128         row.label(text="Paths:")
129
130         row = layout.row()
131
132         col = row.column()
133         col.template_list(ks, "paths", ks, "active_path_index", rows=2)
134
135         col = row.column(align=True)
136         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
137         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
138
139         ksp = ks.active_path
140         if ksp:
141             col = layout.column()
142             col.label(text="Target:")
143             col.template_any_ID(ksp, "id", "id_type")
144             col.template_path_builder(ksp, "data_path", ksp.id)
145
146
147             row = layout.row()
148
149             col = row.column()
150             col.label(text="Array Target:")
151             col.prop(ksp, "entire_array")
152             if ksp.entire_array is False:
153                 col.prop(ksp, "array_index")
154
155             if wide_ui:
156                 col = row.column()
157             col.label(text="F-Curve Grouping:")
158             col.prop(ksp, "grouping")
159             if ksp.grouping == 'NAMED':
160                 col.prop(ksp, "group")
161
162
163 class SCENE_PT_physics(SceneButtonsPanel):
164     bl_label = "Gravity"
165     COMPAT_ENGINES = {'BLENDER_RENDER'}
166
167     def draw_header(self, context):
168         self.layout.prop(context.scene, "use_gravity", text="")
169
170     def draw(self, context):
171         layout = self.layout
172
173         scene = context.scene
174         wide_ui = context.region.width > narrowui
175
176         layout.active = scene.use_gravity
177
178         if wide_ui:
179             layout.prop(scene, "gravity", text="")
180         else:
181             layout.column().prop(scene, "gravity", text="")
182
183
184 class SCENE_PT_simplify(SceneButtonsPanel):
185     bl_label = "Simplify"
186     COMPAT_ENGINES = {'BLENDER_RENDER'}
187
188     def draw_header(self, context):
189         scene = context.scene
190         rd = scene.render_data
191         self.layout.prop(rd, "use_simplify", text="")
192
193     def draw(self, context):
194         layout = self.layout
195         scene = context.scene
196         rd = scene.render_data
197         wide_ui = context.region.width > narrowui
198
199         layout.active = rd.use_simplify
200
201         split = layout.split()
202
203         col = split.column()
204         col.prop(rd, "simplify_subdivision", text="Subdivision")
205         col.prop(rd, "simplify_child_particles", text="Child Particles")
206
207         if wide_ui:
208             col = split.column()
209         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
210         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
211
212 bpy.types.register(SCENE_PT_scene)
213 bpy.types.register(SCENE_PT_unit)
214 bpy.types.register(SCENE_PT_keying_sets)
215 bpy.types.register(SCENE_PT_keying_set_paths)
216 bpy.types.register(SCENE_PT_physics)
217 bpy.types.register(SCENE_PT_simplify)
218
219 bpy.types.register(SCENE_PT_custom_props)