* Fixed compiler warnings concerning the lack of a newline at the
[blender-staging.git] / release / scripts / ui / buttons_scene.py
1
2 import bpy
3
4 class SceneButtonsPanel(bpy.types.Panel):
5         __space_type__ = 'PROPERTIES'
6         __region_type__ = 'WINDOW'
7         __context__ = "scene"
8         
9         def poll(self, context):
10                 return (context.scene != None)
11
12 class RenderButtonsPanel(bpy.types.Panel):
13         __space_type__ = 'PROPERTIES'
14         __region_type__ = 'WINDOW'
15         __context__ = "scene"
16         # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
17         
18         def poll(self, context):
19                 rd = context.scene.render_data
20                 return (rd.use_game_engine==False) and (rd.engine in self.COMPAT_ENGINES)
21
22 class SCENE_PT_render(RenderButtonsPanel):
23         __label__ = "Render"
24         COMPAT_ENGINES = set(['BLENDER_RENDER'])
25         
26         def draw(self, context):
27                 layout = self.layout
28                 
29                 rd = context.scene.render_data
30
31                 row = layout.row()
32                 row.itemO("screen.render", text="Image", icon='ICON_RENDER_STILL')
33                 row.item_booleanO("screen.render", "animation", True, text="Animation", icon='ICON_RENDER_ANIMATION')
34
35                 layout.itemR(rd, "display_mode", text="Display")
36
37 class SCENE_PT_layers(RenderButtonsPanel):
38         __label__ = "Layers"
39         __default_closed__ = True
40         COMPAT_ENGINES = set(['BLENDER_RENDER'])
41         
42         def draw(self, context):
43                 layout = self.layout
44                 
45                 scene = context.scene
46                 rd = scene.render_data
47
48                 row = layout.row()
49                 row.template_list(rd, "layers", rd, "active_layer_index", rows=2)
50
51                 col = row.column(align=True)
52                 col.itemO("scene.render_layer_add", icon='ICON_ZOOMIN', text="")
53                 col.itemO("scene.render_layer_remove", icon='ICON_ZOOMOUT', text="")
54
55                 rl = rd.layers[rd.active_layer_index]
56
57                 split = layout.split()
58                 
59                 col = split.column()
60                 col.itemR(scene, "visible_layers", text="Scene")
61                 col = split.column()
62                 col.itemR(rl, "visible_layers", text="Layer")
63
64                 layout.itemR(rl, "light_override", text="Light")
65                 layout.itemR(rl, "material_override", text="Material")
66                 
67                 layout.itemS()
68                 layout.itemL(text="Include:")
69                 
70                 split = layout.split()
71
72                 col = split.column()
73                 col.itemR(rl, "zmask")
74                 row = col.row()
75                 row.itemR(rl, "zmask_negate", text="Negate")
76                 row.active = rl.zmask
77                 col.itemR(rl, "all_z")
78
79                 col = split.column()
80                 col.itemR(rl, "solid")
81                 col.itemR(rl, "halo")
82                 col.itemR(rl, "ztransp")
83                 col.itemR(rl, "sky")
84
85                 col = split.column()
86                 col.itemR(rl, "edge")
87                 col.itemR(rl, "strand")
88                 col.itemR(rl, "freestyle")
89
90                 if rl.zmask:
91                         split = layout.split()
92                         split.itemL(text="Zmask Layers:")
93                         split.column().itemR(rl, "zmask_layers", text="")
94                 
95                 layout.itemS()
96                 
97                 split = layout.split()
98                 
99                 col = split.column()
100                 col.itemL(text="Passes:")
101                 col.itemR(rl, "pass_combined")
102                 col.itemR(rl, "pass_z")
103                 col.itemR(rl, "pass_vector")
104                 col.itemR(rl, "pass_normal")
105                 col.itemR(rl, "pass_uv")
106                 col.itemR(rl, "pass_mist")
107                 col.itemR(rl, "pass_object_index")
108
109                 col = split.column()
110                 col.itemL()
111                 col.itemR(rl, "pass_color")
112                 col.itemR(rl, "pass_diffuse")
113                 row = col.row()
114                 row.itemR(rl, "pass_specular")
115                 row.itemR(rl, "pass_specular_exclude", text="", icon='ICON_X')
116                 row = col.row()
117                 row.itemR(rl, "pass_shadow")
118                 row.itemR(rl, "pass_shadow_exclude", text="", icon='ICON_X')
119                 row = col.row()
120                 row.itemR(rl, "pass_ao")
121                 row.itemR(rl, "pass_ao_exclude", text="", icon='ICON_X')
122                 row = col.row()
123                 row.itemR(rl, "pass_reflection")
124                 row.itemR(rl, "pass_reflection_exclude", text="", icon='ICON_X')
125                 row = col.row()
126                 row.itemR(rl, "pass_refraction")
127                 row.itemR(rl, "pass_refraction_exclude", text="", icon='ICON_X')
128
129                 if rl.freestyle:
130                         layout.itemS()
131
132                         split = layout.split()
133
134                         col = split.column()
135                         col.itemL(text="Freestyle:")
136                         freestyle = rl.freestyle_settings
137                         col.itemR(freestyle, "sphere_radius", text="Sphere Radius")
138                         col.itemR(freestyle, "ridges_and_valleys", text="Ridges and Valleys")
139                         col.itemR(freestyle, "suggestive_contours", text="Suggestive Contours")
140                         col.itemR(freestyle, "dkr_epsilon", text="Dkr Epsilon")
141
142                         col.itemO("scene.freestyle_module_add", text="Add Style Module")
143
144                         for i, module in enumerate(freestyle.modules):
145                                 box = layout.box()
146                                 box.set_context_pointer("freestyle_module", module)
147                                 row = box.row(align=True)
148                                 row.itemR(module, "is_displayed", text="")
149                                 row.itemR(module, "module_path", text="")
150                                 row.itemO("scene.freestyle_module_remove", icon='ICON_X', text="")
151                                 props = row.itemO("scene.freestyle_module_move_up", icon='VICON_MOVE_UP', text="", properties=True)
152                                 props.active = (i > 0)
153                                 props = row.itemO("scene.freestyle_module_move_down", icon='VICON_MOVE_DOWN', text="", properties=True)
154                                 props.active = (i < len(freestyle.modules) - 1)
155
156 class SCENE_PT_shading(RenderButtonsPanel):
157         __label__ = "Shading"
158         COMPAT_ENGINES = set(['BLENDER_RENDER'])
159
160         def draw(self, context):
161                 layout = self.layout
162                 
163                 rd = context.scene.render_data
164                 
165                 split = layout.split()
166                 
167                 col = split.column()
168                 col.itemR(rd, "render_textures", text="Textures")
169                 col.itemR(rd, "render_shadows", text="Shadows")
170                 col.itemR(rd, "render_sss", text="Subsurface Scattering")
171                 col.itemR(rd, "render_envmaps", text="Environment Map")
172                 
173                 col = split.column()
174                 col.itemR(rd, "render_raytracing", text="Ray Tracing")
175                 col.itemR(rd, "color_management")
176                 col.itemR(rd, "alpha_mode", text="Alpha")
177
178 class SCENE_PT_performance(RenderButtonsPanel):
179         __label__ = "Performance"
180         __default_closed__ = True
181         COMPAT_ENGINES = set(['BLENDER_RENDER'])
182
183         def draw(self, context):
184                 layout = self.layout
185                 
186                 rd = context.scene.render_data
187
188                 split = layout.split()
189                 
190                 col = split.column(align=True)
191                 col.itemL(text="Threads:")
192                 col.row().itemR(rd, "threads_mode", expand=True)
193                 sub = col.column()
194                 sub.enabled = rd.threads_mode == 'THREADS_FIXED'
195                 sub.itemR(rd, "threads")
196                 col.itemL(text="Tiles:")
197                 col.itemR(rd, "parts_x", text="X")
198                 col.itemR(rd, "parts_y", text="Y")
199
200                 col = split.column()
201                 col.itemL(text="Memory:")
202                 sub = col.column()
203                 sub.itemR(rd, "save_buffers")
204                 sub.enabled = not rd.full_sample
205                 sub = col.column()
206                 sub.active = rd.use_compositing
207                 sub.itemR(rd, "free_image_textures")
208                 sub = col.column()
209                 sub.active = rd.render_raytracing
210                 sub.itemL(text="Acceleration structure:")
211                 sub.itemR(rd, "raytrace_structure", text="")
212                 if rd.raytrace_structure == "OCTREE":
213                         sub.itemR(rd, "octree_resolution", text="Resolution")
214                 else:
215                         sub.itemR(rd, "use_instances", text="Instances")
216                 sub.itemR(rd, "use_local_coords", text="Local Coordinates")
217
218 class SCENE_PT_post_processing(RenderButtonsPanel):
219         __label__ = "Post Processing"
220         __default_closed__ = True
221         COMPAT_ENGINES = set(['BLENDER_RENDER'])
222
223         def draw(self, context):
224                 layout = self.layout
225                 
226                 rd = context.scene.render_data
227
228                 split = layout.split()
229
230                 col = split.column()
231                 col.itemR(rd, "use_compositing")
232                 col.itemR(rd, "use_sequencer")
233                 
234                 col = split.column()
235                 col.itemR(rd, "dither_intensity", text="Dither", slider=True)
236                 
237                 layout.itemS()
238                                 
239                 split = layout.split()
240                 
241                 col = split.column()
242                 col.itemR(rd, "fields", text="Fields")
243                 sub = col.column()
244                 sub.active = rd.fields
245                 sub.row().itemR(rd, "field_order", expand=True)
246                 sub.itemR(rd, "fields_still", text="Still")
247                 
248                 col = split.column()
249                 col.itemR(rd, "edge")
250                 sub = col.column()
251                 sub.active = rd.edge
252                 sub.itemR(rd, "edge_threshold", text="Threshold", slider=True)
253                 sub.itemR(rd, "edge_color", text="")
254                 
255                 layout.itemS()
256
257                 split = layout.split()
258                 col = split.column()
259                 col.itemR(rd, "freestyle", text="Freestyle")
260
261
262 class SCENE_PT_output(RenderButtonsPanel):
263         __label__ = "Output"
264         COMPAT_ENGINES = set(['BLENDER_RENDER'])
265
266         def draw(self, context):
267                 layout = self.layout
268                 
269                 rd = context.scene.render_data
270                 
271                 layout.itemR(rd, "output_path", text="")
272
273                 split = layout.split()
274                 col = split.column()
275                 col.itemR(rd, "file_format", text="")
276                 col.row().itemR(rd, "color_mode", text="Color", expand=True)
277
278                 col = split.column()
279                 col.itemR(rd, "file_extensions")
280                 col.itemR(rd, "use_overwrite")
281                 col.itemR(rd, "use_placeholder")
282
283                 if rd.file_format in ('AVIJPEG', 'JPEG'):
284                         split = layout.split()
285                         split.itemR(rd, "quality", slider=True)
286                         
287                 elif rd.file_format == 'OPENEXR':
288                         split = layout.split()
289                         
290                         col = split.column()
291                         col.itemL(text="Codec:")
292                         col.itemR(rd, "exr_codec", text="")
293
294                         subsplit = split.split()
295                         col = subsplit.column()
296                         col.itemR(rd, "exr_half")
297                         col.itemR(rd, "exr_zbuf")
298                         col = subsplit.column()
299                         col.itemR(rd, "exr_preview")
300                 
301                 elif rd.file_format == 'JPEG2000':
302                         split = layout.split()
303                         col = split.column()
304                         col.itemL(text="Depth:")
305                         col.row().itemR(rd, "jpeg2k_depth", expand=True)
306
307                         col = split.column()
308                         col.itemR(rd, "jpeg2k_preset", text="")
309                         col.itemR(rd, "jpeg2k_ycc")
310                         
311                 elif rd.file_format in ('CINEON', 'DPX'):
312                         split = layout.split()
313                         col = split.column()
314                         col.itemR(rd, "cineon_log", text="Convert to Log")
315
316                         col = split.column(align=True)
317                         col.active = rd.cineon_log
318                         col.itemR(rd, "cineon_black", text="Black")
319                         col.itemR(rd, "cineon_white", text="White")
320                         col.itemR(rd, "cineon_gamma", text="Gamma")
321                         
322                 elif rd.file_format == 'TIFF':
323                         split = layout.split()
324                         split.itemR(rd, "tiff_bit")
325
326 class SCENE_PT_encoding(RenderButtonsPanel):
327         __label__ = "Encoding"
328         __default_closed__ = True
329         COMPAT_ENGINES = set(['BLENDER_RENDER'])
330         
331         def poll(self, context):
332                 rd = context.scene.render_data
333                 return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
334
335         def draw(self, context):
336                 layout = self.layout
337                 
338                 rd = context.scene.render_data
339
340                 split = layout.split()
341                 
342                 split.itemR(rd, "ffmpeg_format")
343                 if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
344                         split.itemR(rd, "ffmpeg_codec")
345                 else:
346                         split.itemL()
347
348                 split = layout.split()
349         
350                 col = split.column()
351                 col.itemR(rd, "ffmpeg_video_bitrate")
352                 col.itemL(text="Rate:")
353                 col.itemR(rd, "ffmpeg_minrate", text="Minimum")
354                 col.itemR(rd, "ffmpeg_maxrate", text="Maximum")
355                 col.itemR(rd, "ffmpeg_buffersize", text="Buffer")
356                 
357                 col = split.column()
358                 col.itemR(rd, "ffmpeg_gopsize")
359                 col.itemR(rd, "ffmpeg_autosplit")
360                 col.itemL(text="Mux:")
361                 col.itemR(rd, "ffmpeg_muxrate", text="Rate")
362                 col.itemR(rd, "ffmpeg_packetsize", text="Packet Size")
363                 
364                 row = layout.row()
365                 row.itemL(text="Audio:")
366                 row = layout.row()
367                 row.itemR(rd, "ffmpeg_audio_codec")
368                 
369                 split = layout.split()
370
371                 col = split.column()
372                 col.itemR(rd, "ffmpeg_audio_bitrate")
373                 col.itemR(rd, "ffmpeg_audio_mixrate")
374                 col = split.column()
375                 col.itemR(rd, "ffmpeg_multiplex_audio")
376                 col.itemR(rd, "ffmpeg_audio_volume")
377
378 class SCENE_PT_antialiasing(RenderButtonsPanel):
379         __label__ = "Anti-Aliasing"
380         COMPAT_ENGINES = set(['BLENDER_RENDER'])
381
382         def draw_header(self, context):
383                 rd = context.scene.render_data
384
385                 self.layout.itemR(rd, "antialiasing", text="")
386
387         def draw(self, context):
388                 layout = self.layout
389                 
390                 rd = context.scene.render_data
391
392                 layout.active = rd.antialiasing
393
394                 split = layout.split()
395                 
396                 col = split.column()
397                 col.row().itemR(rd, "antialiasing_samples", expand=True)
398                 col.itemR(rd, "full_sample")
399
400                 col = split.column()
401                 col.itemR(rd, "pixel_filter", text="")
402                 col.itemR(rd, "filter_size", text="Size", slider=True)
403         
404 class SCENE_PT_dimensions(RenderButtonsPanel):
405         __label__ = "Dimensions"
406         COMPAT_ENGINES = set(['BLENDER_RENDER'])
407
408         def draw(self, context):
409                 layout = self.layout
410                 
411                 scene = context.scene
412                 rd = scene.render_data
413                 
414                 split = layout.split()
415                 
416                 col = split.column()
417                 sub = col.column(align=True)
418                 sub.itemL(text="Resolution:")
419                 sub.itemR(rd, "resolution_x", text="X")
420                 sub.itemR(rd, "resolution_y", text="Y")
421                 sub.itemR(rd, "resolution_percentage", text="")
422                 
423                 sub.itemL(text="Aspect Ratio:")
424                 sub.itemR(rd, "pixel_aspect_x", text="X")
425                 sub.itemR(rd, "pixel_aspect_y", text="Y")
426
427                 row = col.row()
428                 row.itemR(rd, "use_border", text="Border")
429                 rowsub = row.row()
430                 rowsub.active = rd.use_border
431                 rowsub.itemR(rd, "crop_to_border", text="Crop")
432                 
433                 col = split.column(align=True)
434                 col.itemL(text="Frame Range:")
435                 col.itemR(scene, "start_frame", text="Start")
436                 col.itemR(scene, "end_frame", text="End")
437                 col.itemR(scene, "frame_step", text="Step")
438                 
439                 col.itemL(text="Frame Rate:")
440                 col.itemR(rd, "fps")
441                 col.itemR(rd, "fps_base",text="/")
442
443 class SCENE_PT_stamp(RenderButtonsPanel):
444         __label__ = "Stamp"
445         __default_closed__ = True
446         COMPAT_ENGINES = set(['BLENDER_RENDER'])
447
448         def draw_header(self, context):
449                 rd = context.scene.render_data
450
451                 self.layout.itemR(rd, "render_stamp", text="")
452
453         def draw(self, context):
454                 layout = self.layout
455                 
456                 rd = context.scene.render_data
457
458                 layout.active = rd.render_stamp
459
460                 split = layout.split()
461                 
462                 col = split.column()
463                 col.itemR(rd, "stamp_time", text="Time")
464                 col.itemR(rd, "stamp_date", text="Date")
465                 col.itemR(rd, "stamp_frame", text="Frame")
466                 col.itemR(rd, "stamp_scene", text="Scene")
467                 col.itemR(rd, "stamp_camera", text="Camera")
468                 col.itemR(rd, "stamp_filename", text="Filename")
469                 col.itemR(rd, "stamp_marker", text="Marker")
470                 col.itemR(rd, "stamp_sequence_strip", text="Seq. Strip")
471
472                 col = split.column()
473                 col.active = rd.render_stamp
474                 col.itemR(rd, "stamp_foreground", slider=True)
475                 col.itemR(rd, "stamp_background", slider=True)
476                 col.itemR(rd, "stamp_font_size", text="Font Size")
477
478                 row = layout.split(percentage=0.2)
479                 row.itemR(rd, "stamp_note", text="Note")
480                 sub = row.row()
481                 sub.active = rd.stamp_note
482                 sub.itemR(rd, "stamp_note_text", text="")
483
484 class SCENE_PT_unit(RenderButtonsPanel):
485         __label__ = "Units"
486         __default_closed__ = True
487         COMPAT_ENGINES = set(['BLENDER_RENDER'])
488
489         def draw(self, context):
490                 layout = self.layout
491                 
492                 unit = context.scene.unit_settings
493                 
494                 col = layout.column()
495                 col.row().itemR(unit, "system", expand=True)
496                 
497                 row = layout.row()
498                 row.active = (unit.system != 'NONE')
499                 row.itemR(unit, "scale_length", text="Scale")
500                 row.itemR(unit, "use_separate")
501                 
502 class SCENE_PT_keying_sets(SceneButtonsPanel):
503         __label__ = "Keying Sets"
504         __default_closed__ = True
505         
506         def draw(self, context):
507                 layout = self.layout
508                 
509                 scene = context.scene
510                 
511                 row = layout.row()
512                 row.itemL(text="Keying Sets:")
513                 
514                 row = layout.row()
515                 
516                 col = row.column()
517                 col.template_list(scene, "keying_sets", scene, "active_keying_set_index", rows=2)
518                 
519                 col = row.column(align=True)
520                 col.itemO("anim.keying_set_add", icon='ICON_ZOOMIN', text="")
521                 col.itemO("anim.keying_set_remove", icon='ICON_ZOOMOUT', text="")
522                 
523                 ks = scene.active_keying_set
524                 if ks:
525                         row = layout.row()
526                         
527                         col = row.column()
528                         col.itemR(ks, "name")
529                         col.itemR(ks, "absolute")
530                         
531                         col = row.column()
532                         col.itemL(text="Keyframing Settings:")
533                         col.itemR(ks, "insertkey_needed", text="Needed")
534                         col.itemR(ks, "insertkey_visual", text="Visual")
535                         
536 class SCENE_PT_keying_set_paths(SceneButtonsPanel):
537         __label__ = "Active Keying Set"
538         __default_closed__ = True
539         
540         def poll(self, context):
541                 return (context.scene != None) and (context.scene.active_keying_set != None)
542         
543         def draw(self, context):
544                 layout = self.layout
545                 
546                 scene = context.scene
547                 ks = scene.active_keying_set
548                 
549                 row = layout.row()
550                 row.itemL(text="Paths:")
551                 
552                 row = layout.row()
553                 
554                 col = row.column()
555                 col.template_list(ks, "paths", ks, "active_path_index", rows=2)
556                 
557                 col = row.column(align=True)
558                 col.itemO("anim.keying_set_path_add", icon='ICON_ZOOMIN', text="")
559                 col.itemO("anim.keying_set_path_remove", icon='ICON_ZOOMOUT', text="")
560                 
561                 ksp = ks.active_path
562                 if ksp:
563                         col = layout.column()
564                         col.itemL(text="Target:")
565                         col.itemR(ksp, "id")
566                         col.itemR(ksp, "rna_path")
567                         
568                         
569                         row = layout.row()
570                         
571                         col = row.column()
572                         col.itemL(text="Array Target:")
573                         col.itemR(ksp, "entire_array")
574                         if ksp.entire_array == False:
575                                 col.itemR(ksp, "array_index")
576                                 
577                         col = row.column()
578                         col.itemL(text="F-Curve Grouping:")
579                         col.itemR(ksp, "grouping")
580                         if ksp.grouping == 'NAMED':
581                                 col.itemR(ksp, "group")
582                                 
583                         
584                         
585
586 class SCENE_PT_physics(RenderButtonsPanel):
587         __label__ = "Gravity"
588         COMPAT_ENGINES = set(['BLENDER_RENDER'])
589
590         def draw_header(self, context):
591                 self.layout.itemR(context.scene, "use_gravity", text="")
592
593         def draw(self, context):
594                 layout = self.layout
595                 
596                 scene = context.scene
597
598                 layout.active = scene.use_gravity
599
600                 layout.itemR(scene, "gravity", text="")
601
602                 
603 bpy.types.register(SCENE_PT_render)
604 bpy.types.register(SCENE_PT_layers)
605 bpy.types.register(SCENE_PT_dimensions)
606 bpy.types.register(SCENE_PT_antialiasing)
607 bpy.types.register(SCENE_PT_shading)
608 bpy.types.register(SCENE_PT_output)
609 bpy.types.register(SCENE_PT_encoding)
610 bpy.types.register(SCENE_PT_performance)
611 bpy.types.register(SCENE_PT_post_processing)
612 bpy.types.register(SCENE_PT_stamp)
613 bpy.types.register(SCENE_PT_unit)
614 bpy.types.register(SCENE_PT_keying_sets)
615 bpy.types.register(SCENE_PT_keying_set_paths)
616 bpy.types.register(SCENE_PT_physics)