cleanup for addon python internals, fix filtering bug.
[blender.git] / release / scripts / ui / properties_render.py
index fbb402efaaa34cc20310957a7e0c986880ae347d..23dc434ae38f968883cd86d606bc57e4f6e79afc 100644 (file)
@@ -12,7 +12,7 @@
 #
 #  You should have received a copy of the GNU General Public License
 #  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 # ##### END GPL LICENSE BLOCK #####
 
@@ -29,6 +29,13 @@ class RENDER_MT_presets(bpy.types.Menu):
     draw = bpy.types.Menu.draw_preset
 
 
+class RENDER_MT_ffmpeg_presets(bpy.types.Menu):
+    bl_label = "FFMPEG Presets"
+    preset_subdir = "ffmpeg"
+    preset_operator = "script.python_file_run"
+    draw = bpy.types.Menu.draw_preset
+
+
 class RenderButtonsPanel(bpy.types.Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -36,28 +43,28 @@ class RenderButtonsPanel(bpy.types.Panel):
     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
 
     def poll(self, context):
-        rd = context.scene.render_data
+        rd = context.scene.render
         return (context.scene and rd.use_game_engine is False) and (rd.engine in self.COMPAT_ENGINES)
 
 
 class RENDER_PT_render(RenderButtonsPanel):
     bl_label = "Render"
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render_data
+        rd = context.scene.render
         wide_ui = context.region.width > narrowui
 
         split = layout.split()
 
         col = split.column()
-        col.operator("screen.render", text="Image", icon='RENDER_STILL')
+        col.operator("render.render", text="Image", icon='RENDER_STILL')
 
         if wide_ui:
             col = split.column()
-        col.operator("screen.render", text="Animation", icon='RENDER_ANIMATION').animation = True
+        col.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True
 
         layout.prop(rd, "display_mode", text="Display")
 
@@ -65,13 +72,13 @@ class RENDER_PT_render(RenderButtonsPanel):
 class RENDER_PT_layers(RenderButtonsPanel):
     bl_label = "Layers"
     bl_default_closed = True
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def draw(self, context):
         layout = self.layout
 
         scene = context.scene
-        rd = scene.render_data
+        rd = scene.render
         wide_ui = context.region.width > narrowui
 
         row = layout.row()
@@ -137,11 +144,11 @@ class RENDER_PT_layers(RenderButtonsPanel):
         col.prop(rl, "pass_uv")
         col.prop(rl, "pass_mist")
         col.prop(rl, "pass_object_index")
+        col.prop(rl, "pass_color")
 
         if wide_ui:
             col = split.column()
         col.label()
-        col.prop(rl, "pass_color")
         col.prop(rl, "pass_diffuse")
         row = col.row()
         row.prop(rl, "pass_specular")
@@ -150,9 +157,18 @@ class RENDER_PT_layers(RenderButtonsPanel):
         row.prop(rl, "pass_shadow")
         row.prop(rl, "pass_shadow_exclude", text="", icon='X')
         row = col.row()
+        row.prop(rl, "pass_emit")
+        row.prop(rl, "pass_emit_exclude", text="", icon='X')
+        row = col.row()
         row.prop(rl, "pass_ao")
         row.prop(rl, "pass_ao_exclude", text="", icon='X')
         row = col.row()
+        row.prop(rl, "pass_environment")
+        row.prop(rl, "pass_environment_exclude", text="", icon='X')
+        row = col.row()
+        row.prop(rl, "pass_indirect")
+        row.prop(rl, "pass_indirect_exclude", text="", icon='X')
+        row = col.row()
         row.prop(rl, "pass_reflection")
         row.prop(rl, "pass_reflection_exclude", text="", icon='X')
         row = col.row()
@@ -162,12 +178,12 @@ class RENDER_PT_layers(RenderButtonsPanel):
 
 class RENDER_PT_shading(RenderButtonsPanel):
     bl_label = "Shading"
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render_data
+        rd = context.scene.render
         wide_ui = context.region.width > narrowui
 
         split = layout.split()
@@ -188,12 +204,12 @@ class RENDER_PT_shading(RenderButtonsPanel):
 class RENDER_PT_performance(RenderButtonsPanel):
     bl_label = "Performance"
     bl_default_closed = True
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render_data
+        rd = context.scene.render
         wide_ui = context.region.width > narrowui
 
         split = layout.split()
@@ -213,8 +229,8 @@ class RENDER_PT_performance(RenderButtonsPanel):
             col = split.column()
         col.label(text="Memory:")
         sub = col.column()
+        sub.enabled = not (rd.use_border or rd.full_sample)
         sub.prop(rd, "save_buffers")
-        sub.enabled = not rd.full_sample
         sub = col.column()
         sub.active = rd.use_compositing
         sub.prop(rd, "free_image_textures")
@@ -232,12 +248,12 @@ class RENDER_PT_performance(RenderButtonsPanel):
 class RENDER_PT_post_processing(RenderButtonsPanel):
     bl_label = "Post Processing"
     bl_default_closed = True
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render_data
+        rd = context.scene.render
         wide_ui = context.region.width > narrowui
 
         split = layout.split()
@@ -275,12 +291,12 @@ class RENDER_PT_post_processing(RenderButtonsPanel):
 
 class RENDER_PT_output(RenderButtonsPanel):
     bl_label = "Output"
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render_data
+        rd = context.scene.render
         wide_ui = context.region.width > narrowui
 
         layout.prop(rd, "output_path", text="")
@@ -292,7 +308,7 @@ class RENDER_PT_output(RenderButtonsPanel):
 
         if wide_ui:
             col = split.column()
-        col.prop(rd, "file_extensions")
+        col.prop(rd, "use_file_extension")
         col.prop(rd, "use_overwrite")
         col.prop(rd, "use_placeholder")
 
@@ -346,7 +362,7 @@ class RENDER_PT_output(RenderButtonsPanel):
 
         elif rd.file_format == 'QUICKTIME_CARBON':
             split = layout.split()
-            split.operator("scene.render_data_set_quicktime_codec")
+            split.operator("scene.render_set_quicktime_codec")
 
         elif rd.file_format == 'QUICKTIME_QTKIT':
             split = layout.split()
@@ -358,18 +374,20 @@ class RENDER_PT_output(RenderButtonsPanel):
 class RENDER_PT_encoding(RenderButtonsPanel):
     bl_label = "Encoding"
     bl_default_closed = True
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def poll(self, context):
-        rd = context.scene.render_data
+        rd = context.scene.render
         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
 
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render_data
+        rd = context.scene.render
         wide_ui = context.region.width > narrowui
 
+        layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
+
         split = layout.split()
 
         col = split.column()
@@ -407,11 +425,11 @@ class RENDER_PT_encoding(RenderButtonsPanel):
         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
 
         # Audio:
-        layout.prop(rd, "ffmpeg_multiplex_audio", text="Audio")
-
         sub = layout.column()
-        sub.active = rd.ffmpeg_multiplex_audio
-        sub.prop(rd, "ffmpeg_audio_codec", text="Codec")
+
+        if rd.ffmpeg_format not in ('MP3'):
+            sub.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
+
         sub.separator()
 
         split = sub.split()
@@ -427,17 +445,17 @@ class RENDER_PT_encoding(RenderButtonsPanel):
 
 class RENDER_PT_antialiasing(RenderButtonsPanel):
     bl_label = "Anti-Aliasing"
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def draw_header(self, context):
-        rd = context.scene.render_data
+        rd = context.scene.render
 
         self.layout.prop(rd, "antialiasing", text="")
 
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render_data
+        rd = context.scene.render
         wide_ui = context.region.width > narrowui
         layout.active = rd.antialiasing
 
@@ -445,7 +463,9 @@ class RENDER_PT_antialiasing(RenderButtonsPanel):
 
         col = split.column()
         col.row().prop(rd, "antialiasing_samples", expand=True)
-        col.prop(rd, "full_sample")
+        sub = col.row()
+        sub.enabled = not rd.use_border
+        sub.prop(rd, "full_sample")
 
         if wide_ui:
             col = split.column()
@@ -453,15 +473,35 @@ class RENDER_PT_antialiasing(RenderButtonsPanel):
         col.prop(rd, "filter_size", text="Size")
 
 
+class RENDER_PT_motion_blur(RenderButtonsPanel):
+    bl_label = "Full Sample Motion Blur"
+    bl_default_closed = True
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
+
+    def draw_header(self, context):
+        rd = context.scene.render
+
+        self.layout.prop(rd, "motion_blur", text="")
+
+    def draw(self, context):
+        layout = self.layout
+
+        rd = context.scene.render
+        layout.active = rd.motion_blur
+
+        row = layout.row()
+        row.prop(rd, "motion_blur_samples")
+
+
 class RENDER_PT_dimensions(RenderButtonsPanel):
     bl_label = "Dimensions"
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def draw(self, context):
         layout = self.layout
 
         scene = context.scene
-        rd = scene.render_data
+        rd = scene.render
         wide_ui = context.region.width > narrowui
 
         row = layout.row().split()
@@ -504,17 +544,17 @@ class RENDER_PT_dimensions(RenderButtonsPanel):
 class RENDER_PT_stamp(RenderButtonsPanel):
     bl_label = "Stamp"
     bl_default_closed = True
-    COMPAT_ENGINES = set(['BLENDER_RENDER'])
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def draw_header(self, context):
-        rd = context.scene.render_data
+        rd = context.scene.render
 
         self.layout.prop(rd, "render_stamp", text="")
 
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render_data
+        rd = context.scene.render
         wide_ui = context.region.width > narrowui
 
         layout.active = rd.render_stamp
@@ -547,15 +587,80 @@ class RENDER_PT_stamp(RenderButtonsPanel):
         sub.prop(rd, "stamp_note_text", text="")
 
 
-bpy.types.register(RENDER_MT_presets)
+class RENDER_PT_bake(RenderButtonsPanel):
+    bl_label = "Bake"
+    bl_default_closed = True
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
+
+    def draw(self, context):
+        layout = self.layout
+
+        rd = context.scene.render
+        wide_ui = context.region.width > narrowui
+
+        layout.operator("object.bake_image", icon='RENDER_STILL')
+
+        if wide_ui:
+            layout.prop(rd, "bake_type")
+        else:
+            layout.prop(rd, "bake_type", text="")
 
-bpy.types.register(RENDER_PT_render)
-bpy.types.register(RENDER_PT_layers)
-bpy.types.register(RENDER_PT_dimensions)
-bpy.types.register(RENDER_PT_antialiasing)
-bpy.types.register(RENDER_PT_shading)
-bpy.types.register(RENDER_PT_output)
-bpy.types.register(RENDER_PT_encoding)
-bpy.types.register(RENDER_PT_performance)
-bpy.types.register(RENDER_PT_post_processing)
-bpy.types.register(RENDER_PT_stamp)
+        if rd.bake_type == 'NORMALS':
+            if wide_ui:
+                layout.prop(rd, "bake_normal_space")
+            else:
+                layout.prop(rd, "bake_normal_space", text="")
+        elif rd.bake_type in ('DISPLACEMENT', 'AO'):
+            layout.prop(rd, "bake_normalized")
+
+        # col.prop(rd, "bake_aa_mode")
+        # col.prop(rd, "bake_enable_aa")
+
+        layout.separator()
+
+        split = layout.split()
+
+        col = split.column()
+        col.prop(rd, "bake_clear")
+        col.prop(rd, "bake_margin")
+        col.prop(rd, "bake_quad_split", text="Split")
+
+        if wide_ui:
+            col = split.column()
+        col.prop(rd, "bake_active")
+        sub = col.column()
+        sub.active = rd.bake_active
+        sub.prop(rd, "bake_distance")
+        sub.prop(rd, "bake_bias")
+
+
+classes = [
+    RENDER_MT_presets,
+    RENDER_MT_ffmpeg_presets,
+    RENDER_PT_render,
+    RENDER_PT_layers,
+    RENDER_PT_dimensions,
+    RENDER_PT_antialiasing,
+    RENDER_PT_motion_blur,
+    RENDER_PT_shading,
+    RENDER_PT_output,
+    RENDER_PT_encoding,
+    RENDER_PT_performance,
+    RENDER_PT_post_processing,
+    RENDER_PT_stamp,
+    RENDER_PT_bake]
+
+
+def register():
+    register = bpy.types.register
+    for cls in classes:
+        register(cls)
+
+
+def unregister():
+    unregister = bpy.types.unregister
+    for cls in classes:
+        unregister(cls)
+
+if __name__ == "__main__":
+    register()